CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2003
    Location
    Malta
    Posts
    13

    Question Invalid Parameter Used

    Dear All, I have created a function to resize an image and save it to the server. This is the code:-

    try
    {
    System.Drawing.Image NewImg;

    System.Drawing.Image.GetThumbnailImageAbort dummyCallBack =
    new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);

    NewImg = fullSizeImg.GetThumbnailImage(image_width, image_height, dummyCallBack, IntPtr.Zero);
    NewImg.Save(path + image_name);

    int x = image_width;
    int y = image_height;
    string image_path = path + "\\" + image_name;
    Image oImg = Image.FromFile(image_path);
    Bitmap bmp = new Bitmap(x,y);

    System.Drawing.Imaging.Encoder Enc = System.Drawing.Imaging.Encoder.Transformation;
    EncoderParameters EncParms = new EncoderParameters(1);
    EncoderParameter EncParm;

    Graphics gr = Graphics.FromImage(bmp);
    gr.CompositingQuality = CompositingQuality.HighQuality;
    gr.SmoothingMode = SmoothingMode.HighQuality;
    gr.InterpolationMode = InterpolationMode.HighQualityBicubic;

    gr.DrawImage(oImg, 0, 0, x, y);
    gr.Save();

    EncParms.Param = new EncoderParameter[]
    {
    new EncoderParameter(Enc,(long)EncoderValue.CompressionLZW),
    new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100L)
    };
    ImageCodecInfo ici ;

    ici = GetProperEncoder(image_name);

    bmp.Save(image_path, ici, EncParms);
    oImg.Dispose();
    bmp.Dispose();

    }
    catch (Exception e)
    {
    Console.WriteLine("Caught: {0}",e.Message);
    }

    However I am getting an exception on this line :-

    bmp.Save(image_path, ici, EncParms);

    The exception is

    System.Object {System.ArgumentException} "Invalid Parameter Used"

    Can anybody help me please? Thanks for your help and time
    www.johannmontfort.com

  2. #2
    Join Date
    May 2003
    Location
    Germany
    Posts
    936

    Re: Invalid Parameter Used

    Seems that one of your parameters is null or the type of it is wrong. Check it.
    Useful or not? Rate my posting. Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured