DrawImage resized image too small

前端 未结 1 1475
慢半拍i
慢半拍i 2020-11-29 13:21

When I draw an image using Graphics.DrawImage and draw it at a bigger size than the original image, it ends up being a bit too small. You can see this in the fo

相关标签:
1条回答
  • 2020-11-29 14:20

    The issue happens when scaling to 2x or larger.

    Looks like the whole problem is caused by the wrong default PixelOffsetMode.

    By offsetting pixels during rendering, you can improve render quality at the cost of render speed.

    Setting it to

    g.PixelOffsetMode = PixelOffsetMode.Half;
    

    makes it go away for me.

    Setting it to

    g.PixelOffsetMode = PixelOffsetMode.HighQuality;
    

    also works fine.

    Default, None and HighSpeed cause the image to be rendered a little to the left and up.

    Often you will also want to set InterpolationMode.NearestNeighbor.

    0 讨论(0)
提交回复
热议问题