I've had the same image resizing code in place for 7+ years and it worked like a charm while targeting old .net frameworks (with the most recent being 4.61). I've finally got around to attempting to upgrade the application to .net 6, and for some reason the image resize code no longer produces valid image.
No exception is thrown, but the image it produces is corrupt or something, as only the very top of the photo looks correct, with the rest of the image sort of overlaid with zig-zaggy lines.
It doesn't do this for all images either, so I can't make sense of what is happening. My code is pretty simple and is as follows:
var newImage = new Bitmap(newWidth, newHeight);
using (Graphics graphicsHandle = Graphics.FromImage(newImage))
{
graphicsHandle.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphicsHandle.DrawImage(orgImage, 0, 0, newWidth, newHeight);
}
But the images look like this:
Or like this:
Literally, the only thing that's changed is targeting .net 6/core, but I don't know how to fix this. Any help would be greatly appreciated.