Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.NET打印坐标转换_.net_Vb.net_Printing_Coordinate Transformation - Fatal编程技术网

.NET打印坐标转换

.NET打印坐标转换,.net,vb.net,printing,coordinate-transformation,.net,Vb.net,Printing,Coordinate Transformation,我找不到一个简单的答案。 我有像素坐标,我想在这些坐标处打印(横向)页面中的图像 在我的印刷活动中,我会: Dim mypoint As New PointF(1, 1192) e.Graphics.DrawImage(My.Resources.littleSquare, mypoint) 这显然不起作用:我指定像素,但驱动程序期望英寸(?)或什么 尝试:e.Graphics.PageUnit=GraphicsUnit.Inch,但运气不佳 我想要一种转换方法,如: Dim mypoint A

我找不到一个简单的答案。 我有像素坐标,我想在这些坐标处打印(横向)页面中的图像

在我的印刷活动中,我会:

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
有什么提示吗?谢谢。

我想我明白了

我的像素坐标不是固定的,而是相对于300dpi画布的,因此我必须进行双DPI转换,如下所示:

e.Graphics.PageUnit = GraphicsUnit.Pixel
dpiX = e.Graphics.DpiX
dpiY = e.Graphics.DpiY

Dim mypoint As New PointF(convertPixelsIntoInchesX(1501), convertPixelsIntoInchesY(1192))
e.Graphics.DrawImage(My.Resources.myblacksquare, mypoint)

Private Function convertPixelsIntoInchesX(ByVal pixel As Integer) As Single
   Return CSng(pixel * dpiX / 300)
End Function

Private Function convertPixelsIntoInchesY(ByVal pixel As Integer) As Single
        Return CSng(pixel * dpiY / 300)
End Function
我想我明白了

我的像素坐标不是固定的,而是相对于300dpi画布的,因此我必须进行双DPI转换,如下所示:

e.Graphics.PageUnit = GraphicsUnit.Pixel
dpiX = e.Graphics.DpiX
dpiY = e.Graphics.DpiY

Dim mypoint As New PointF(convertPixelsIntoInchesX(1501), convertPixelsIntoInchesY(1192))
e.Graphics.DrawImage(My.Resources.myblacksquare, mypoint)

Private Function convertPixelsIntoInchesX(ByVal pixel As Integer) As Single
   Return CSng(pixel * dpiX / 300)
End Function

Private Function convertPixelsIntoInchesY(ByVal pixel As Integer) As Single
        Return CSng(pixel * dpiY / 300)
End Function

在本地磁盘上创建映像文件并查看创建的内容。这将引导你走上正确的道路。(11192)不会是非常宽的图像(1像素)。不,你没有回答这个问题。图像很好,50x50像素,问题在于从像素到打印系统期望的坐标转换。在本地磁盘上创建图像文件并查看创建的内容。这将引导你走上正确的道路。(11192)不会是非常宽的图像(1像素)。不,你没有回答这个问题。图像很好,50x50像素,问题在于从像素到打印系统期望的坐标转换。