C#:从文件打印图像

我想打印一个文件的图像,以适应一个页面完美。

所有我设法到现在是这样的:

private void button_print_Click(object sender, EventArgs e) { if (printDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { printDocument1.PrinterSettings = printDialog1.PrinterSettings; printDocument1.PrintPage += PrintPage; printDocument1.Print(); } } private void PrintPage(object o, PrintPageEventArgs e) { System.Drawing.Image img = imgOriginal; Point loc = new Point(0, 24); e.Graphics.DrawImage(img, loc); } 

这里的问题是,图像是很大的,以适应完美的页面。 我能做什么? 所有线程的问题,我发现谷歌是不是那么有希望。

有任何想法吗?

提前致谢

Marco Frost

 private void PrintPage(object o, PrintPageEventArgs e) { string filepath = "D:\\patient images\\" + txtPatCode.Text + "\\" + lstImages.SelectedItems[0].Text; System.Drawing.Image img = Image.FromFile(filepath); ResizeImage(img, 200); Point loc = new Point(200, 200); e.Graphics.DrawImage(img, loc); } public static Image ResizeImage(Image img, int minsize) { var size = img.Size; if (size.Width >= size.Height) { // Could be: if (size.Height < minsize) size.Height = minsize; size.Height = minsize; size.Width = (size.Height * img.Width + img.Height - 1) / img.Height; } else { size.Width = minsize; size.Height = (size.Width * img.Height + img.Width - 1) / img.Width; } return new Bitmap(img, size); }