View Single Post
  #2 (permalink)  
Old 01-14-2009, 9:54 PM
JohnH's Avatar
JohnH JohnH is offline
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 37
Posts: 10,303
Reputation: 1315
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

The printing GraphicsUnit is Display, which is 1/100th inch, while the image unit is Pixel. Convert the image measurements to Display units, then you can do the logic math with comparable values. Example:
Code:
Dim img As Image = Image.FromFile("img.bmp")

'image size in 1/100 inch measurement
Dim sz As New SizeF(100 * img.Width / img.HorizontalResolution, _
                    100 * img.Height / img.VerticalResolution)

Dim p As New PointF((e.PageBounds.Width - sz.Width) / 2, _
                    (e.PageBounds.Height - sz.Height) / 2)

e.Graphics.DrawImage(img, p)

img.Dispose()
__________________
Reply With Quote