本文介绍了提高调整大小图像的质量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Image backImage = Image.FromFile(Imagepath);
Image resolutionBackImage = backImage.GetThumbnailImage(height ,width, null, System.IntPtr.Zero);
resolutionBackImage.Save(path);


通过使用上面的代码调整图像的大小.但是其质量还不够.因此,请告诉我一种提高上述代码接收图像质量的方法.非常感谢


The image was resized by using above code. But its quality is not enough. So please tell me a way to increase the image quality recieving from above code. Thanks a lot

推荐答案


private static void TransformImage(int width, int height, string path, Image image,
            float scale)
        {
            Bitmap thump = new Bitmap(width, height);
            Graphics graphics = Graphics.FromImage(thump);
            Matrix transform = new Matrix();

            transform.Scale(scale, scale, MatrixOrder.Append);
            graphics.SetClip(new Rectangle(0, 0, width, height));
            graphics.Transform = transform;
            graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            graphics.DrawImage(image, 0, 0, image.Width, image.Height);

            ImageCodecInfo[] Info = ImageCodecInfo.GetImageEncoders();
            EncoderParameters Params = new EncoderParameters(1);
            Params.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100L);
            thump.Save(path, Info[1], Params);

            thump.Dispose();
            graphics.Dispose();
}


这篇关于提高调整大小图像的质量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 14:13