Click here to Skip to main content
15,884,720 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to load an image and then want to resize it and then save the new resized image.
like the following
VB
g.DrawImage(img, new Rectangle(0, 0,
                      (int)(rect.Width - 200 * dCurZoom), (int)(rect.Height - 200 * dCurZoom))) ;

but problem is this that the resized image is drawn on original one and i am not able to save the new resized image seperatel. please help me!!!
Posted
Comments
irfanniazi 12-Apr-13 3:50am    
can you share a complete code please!!!!!!!!!!

1 solution

if (img.Width != width || img.Height != height)
                {
                    Bitmap newImage = new Bitmap(width, height);
                    using (Graphics gr = Graphics.FromImage(newImage))
                    {
                        gr.SmoothingMode = SmoothingMode.HighQuality;
                        gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
                        gr.PixelOffsetMode = PixelOffsetMode.HighQuality;
                        gr.DrawImage(img, new Rectangle(0, 0, width, height));
                    }

                    img.Dispose();
                    img = newImage;
                }
 
Share this answer
 
Comments
irfanniazi 12-Apr-13 3:37am    
gr.DrawImage(img, new Rectangle(0, 0, width, height));
herw "img" is which image. mean either it is new one or refernce of the image on which it is to be drawn
tumbledDown2earth 12-Apr-13 3:42am    
refernce of the image on which it is to be drawn

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