[winforms] Style
authorRalph Leckett <rleckett@gmail.com>
Sat, 11 Dec 2010 03:45:52 +0000 (22:45 -0500)
committerMiguel de Icaza <miguel@gnome.org>
Sat, 11 Dec 2010 03:45:52 +0000 (22:45 -0500)
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageList.cs

index 544595d21ddb135ace95f848d461019d68581eb7..e9d7a6426bcf1f2ab4eafff6427a73219229c414 100644 (file)
@@ -567,26 +567,23 @@ namespace System.Windows.Forms
                        {
                                int imageWidth;
                                int imageHeight;
-                               Bitmap bitmap;
-                               Graphics graphics;
                                ImageAttributes imageAttributes;
 
                                if (transparentColor.A == 0)
                                        imageAttributes = null;
                                else {
                                        imageAttributes = new ImageAttributes();
-                                       imageAttributes.SetColorKey(transparentColor, transparentColor);
+                                       imageAttributes.SetColorKey (transparentColor, transparentColor);
                                }
 
-                               bitmap = new Bitmap(imageWidth = this.imageSize.Width, imageHeight = this.imageSize.Height, PixelFormat.Format32bppArgb);
-                               graphics = Graphics.FromImage(bitmap);
-                               graphics.DrawImage(value, new Rectangle(0, 0, imageWidth, imageHeight), 0, 0, value.Width, value.Height, GraphicsUnit.Pixel, imageAttributes);
-                               graphics.Dispose();
+                               var bitmap = new Bitmap (imageWidth = this.imageSize.Width, imageHeight = this.imageSize.Height, PixelFormat.Format32bppArgb);
+                               using (var graphics = Graphics.FromImage (bitmap))
+                                       graphics.DrawImage (value, new Rectangle(0, 0, imageWidth, imageHeight), 0, 0, value.Width, value.Height, GraphicsUnit.Pixel, imageAttributes);
 
                                if (imageAttributes != null)
-                                       imageAttributes.Dispose();
+                                       imageAttributes.Dispose ();
 
-                               ReduceColorDepth(bitmap);
+                               ReduceColorDepth (bitmap);
                                return bitmap;
                        }