Image Resizing... PLEASE HELP!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • E

    Image Resizing... PLEASE HELP!

    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

    private static Image imageResize(Ima ge img, int newWidth, int newHeight){
    //Resizing Image
    Bitmap NewImg = new Bitmap(newWidth , newHeight);
    Graphics g = Graphics.FromIm age(NewImg);
    g.DrawImage(img , 0, 0, newWidth, newHeight);
    return NewImg;
    }

    public static void SaveHighQuality Jpeg(Image img,string filename){
    //Setting Quality
    EncoderParamete rs ep = new EncoderParamete rs();
    ep.Param[0] = new EncoderParamete r(Encoder.Quali ty,(long)90);

    //Get the list of available encoders
    ImageCodecInfo[] codecs=ImageCod ecInfo.GetImage Encoders();

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

    foreach(ImageCo decInfo codec in codecs) {
    if(codec.MimeTy pe=="image/jpeg")
    ici=codec;
    }

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






Working...