Im scaling a wallpaper image down into a display area of 152x114 and noticed an images resolution affects the actual scaling of the image.
For instance, an image 1024x768 with a resolution of 96x96 scales down fine, but a same sized image with a resolution of 72x72 is clipped, with only a portion of the image appearing in the display area.
My maths is a little rusty on the subject, but ive managed to factor in the resolution of an image, but the outcome results with the image now slightly smaller than the display area, resulting in grey lines appearin on the bottom and on the right of the image.
Heres my code:
What else am I supposed to take into account in determining the actual image size so I can find the proper scaling ratio?
For instance, an image 1024x768 with a resolution of 96x96 scales down fine, but a same sized image with a resolution of 72x72 is clipped, with only a portion of the image appearing in the display area.
My maths is a little rusty on the subject, but ive managed to factor in the resolution of an image, but the outcome results with the image now slightly smaller than the display area, resulting in grey lines appearin on the bottom and on the right of the image.
Heres my code:
Code:
giXLen = 152
giYLen = 114
xImgLen = img.Width / (img.HorizontalResolution / 100)
yImgLen = img.Height / (img.VerticalResolution / 100)
dXratio = giXLen / xImgLen
dYratio = giYLen / yImgLen
Scale image
G.ScaleTransform(dXratio, dYratio)
G.DrawImage(img, pOffset)
What else am I supposed to take into account in determining the actual image size so I can find the proper scaling ratio?