2006-06-14 Gonzalo Paniagua Javier <gonzalo@ximian.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Wed, 14 Jun 2006 17:57:02 +0000 (17:57 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Wed, 14 Jun 2006 17:57:02 +0000 (17:57 -0000)
* ImageListStreamer.cs: correctly generate the 1bpp mask for images
whose width is not a multiple of 8.

svn path=/trunk/mcs/; revision=61710

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageListStreamer.cs

index ac16cdf92ef773899e3e5593ed265b9a25d498ef..d964350c77493fc9040941ffa960cc5689a4c6d4 100644 (file)
@@ -1,3 +1,8 @@
+2006-06-14 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * ImageListStreamer.cs: correctly generate the 1bpp mask for images
+       whose width is not a multiple of 8.
+
 2006-06-13  Jackson Harper  <jackson@ximian.com>
 
        * MdiClient.cs:  Only maximize the next child if the current one
index d62bbaa1a1e9399c3278e20f5a8d6b93dd30ad34..48ba0ad41aae7edb0c49c1d397e494b11aa975df 100644 (file)
@@ -208,28 +208,53 @@ namespace System.Windows.Forms {
                        int h = images [0].Height;
                        byte *scan = (byte *) dresult.Scan0.ToPointer ();
                        int stride = dresult.Stride;
+                       Bitmap current = null;
                        for (int idx = 0; idx < images.Length; idx++) {
-                               Bitmap current = (Bitmap) images [idx];
+                               current = (Bitmap) images [idx];
                                // Hack for newly added images.
                                // Probably has to be done somewhere else.
                                Color c1 = current.GetPixel (0, 0);
                                if (c1.A != 0 && c1 == back_color)
                                        current.MakeTransparent (back_color);
                                //
-                               int basey = (idx / 4) * h;
-                               int basex = (idx % 4) * w;
-                               for (int y = 0; y < h; y++) {
-                                       int yidx = (y + basey) * stride;
-                                       for (int x = 0; x < w; x++) {
-                                               Color color = current.GetPixel (x, y);
-                                               if (color.A == 0) {
-                                                       int ptridx = yidx + ((x + basex) >> 3);
-                                                       scan [ptridx] |= (byte) (0x80 >> (x & 7));
-                                               }
+                       }
+
+                       int yidx = 0;
+                       int imgidx = 0;
+                       int localy = 0;
+                       int localx = 0;
+                       int factor_y = 0;
+                       int factor_x = 0;
+                       for (int y = 0; y < main.Height; y++) {
+                               if (localy == h) {
+                                       localy = 0;
+                                       factor_y += 4;
+                               }
+                               factor_x = 0;
+                               localx = 0;
+                               for (int x = 0; x < main.Width; x++) {
+                                       if (localx == w) {
+                                               localx = 0;
+                                               factor_x++;
+                                       }
+                                       imgidx = factor_y + factor_x;
+                                       if (imgidx >= images.Length)
+                                               break;
+                                       current = (Bitmap) images [imgidx];
+                                       Color color = current.GetPixel (localx, localy);
+                                       if (color.A == 0) {
+                                               int ptridx = yidx + (x >> 3);
+                                               scan [ptridx] |= (byte) (0x80 >> (x & 7));
                                        }
+                                       localx++;
                                }
+                               if (imgidx >= images.Length)
+                                       break;
+                               yidx += stride;
+                               localy++;
                        }
                        result.UnlockBits (dresult);
+
                        return result;
                }