我有这段代码可以将图像大小调整为 300x300。但是在调整大小后,图像仍然失去了它的质量。我已经尝试过在其他网站上发布的其他解决方案,这些解决方案与此代码具有相同的代码实现,但它对我不起作用。请帮我解决一下这个。
Stream ream = FileUploadPic.FileContent;
System.Drawing.Image i = new Bitmap(ream);
Bitmap Orig_Photo = new Bitmap(i);
Bitmap resize_Photo = new Bitmap(300,300);
Graphics thumbnailGraph = Graphics.FromImage(resize_Photo);
thumbnailGraph.CompositingQuality = CompositingQuality.HighQuality;
thumbnailGraph.SmoothingMode = SmoothingMode.AntiAlias;
thumbnailGraph.InterpolationMode = InterpolationMode.HighQualityBicubic;
thumbnailGraph.PixelOffsetMode = PixelOffsetMode.HighQuality;
var imageRectangle = new Rectangle(0, 0, 300, 300);
thumbnailGraph.DrawImage(i, imageRectangle);
System.Drawing.Image ii = new Bitmap(resize_Photo);