I have a gray scale image that I would like to enlarge so that I can better see the individual pixels. I've tried setting Smoothing mode to none and some different Interpolation Modes (as suggested on other questions on here), but the images still appear to me as if they are still doing some sort of blending before being displayed on the screen.
basically If I have a image that is
(White, White,
White, Black)
I want when I enlarge it to say 6x6, it to look like
(White, White, White, White, White, White
White, White, White, White, White, White
White, White, White, White, White, White
White, White, White, Black, Black, Black
White, White, White, Black, Black, Black
White, White, White, Black, Black, Black)
With no fading between the black and white areas, should look like a square. The image should look more "pixelized" rather then "Blurry"
Try to set interpolation mode:
g.InterpolationMode = InterpolationMode.NearestNeighbor;
I too was looking to do something similar. When I found this question neither answer were quite what I was looking for but combined they were. This is what got me to where I wanted to be and from what I can tell from your question what you want.
private Bitmap ResizeBitmap(Bitmap sourceBMP, int width, int height)
{
Bitmap result = new Bitmap(width, height);
using (Graphics g = Graphics.FromImage(result))
{
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
g.DrawImage(sourceBMP, 0, 0, width, height);
}
return result;
}
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