When I use this method to resize a bitmap:
private Bitmap ResizeBitmap(Bitmap b, int nWidth, int nHeight)
{
Bitmap result = new Bitmap(nWidth, nHeight);
using (Graphics g = Graphics.FromImage((Image)result))
{
g.SmoothingMode = SmoothingMode.None;
g.DrawImage(b, 0, 0, nWidth, nHeight);
}
return result;
}
It still uses antialiasing even though I specified:
g.SmoothingMode = SmoothingMode.None;
I want just a basic resizing without any smoothing.
Instead of doing
g.SmoothingMode = SmoothingMode.None;
you should do
g.InterpolationMode = InterpolationMode.NearestNeighbor;
Anti-aliasing is a sub-pixel thing, you're actually looking for Nearest Neighbour interpolation during the resize operation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With