[Mono-devel-list] Re: ArgumentException thrown in Bitmap constructor
Jordi Mas
jmas at softcatala.org
Sat Jan 24 02:13:15 EST 2004
En/na Duncan Mak ha escrit:
>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?
>
>
I have been working on the Bitmap class this week.
At bitmap.cs, I have changed the way that we call
GdipCreateBitmapFromScan0 from the constructor public Bitmap (int, int ,
PixelFormat). I added a little note at the Cairo implementation of that
function (at bitmap.c) because changes have to be introduced in the
Linux/Cairo layer in order to emulate that GDI function correctly.
Since for a few weeks we will be finishing the System.Drawing high level
C# implementation using the Win32 native GDIPLUS.DLL if you use Cairo
under Linux a few things may not work as an expected.
Jordi,
--
Jordi Mas i Hernàndez (homepage http://www.softcatala.org/~jmas)
http://www.softcatala.org
More information about the Mono-devel-list
mailing list