Author: manolo
Date: 2012-09-29 12:42:35 -0700 (Sat, 29 Sep 2012)
New Revision: 9690
Log:
Fixed error when bit mask width is not a multiple of 8.

Modified:
   branches/branch-3.0/src/fltk3/ShapedWindow.cxx

Modified: branches/branch-3.0/src/fltk3/ShapedWindow.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/ShapedWindow.cxx      2012-09-29 14:39:41 UTC 
(rev 9689)
+++ branches/branch-3.0/src/fltk3/ShapedWindow.cxx      2012-09-29 19:42:35 UTC 
(rev 9690)
@@ -207,13 +207,14 @@
       }
     // reverse mask bits and also perform bitwise inversion of all bytes
     char *p = (char*)temp->data()[0];
-    char *q = p + (lw*lh)/8;
+    int bytes_per_row = (lw + 7)/8;
+    char *q = p + bytes_per_row * lh;
     while (p < q) {
       *p = swap_byte(~*p);
       p++;
       }
-    CGDataProviderRef provider = CGDataProviderCreateWithData(temp, 
temp->data()[0], (lw*lh)/8, MyProviderReleaseData);
-    mask = CGImageMaskCreate(lw, lh, 1, 1, lw/8, provider, NULL, false);
+    CGDataProviderRef provider = CGDataProviderCreateWithData(temp, 
temp->data()[0], bytes_per_row * lh, MyProviderReleaseData);
+    mask = CGImageMaskCreate(lw, lh, 1, 1, bytes_per_row, provider, NULL, 
false);
 #else 
     // any other window managers that FLTK3 supports will be added here
 #endif

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to