我正在尝试打印尺寸为 2x2 英寸的图像。根据分辨率创建了一个转换函数(英寸到像素)。然而,结果远不是 2x2 英寸,打印产生的图像几乎不能适合整张纸!我做错了什么吗?
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim graph = e.Graphics
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
e.Graphics.CompositingQuality = Drawing2D.CompositingQuality.HighQuality
Dim photo = Image.FromFile("C:\Users\Public\Pictures\Sample Pictures\Koala.jpg")
graph.DrawImage(photo, New RectangleF(0, 0, InchToPx(graph.DpiX, 2), InchToPx(graph.DpiY, 2)))
End Sub
Private Function InchToPx(ByVal dpi As Single, ByVal inches As Single) As Single
Return (inches * dpi)
End Function