C # solve the problem that the Image drawn by DrawImage becomes larger,
For example:
Private Image image = Resources. image1; // assume that image1 is as large as 360x600.
Private Graphics graphics;
Graphics. DrawImage (image, 0, 0); // draw the image at the coordinates of [0, 0]. I will wipe it! The image is larger than the source image!
Why ???
It turns out that DrawImage is a device-related function, that is, DrawImage will bring the screen parameters !!!
Therefore, the DPI of the image is usually 96. Our images are usually 72DPI.
For example, assume that the width of an Image object is 216 pixels, And the stored horizontal resolution value is 72 points/inch. Because 216 divided by 72 is equal to 3, DrawImage scales the image
The width of the 96-point/inch resolution is 3 inch. That is to say, DrawImage will display an image with a width of 96x3 = 288 pixels.
Solution Law Office:
1: graphics. DrawImage (image, 0, 0, image. Width, image. Height); // you can add the Width and Height of the source image.
2: image. SetResolution (96, 96); // set SetResolution so that it is displayed at a 96-point/inch resolution.