C# Draw Image (Scaled) to Graphics, does not interpolate correctly. Fixes?

Ok I figured out the magic keywords: g. PixelOffsetMode = System.Drawing. Drawing2D.PixelOffsetMode.

Half; This coupled with setting the Interpolation Mode to NearestNeighbour allows for a full block to be drawn. Without setting the Interpolation mode, you get weird blending (expected). Without setting the PixelOffsetMode, the nearest neighbour algorithm has no neighbour to compare to on a blank paint and therefore only draws half the image, for half the width.

Setting it to offset half, moves everything over by -0.5px, and allows this algorithm to work for block textures.

I had the same problem and after trying several variations of PixelOffsetMode and InterpolationMode, this is what worked for me. For those searching via Google: Setting PixelOffsetMode to Half lets graphics. DrawImage(...) resize an image (like in MS Paint) without any aliasing and fills the destination size/rectangle with what you specify.

This is good if you want to overlay a single colour image/pattern when you don't care about artifacts/blending (because its one solid colour, there won't be any). – Andrew May 29 at 4:55.

InterpolationMode. NearestNeighbor is what you want to use in this case.

I have tried this, and it gives me a solid bitmap for exactly 1/2 the width, then nothing. Other modes give varying transparency after halfway, but InterpolationMode. NearestNeighbor only draws 0.5*wanted_width.

– Nick Dec 10 '10 at 20:55 That's not true, it must be a problem elsewhere in your code. I tested it myself just to be sure. The interpolation mode has nothing to do with the width of the drawn image.

– Ed S. Dec 10 '10 at 21:14 It does when there is nothing else drawn. Check below for my answer, it has to do with the PixelOffset as well.It is easily reproducable.

Take any control, override its OnPaint event, draw a 1px wide image for the full width, and it will only show up 50% wide. Now set the PixelOffset, and it shows 100%. This is with Visual Studio 2010, and .

NET 4.0 on many many different controls, all act the same. – Nick Dec 13 '10 at 18:05 I did test it and did not see that behavior. – Ed S.

Dec 13 '10 at 18:16.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions