locked
'Parameter is not valid' when creating bitmap with size specified RRS feed

  • Question

  • I am trying to read an image into a bitmap and then create a new bitmap with a specified size, effectively resizing the first bitmap:

                    image = new Bitmap(Path + FileName);
                    image = new Bitmap(image,new Size(Width, Height));

    or by

                    Image img = System.Drawing.Image.FromFile(Path + FileName);
                    image = new Bitmap(img,Size);

    In either case the second line throws an ArgumentException: 'Parameter is not valid'. If i do not specify a size object it works fine.


    Saturday, August 19, 2006 10:57 AM

Answers

  • You can't resize an image that way.  You'll need to use Graphics.DrawImage.  Check this thread for a code example.
    Saturday, August 19, 2006 11:48 AM

All replies

  • You can't resize an image that way.  You'll need to use Graphics.DrawImage.  Check this thread for a code example.
    Saturday, August 19, 2006 11:48 AM
  • Hi i am also getting the same exception "Parameter not valid" in my code

      MemoryStream ms = new MemoryStream(byteArrayIn);
     System.Drawing.Image returnImage = System.Drawing.Image.FromStream(ms);


    Actually the byteArrayIn 's length is 169014. And none of value in it is not greater than 255. But i am getting this exception.

    So my question is why i am getting this exception? How to solve?

    Please help me!!

    Thanks!!
    • Proposed as answer by Mandrew360 Tuesday, March 10, 2009 12:38 PM
    Tuesday, March 10, 2009 12:36 PM