Author: spouliot
Date: 2006-07-05 08:38:37 -0400 (Wed, 05 Jul 2006)
New Revision: 62263
Modified:
trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog
trunk/mcs/class/System.Drawing/System.Drawing/Image.cs
Log:
Image.cs: Made GetThumbnailImage throw OutOfMemoryException when image size is
invalid (to match MS behaviour), also ensure that the Graphics instance is
disposed even if CheckStatus throws an exception.
Modified: trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog
===================================================================
--- trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog 2006-07-05
12:34:42 UTC (rev 62262)
+++ trunk/mcs/class/System.Drawing/System.Drawing/ChangeLog 2006-07-05
12:38:37 UTC (rev 62263)
@@ -1,3 +1,9 @@
+2006-07-04 Sebastien Pouliot <[EMAIL PROTECTED]>
+
+ * Image.cs: Made GetThumbnailImage throw OutOfMemoryException when
+ image size is invalid (to match MS behaviour), also ensure that the
+ Graphics instance is disposed even if CheckStatus throws an exception.
+
2006-06-26 Sebastien Pouliot <[EMAIL PROTECTED]>
* Pen.cs: Ensure we dispose of an existing brush before replacing it.
Modified: trunk/mcs/class/System.Drawing/System.Drawing/Image.cs
===================================================================
--- trunk/mcs/class/System.Drawing/System.Drawing/Image.cs 2006-07-05
12:34:42 UTC (rev 62262)
+++ trunk/mcs/class/System.Drawing/System.Drawing/Image.cs 2006-07-05
12:38:37 UTC (rev 62263)
@@ -339,23 +339,23 @@
return item;
}
- public Image GetThumbnailImage(int thumbWidth, int thumbHeight,
Image.GetThumbnailImageAbort callback, IntPtr callbackData)
+ public Image GetThumbnailImage (int thumbWidth, int thumbHeight,
Image.GetThumbnailImageAbort callback, IntPtr callbackData)
{
- Status status;
- Image ThumbNail;
- Graphics g;
+ if ((thumbWidth <= 0) || (thumbHeight <= 0))
+ throw new OutOfMemoryException ("Invalid thumbnail
size");
- ThumbNail=new Bitmap(thumbWidth, thumbHeight);
- g=Graphics.FromImage(ThumbNail);
-
- status = GDIPlus.GdipDrawImageRectRectI(g.nativeObject,
nativeObject,
- 0, 0, thumbWidth, thumbHeight,
- 0, 0, this.Width, this.Height,
- GraphicsUnit.Pixel, IntPtr.Zero, null,
IntPtr.Zero);
- GDIPlus.CheckStatus (status);
- g.Dispose();
+ Image ThumbNail = new Bitmap (thumbWidth, thumbHeight);
- return(ThumbNail);
+ using (Graphics g = Graphics.FromImage (ThumbNail)) {
+ Status status = GDIPlus.GdipDrawImageRectRectI
(g.nativeObject, nativeObject,
+ 0, 0, thumbWidth, thumbHeight,
+ 0, 0, this.Width, this.Height,
+ GraphicsUnit.Pixel, IntPtr.Zero, null,
IntPtr.Zero);
+
+ GDIPlus.CheckStatus (status);
+ }
+
+ return ThumbNail;
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches