DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2606
Version: 1.3-current


If using a negative line data size to flip a image alpha blending on X11
didn't use the line data size and this would cause reading outside of the
allocated data. I have attached a patch and the complete file that fixes
this problem.


Link: http://www.fltk.org/str.php?L2606
Version: 1.3-current
Index: src/Fl_Image.cxx
===================================================================
--- src/Fl_Image.cxx    (revision 8592)
+++ src/Fl_Image.cxx    (working copy)
@@ -378,13 +378,18 @@
 #if !defined(WIN32) && !defined(__APPLE_QUARTZ__)
 // Composite an image with alpha on systems that don't have accelerated
 // alpha compositing...
-static void alpha_blend(Fl_RGB_Image *img, int X, int Y, int W, int H, int cx, 
int cy) {
+static void alpha_blend(Fl_RGB_Image *img, int X, int Y, int W, int H, int cx, 
int cy, int ld) {
   uchar *srcptr = (uchar*)img->array + img->d() * (img->w() * cy + cx);
+  if(ld != 0)
+    srcptr = (uchar*)img->array + ld*cy + cx*img->d();
   int srcskip = img->d() * (img->w() - W);
 
   uchar *dst = new uchar[W * H * 3];
   uchar *dstptr = dst;
 
+  if(ld < 0)
+    ld *= 2;
+
   fl_read_image(dst, X, Y, W, H, 0);
 
   uchar srcr, srcg, srcb, srca;
@@ -393,7 +398,7 @@
   if (img->d() == 2) {
     // Composite grayscale + alpha over RGB...
     // Composite RGBA over RGB...
-    for (int y = H; y > 0; y--, srcptr+=srcskip)
+    for (int y = H; y > 0; y--, srcptr+=srcskip) {
       for (int x = W; x > 0; x--) {
        srcg = *srcptr++;
        srca = *srcptr++;
@@ -407,9 +412,11 @@
        *dstptr++ = (srcg * srca + dstg * dsta) >> 8;
        *dstptr++ = (srcg * srca + dstb * dsta) >> 8;
       }
+      srcptr += ld;
+    }
   } else {
     // Composite RGBA over RGB...
-    for (int y = H; y > 0; y--, srcptr+=srcskip)
+    for (int y = H; y > 0; y--, srcptr+=srcskip) {
       for (int x = W; x > 0; x--) {
        srcr = *srcptr++;
        srcg = *srcptr++;
@@ -425,6 +432,8 @@
        *dstptr++ = (srcg * srca + dstg * dsta) >> 8;
        *dstptr++ = (srcb * srca + dstb * dsta) >> 8;
       }
+      srcptr += ld;
+    }
   }
 
   fl_draw_image(dst, X, Y, W, H, 3, 0);
@@ -569,7 +578,7 @@
     }
   } else {
     // Composite image with alpha manually each time...
-    alpha_blend(img, X, Y, W, H, cx, cy);
+    alpha_blend(img, X, Y, W, H, cx, cy, img->ld());
   }
 }
 
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs

Reply via email to