1

これに対する簡単な答えは得られません。私はピクセル座標を持っています。それらの座標で (ランドスケープ) ページに画像を印刷したいと思います。

私の印刷イベントでは、次のことを行います。

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

ヒントはありますか?ありがとう。

4

1 に答える 1

1

私はそれを手に入れたと思います。

私のピクセル座標は固定ではありませんが、300dpi キャンバスに対して相対的であるため、次のように 2 倍の 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
于 2011-08-23T13:49:34.730 に答える