Click here to Skip to main content
15,922,630 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
C#
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
Posted
Updated 16-Aug-11 20:39pm
v6

C#
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(); 
}
 
Share this answer
 
 
Share this answer
 
Comments
Jeremy Shin Woo 17-Aug-11 1:45am    
But I haven,t a chance to change previous code and use to external reference file.. :(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900