Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Using g As Graphics = Graphics.FromHwnd(Me.Handle)
            Dim xv = PhysicalToPixels(1, g.DpiX)
        End Using
    End Sub
    Private Function PhysicalToPixels(ByVal physicalSize As Single, ByVal dpi As Single) As Single
        Return physicalSize / 25.4 * dpi
    End Function
調用方式:
如果PictureBox的圖元大小為800,600

那轉換成毫米
x   =   PhysicalToPixels(800,g.DpiX)
y   =   PhysicalToPixels(600,g.Dpiy)

 


arrow
arrow
    全站熱搜

    Roger 發表在 痞客邦 留言(0) 人氣()