M
M
Maxim Nikitin2015-03-13 10:55:18
.NET
Maxim Nikitin, 2015-03-13 10:55:18

How to deal with loss of image details after saving (.NET Bitmap)?

I save images to disk, the same image can be of different resolutions.
In case of sufficient resolution, the image does not lose details:
2f5aec4ebd2141ce99b362eaa743aa16.png
At a lower resolution, details are lost after saving:
096f01d446c443c8bbdee782fadc7ba7.png
Are there any algorithms for saving in such a way that at least 1px wide lines remain?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor Ermolaev, 2015-03-13
@MaxSter

Depends on what format you save the image in. If you need lossless, then I recommend using the PNG format.

R
Rainbird, 2015-03-13
@Rainberd

Do you resize through System.Drawing.Graphics? Try playing with SmoothingMode, InterpolationMode, PixelOffsetMode:

var newBmp = new Bitmap(newWidth, newHeight);
using (Graphics g = Graphics.FromImage(newBmp)) {
    g.SmoothingMode = SmoothingMode.HighQuality;
    g.InterpolationMode = InterpolationMode.HighQualityBicubic; // или HighQualityBilinear
    g.PixelOffsetMode = PixelOffsetMode.HighQuality;
    g.DrawImage(oldBmp, new Rectangle(0, 0, newWidth, newHeight));
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question