使用 graphics.DrawImage(bitmap, 0, 0) 绘制图像时,如果bitmap是 new Bitmap(width, height) 生成的,则绘制是按原分辨率绘制的。如果图片超过 DC 的尺寸,则图片会显示不全。
但如果bitmap是通过 Bitmap::FromFile 从PNG加载的,则 graphics.DrawImage(bitmap, 0, 0) 不是原分辨率,做了缩放。
If the resolution used by GDI+ (usually 96 dots per inch) is different from the resolution stored in the Image object, then the DrawImage method will scale the image. For example, suppose an Image object has a width of 216 pixels and a stored horizontal resolution value of 72 dots per inch. Because 216/72 is 3, DrawImage will scale the image so that it has a width of 3 inches at a resolution of 96 dots per inch. That is, DrawImage will display an image that has a width of 96x3 = 288 pixels
获取GDI+的显示分辨率可以用 graphics.GetDpiX()。获取bitmap的分辨率可以用 bitmap.GetHorizontalResolution()。new Bitmap(width, height) 生成的 bitmap 是按默认96dpi生成的