0
I’m trying to resize an image with this code.
public static Bitmap ResizeImage(Image image, int width)
{
var destRect = new Rectangle(0, 0, width, image.Height);
var destImage = new Bitmap(width, image.Height);
destImage.SetResolution(image.HorizontalResolution, image.VerticalResolution);
using (var graphics = Graphics.FromImage(destImage))
{
graphics.CompositingMode = CompositingMode.SourceCopy;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
graphics.DrawImage(image, destRect);
}
return destImage;
}
However, she is losing quality. This image shows the original barcode (277 pixels wide) at the top and the resized (270 wide) at the bottom.
what width are you going through and what formats are you getting, how are you saving? in my tests here not granulou
– Lucas Miranda
I am using zxing to generate barcode. Any width I place is not respected. The image is always 277 wide.
– Guilherme Almeida
This is showing me a question in your printer and not in the code
– Leandro Angelo