.NET打印坐标转换
对此我无法得到简单的答案。 我有像素坐标,我想在这些坐标的(横向)页面中打印图像。
在我的打印事件中,我这样做:
Dim mypoint As New PointF(1, 1192)
e.Graphics.DrawImage(My.Resources.littleSquare, mypoint)
这显然不起作用:我指定像素,但驱动程序期望英寸(?)还是什么?
尝试:e.Graphics.PageUnit = GraphicsUnit.Inch
但没有成功。
我想要一个转换方法,例如:
Dim mypoint As New PointF(convertPixelsIntoInches(1), convertPixelsIntoInches(1192))
e.Graphics.DrawImage(My.Resources.littleSquare, mypoint)
Private Function convertPixelsIntoInches(ByVal pixels As Integer) As Single
Return ??
End Function
有任何提示吗?谢谢。
I can't get a simple answer to this.
I have pixel coordinates, I want to print an image in a (landscape) page at those coords.
In my printing event I do:
Dim mypoint As New PointF(1, 1192)
e.Graphics.DrawImage(My.Resources.littleSquare, mypoint)
This obviously doesn't work: I specify pixels but the driver expects inches(?) or what?
Tried to: e.Graphics.PageUnit = GraphicsUnit.Inch
with no luck.
I'd like a conversion method like:
Dim mypoint As New PointF(convertPixelsIntoInches(1), convertPixelsIntoInches(1192))
e.Graphics.DrawImage(My.Resources.littleSquare, mypoint)
Private Function convertPixelsIntoInches(ByVal pixels As Integer) As Single
Return ??
End Function
Any hints? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我明白了。
我的像素坐标不固定,而是相对于 300dpi 画布,因此我必须进行双 DPI 转换,如下所示:
I think I got it.
My pixel coordinates are not fixed, but relative to a 300dpi canvas, thus I have to do a double DPI conversion, like this: