[Mono-devel-list] [Patch] System.Drawing.Bitmap .NET Framework compatibility
Ben Maurer
bmaurer at ximian.com
Sat May 14 13:35:08 EDT 2005
On Sat, 2005-05-14 at 12:14 +0200, Kornél Pál wrote:
> Hi,
>
> System.Drawing.Bitmap in .NET Framework implements new Bitmap(original, ...)
> constructorst as copying the original bitmap to a memory bitmap.
>
> Mono implements it using GdipCloneBitmapAreaI.
>
> I don't know the behaviour of Cairo but GdipCloneBitmapAreaI on GDI+ results
> in a bitmap based on the original.
>
> As GDI+ draws bitmaps from the stream if they were created from a stream
> this different implementation of the above contructors results in
> significant difference as the stream should be closed while the bitmap uses
> it, otherwise the bitmap cannot be rendered.
>
> BitmapFromImage is not needed for this constructor and is not recommended in
> MakeTransparent.
>
> And not that using Dispose (that calls GC.SuppressFinalize) in
> BitmapFromImage result in memory leak as the new image will never be
> disposed.
In general, it is better to say:
using (Graphics g = ...) {
}
Which will emit the code
Graphics g = ...
try {
...
} finally {
if (g != null)
g.Dispose ();
}
Than to just do:
Grahics g = ...
...
g.Dispose ();
-- Ben
More information about the Mono-devel-list
mailing list