By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,399 Members | 1,593 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,399 IT Pros & Developers. It's quick & easy.

Image Resizing & Saving problem

P: n/a
I wrote code which Resizes images and then saves them below is the 2
methods. The problem is that half of the resized image turns out gray, as if
it wasn't completed. Could someone please tell me what could be the problem?
I have pasted code below. Also this is a link to sample image that has the
private static Image imageResize(Image img, int newWidth, int newHeight){
//Resizing Image
Bitmap NewImg = new Bitmap(newWidth, newHeight);
Graphics g = Graphics.FromImage(NewImg);
g.DrawImage(img, 0, 0, newWidth, newHeight);
return NewImg;

public static void SaveHighQualityJpeg(Image img,string filename){
//Setting Quality
EncoderParameters ep = new EncoderParameters();
ep.Param[0] = new EncoderParameter(Encoder.Quality,(long)90);

//Get the list of available encoders
ImageCodecInfo[] codecs=ImageCodecInfo.GetImageEncoders();

//find the encoder with the image/jpeg mime-type
ImageCodecInfo ici = null;

foreach(ImageCodecInfo codec in codecs) {

//Save the image

Nov 15 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.