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

Image Resizing... PLEASE HELP!

P: n/a
E
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
problem
http://productionserver.no-ip.com/im.../g2SPA0701.jpg
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) {
if(codec.MimeType=="image/jpeg")
ici=codec;
}

//Save the image
img.Save(filename,ici,ep);
}


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.