[Mono-devel-list] ArgumentException thrown in Bitmap constructor

Duncan Mak duncan at ximian.com
Fri Jan 23 20:27:02 EST 2004


Hola Jordi,

While in Algorithms class today, I was kinda bored so I decided to start
implementing the DrawPath method. I tried to test my code with a sample
program, but I'm getting this error:

Unhandled Exception: System.ArgumentException: Could not allocate the
GdiPlus image: InvalidParameter in <0x00122> System.Drawing.Bitmap:.ctor
(int,int,System.Drawing.Imaging.PixelFormat)
in <0x0001a> System.Drawing.Bitmap:.ctor (int,int)
in <0x00061> (wrapper remoting-invoke-with-check)
System.Drawing.Bitmap:.ctor (int,int)
in <0x00077> .Draw:Main (string[])

Here is my program:

using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;

class Draw  {
        static void Main ()
        {
                Bitmap b = new Bitmap (100, 100);
                Graphics g = Graphics.FromImage (b);
		GraphicsPath path = new GraphicsPath ();

		path.DrawLine (1, 1, 100, 100);
                Pen p = new Pen (Color.Red, 4);
                g.DrawPath (p, path);

                b.Save ("foo.jpg", ImageFormat.Jpeg);
        }
}

I remember that you made a change to Bitmap recently regarding encoding
stuff, does this have anything to do with this exception being thrown?

Duncan.



More information about the Mono-devel-list mailing list