]> granicus.if.org Git - graphviz/commitdiff
webp - fix missing lib, and some ugly color swapping
authorJohn Ellson <ellson@research.att.com>
Thu, 19 Jan 2012 18:52:50 +0000 (13:52 -0500)
committerJohn Ellson <ellson@research.att.com>
Thu, 19 Jan 2012 18:52:50 +0000 (13:52 -0500)
plugin/webp/Makefile.am
plugin/webp/gvdevice_webp.c
plugin/webp/gvloadimage_webp.c

index 6c535ca0550fcd66adfce25bfa95feafd73e0a4e..6a2858c4090f5e17699292121ce8ca074f93581f 100644 (file)
@@ -32,7 +32,7 @@ libgvplugin_webp_C_la_SOURCES = \
 
 libgvplugin_webp_la_LDFLAGS = -version-info @GVPLUGIN_VERSION_INFO@
 libgvplugin_webp_la_SOURCES = $(libgvplugin_webp_C_la_SOURCES)
-libgvplugin_webp_la_LIBADD = @WEBP_LIBS@
+libgvplugin_webp_la_LIBADD = @WEBP_LIBS@ @PANGOCAIRO_LIBS@
 
 if WITH_WIN32
 libgvplugin_webp_la_LDFLAGS += -no-undefined
index ff8ef0943cc809d5b87dedbdd4fa59f909342125..7564c9cf1113a65ace493ba4b886b6befe461bdd 100644 (file)
@@ -111,7 +111,7 @@ static void webp_format(GVJ_t * job)
        return;
     }
 
-    if (!WebPPictureImportRGBA(&picture,
+    if (!WebPPictureImportBGRA(&picture,
                (const uint8_t * const)job->imagedata, stride)) {
        fprintf(stderr, "Error! Cannot import picture\n");
        goto Error;
index 3c05fb15b5c28f6a9d8889d387a6520749ed686d..cb4206678bdad640607955c6c9c4bc875b3b5660 100644 (file)
@@ -16,6 +16,7 @@
 #endif
 
 #include <stdlib.h>
+#include <string.h>
 
 #include "gvplugin_loadimage.h"
 #include "gvio.h"
@@ -86,6 +87,22 @@ static cairo_surface_t* webp_really_loadimage(const char *in_file, FILE* const i
     output_buffer->colorspace = MODE_RGBA;
     status = WebPDecode((const uint8_t*)data, data_size, &config);
 
+    /* FIXME - this is ugly */
+    if (! bitstream->has_alpha) {
+       int x, y;
+       unsigned char *p, t;
+
+       for (y = 0; y < output_buffer->height; y++) {
+           p = output_buffer->u.RGBA.rgba + (output_buffer->u.RGBA.stride * y);
+           for (x = 0; x < output_buffer->width; x++) {
+               t = p[0];     /* swap red/blue */
+               p[0] = p[2];
+               p[2] = t;
+               p += 4;
+           }
+       }
+    }
+
 end:
     free(data);
     ok = (status == VP8_STATUS_OK);
@@ -95,23 +112,12 @@ end:
        return NULL;
     }
 
-#if 0
-    fprintf(stderr, "Info: WebP file %s can be decoded (dimensions: %d x %d)%s.\n",
-       in_file, output_buffer->width, output_buffer->height,
-       bitstream->has_alpha ? " (with alpha)" : "");
-#endif
-
-#if 1
-
-    // FIXME - this statement dies....    but works in dot_static!!!
-    
     surface = cairo_image_surface_create_for_data (
            output_buffer->u.RGBA.rgba,
            CAIRO_FORMAT_ARGB32,
            output_buffer->width,
            output_buffer->height,
            output_buffer->u.RGBA.stride);
-#endif
 
     return surface;
 }