]> granicus.if.org Git - graphviz/commitdiff
turns out that web comes in different flavors - with different ways of encoding the...
authorJohn Ellson <ellson@research.att.com>
Thu, 12 Jan 2012 02:42:56 +0000 (21:42 -0500)
committerJohn Ellson <ellson@research.att.com>
Thu, 12 Jan 2012 02:42:56 +0000 (21:42 -0500)
lib/gvc/gvusershape.c
plugin/webp/gvloadimage_webp.c

index fd119a7165f22a4a9467745d6dabde22a94604cd..ab05d06af219266b2af4f07aad1bc151b8eef7d1 100644 (file)
@@ -211,7 +211,7 @@ static void svg_size (usershape_t *us)
                    break;
            }
            else if (strcmp(attribute,"viewBox") == 0
-            && sscanf(value, "%lf %lf %lf %lf", &x0,&y0,&x1,&y1) == 4) {
+             && sscanf(value, "%lf %lf %lf %lf", &x0,&y0,&x1,&y1) == 4) {
                w = x1 - x0 + 1;
                h = y1 - y0 + 1;
                wFlag = TRUE;
@@ -242,10 +242,20 @@ static void webp_size (usershape_t *us)
     unsigned int w, h;
 
     us->dpi = 0;
-    fseek(us->f, 26, SEEK_SET);
-    if (get_int_lsb_first(us->f, 2, &w) && get_int_lsb_first(us->f, 2, &h)) {
-        us->w = w;
-        us->h = h;
+    fseek(us->f, 15, SEEK_SET);
+    if (fgetc(us->f) == 'X') { //VP8X
+        fseek(us->f, 24, SEEK_SET);
+        if (get_int_lsb_first(us->f, 4, &w) && get_int_lsb_first(us->f, 4, &h)) {
+            us->w = w;
+            us->h = h;
+        }
+    }
+    else { //VP8
+        fseek(us->f, 26, SEEK_SET);
+        if (get_int_lsb_first(us->f, 2, &w) && get_int_lsb_first(us->f, 2, &h)) {
+            us->w = w;
+            us->h = h;
+        }
     }
 }
 
index 317bfdcb8294a9455a90e95e8d8841dd5b079f11..87992a1e5e09f5946a8c11a31f9f1530df2e4c22 100644 (file)
@@ -106,6 +106,7 @@ end:
     return surface;
 }
 
+/* get image either from cached surface, or from freskly loaded surface */
 static cairo_surface_t* webp_loadimage(GVJ_t * job, usershape_t *us)
 {
     cairo_surface_t *surface = NULL; /* source surface */
@@ -143,6 +144,7 @@ static cairo_surface_t* webp_loadimage(GVJ_t * job, usershape_t *us)
     return surface;
 }
 
+/* paint image into required location in graph */
 static void webp_loadimage_cairo(GVJ_t * job, usershape_t *us, boxf b, boolean filled)
 {
     cairo_t *cr = (cairo_t *) job->context; /* target context */