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);
}