]> granicus.if.org Git - graphviz/commitdiff
fix for gd jpg imageloader inventing transparency when ther is none
authorJohn Ellson <ellson@research.att.com>
Thu, 16 Jan 2014 17:07:47 +0000 (12:07 -0500)
committerJohn Ellson <ellson@research.att.com>
Thu, 16 Jan 2014 17:07:47 +0000 (12:07 -0500)
plugin/gd/gvloadimage_gd.c

index fd7b067afa0e8b38ae511429878ccc76ea745cf5..05f2a8588b65111b07fa28601c900cfb091a14db 100644 (file)
@@ -146,13 +146,26 @@ static void gd_loadimage_cairo(GVJ_t * job, usershape_t *us, boxf b, boolean fil
                                                        width, height, stride);
 
        if (im->trueColor) {
-           for (y = 0; y < height; y++) {
-               for (x = 0; x < width; x++) {
-                   px = gdImageTrueColorPixel(im, x, y);
-                   *data++ = gdTrueColorGetBlue(px);
-                   *data++ = gdTrueColorGetGreen(px);
-                   *data++ = gdTrueColorGetRed(px);
-                   *data++ = (0x7F-gdTrueColorGetAlpha(px)) << 1;
+           if (im->saveAlphaFlag) {
+               for (y = 0; y < height; y++) {
+                   for (x = 0; x < width; x++) {
+                       px = gdImageTrueColorPixel(im, x, y);
+                       *data++ = gdTrueColorGetBlue(px);
+                       *data++ = gdTrueColorGetGreen(px);
+                       *data++ = gdTrueColorGetRed(px);
+                       *data++ = (0x7F-gdTrueColorGetAlpha(px)) << 1;
+                   }
+               }
+           }
+           else {
+               for (y = 0; y < height; y++) {
+                   for (x = 0; x < width; x++) {
+                       px = gdImageTrueColorPixel(im, x, y);
+                       *data++ = gdTrueColorGetBlue(px);
+                       *data++ = gdTrueColorGetGreen(px);
+                       *data++ = gdTrueColorGetRed(px);
+                       *data++ = 0xFF;
+                   }
                }
            }
        }