Author: kostat
Date: 2005-12-13 09:55:34 -0500 (Tue, 13 Dec 2005)
New Revision: 54295

Modified:
   branches/mainsoft/gh1.7/mcs/class/System.Drawing/System.Drawing/Bitmap.jvm.cs
   branches/mainsoft/gh1.7/mcs/class/System.Drawing/System.Drawing/ChangeLog
Log:
merge -r 54293:54294

Modified: 
branches/mainsoft/gh1.7/mcs/class/System.Drawing/System.Drawing/Bitmap.jvm.cs
===================================================================
--- 
branches/mainsoft/gh1.7/mcs/class/System.Drawing/System.Drawing/Bitmap.jvm.cs   
    2005-12-13 14:52:08 UTC (rev 54294)
+++ 
branches/mainsoft/gh1.7/mcs/class/System.Drawing/System.Drawing/Bitmap.jvm.cs   
    2005-12-13 14:55:34 UTC (rev 54295)
@@ -249,18 +249,18 @@
                
                public Bitmap Clone (RectangleF rect, PixelFormat pixFormat)
                {
-                       PlainImage plainImage = CurrentImage.Clone(false);
-                       BufferedImage clone = new BufferedImage( 
(int)rect.Width, (int)rect.Height, ToBufferedImageFormat( pixFormat ) );
-                       awt.Graphics2D g = clone.createGraphics();
-                       try {
-                               g.drawImage( NativeObject, -(int)rect.X, 
-(int)rect.Y, null );
-                       }
-                       finally {
-                               g.dispose();
-                       }
-
-                       plainImage.NativeImage = clone;
-                       return new Bitmap(plainImage);
+                       PlainImage plainImage = CurrentImage.Clone(false);
+                       BufferedImage clone = new BufferedImage( 
(int)rect.Width, (int)rect.Height, ToBufferedImageFormat( pixFormat ) );
+                       awt.Graphics2D g = clone.createGraphics();
+                       try {
+                               g.drawImage( NativeObject, -(int)rect.X, 
-(int)rect.Y, null );
+                       }
+                       finally {
+                               g.dispose();
+                       }
+
+                       plainImage.NativeImage = clone;
+                       return new Bitmap(plainImage);
                }
                #endregion
 
@@ -274,15 +274,17 @@
                #region MakeTransparent
                public void MakeTransparent ()
                {
-                       Color clr = GetPixel(0,0);                      
+                       Color clr = Color.FromArgb(0,0,0);                      
                        MakeTransparent (clr);
                }
 
                public void MakeTransparent (Color transparentColor)
                {
-                       byte A = transparentColor.A;
                        image.WritableRaster raster = NativeObject.getRaster();
                        int numBands  = raster.getNumBands();
+                       if (numBands != 4)
+                               return;
+
                        int maxWidth  = raster.getWidth() + raster.getMinX();
                        int maxHeight = raster.getHeight() + raster.getMinY();
                        int[] srcPix  = new int[numBands];
@@ -290,12 +292,11 @@
                        for (int y = raster.getMinY(); y < maxHeight; y++) {
                                for (int x = raster.getMinX(); x < maxWidth; 
x++) {
                                        /*srcPix =*/ raster.getPixel(x, y, 
srcPix);
-                                       for (int z = 0; z < numBands; z++) {
-                                               int argb = srcPix[z];
-                                               if ((uint)argb >> 24 == A) {
-                                                       argb &= 0x00FFFFFF;
-                                                       srcPix[z] = argb;
-                                               }
+                                       if (srcPix[0] == transparentColor.R &&
+                                               srcPix[1] == transparentColor.G 
&&
+                                               srcPix[2] == 
transparentColor.B) {
+                                               srcPix[3] = 0;
+                                               raster.setPixel(x, y, srcPix);
                                        }
                                }
                        }

Modified: 
branches/mainsoft/gh1.7/mcs/class/System.Drawing/System.Drawing/ChangeLog
===================================================================
--- branches/mainsoft/gh1.7/mcs/class/System.Drawing/System.Drawing/ChangeLog   
2005-12-13 14:52:08 UTC (rev 54294)
+++ branches/mainsoft/gh1.7/mcs/class/System.Drawing/System.Drawing/ChangeLog   
2005-12-13 14:55:34 UTC (rev 54295)
@@ -1,3 +1,7 @@
+2005-12-13  Konstantin Triger <[EMAIL PROTECTED]>
+
+       * Bitmap.jvm.cs: Fix MakeTransparent.
+
 2005-11-28 Konstantin Triger <[EMAIL PROTECTED]>
 
         * SystemIcons.jvm.cs: refactoring.

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to