winforms - C# user control scaling image wrongly -
i have usercontrol image property. image resources.resx , has size of 48x48.
when draw image on command using:
e.graphics.drawimage(image, 0, 0); //or e.graphics.drawimageunscaled(image, 0, 0);
the image scaled 1.5 times size. way maintain image size want pass rectangle methods.
why usercontrol/image behaving this?
when image scaled suppose referring number of pixels...
but drawimage utilize device resolution maintain "physical size".
see msdn:
the drawimage method draws image using physical size, image have right size in inches regardless of resolution (dots per inch) of display device. example, suppose image has pixel width of 216 , horizontal resolution of 72 dots per inch. if phone call drawimage draw image on device that has resolution of 96 dots per inch, pixel width of rendered image (216/72)*96 = 288.
...so reason of function behavior.
the same applies drawimageunscaled.
c# winforms user-controls
No comments:
Post a Comment