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
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
.