]> granicus.if.org Git - graphviz/commitdiff
Allow large rasters in Postscript output (by breaking the data
authornorth <devnull@localhost>
Fri, 8 Dec 2006 21:17:49 +0000 (21:17 +0000)
committernorth <devnull@localhost>
Fri, 8 Dec 2006 21:17:49 +0000 (21:17 +0000)
into chunks that are fed to colorimage through a procedure.)

plugin/gd/gvloadimage_gd.c
plugin/pango/gvloadimage_pango.c

index be376dc3c85887beb5444f8c51057a24eb318cd0..a1cf56a273ed3db98529f8c02e32108916796d9c 100644 (file)
@@ -136,20 +136,14 @@ static void gd_loadimage_ps(GVJ_t * job, usershape_t *us, boxf b, boolean filled
        X = im->sx;
        Y = im->sy;
 
-        fprintf(out, "gsave\n");
+        fprintf(out, "save\n");
 
-        /* this sets the position of the image */
-        fprintf(out, "%g %g translate %% lower-left coordinate\n", b.LL.x, b.LL.y);
-    
-        /* this sets the rendered size to fit the box */
-        fprintf(out,"%g %g scale\n", b.UR.x - b.LL.x, b.UR.y - b.LL.y);
-    
-        /* xsize ysize bits-per-sample [matrix] */
-        fprintf(out, "%d %d 8 [%d 0 0 %d 0 %d]\n", X, Y, X, -Y, Y);
-    
-        fprintf(out, "{<\n");
+       /* define image data as string array (one per raster line) */
+        fprintf(out, "/myctr 0 def\n");
+        fprintf(out, "/myarray [\n");
         if (im->trueColor) {
             for (y = 0; y < Y; y++) {
+               fprintf(out, "<");
                 for (x = 0; x < X; x++) {
                     px = gdImageTrueColorPixel(im, x, y);
                     fprintf(out, "%02x%02x%02x",
@@ -157,11 +151,12 @@ static void gd_loadimage_ps(GVJ_t * job, usershape_t *us, boxf b, boolean filled
                         gdTrueColorGetGreen(px),
                         gdTrueColorGetBlue(px));
                 }
+               fprintf(out, ">\n");
             }
-            fprintf(out, "\n");
        }
         else {
             for (y = 0; y < Y; y++) {
+               fprintf(out, "<");
                 for (x = 0; x < X; x++) {
                     px = gdImagePalettePixel(im, x, y);
                     fprintf(out, "%02x%02x%02x",
@@ -169,14 +164,24 @@ static void gd_loadimage_ps(GVJ_t * job, usershape_t *us, boxf b, boolean filled
                         im->green[px],
                         im->blue[px]);
                 }
+               fprintf(out, ">\n");
             }
-            fprintf(out, "\n");
         }
+       fprintf(out, "] def\n");
+       fprintf(out,"/myproc { myarray myctr get /myctr myctr 1 add def } def\n");
+
+        /* this sets the position of the image */
+        fprintf(out, "%g %g translate %% lower-left coordinate\n", b.LL.x, b.LL.y);
+
+        /* this sets the rendered size to fit the box */
+        fprintf(out,"%g %g scale\n", b.UR.x - b.LL.x, b.UR.y - b.LL.y);
+    
+        /* xsize ysize bits-per-sample [matrix] */
+        fprintf(out, "%d %d 8 [%d 0 0 %d 0 %d]\n", X, Y, X, -Y, Y);
     
-        fprintf(out, ">}\n");
-        fprintf(out, "false 3 colorimage\n");
+        fprintf(out, "{myproc} false 3 colorimage\n");
     
-        fprintf(out, "grestore\n");
+        fprintf(out, "restore\n");
     }
 }
 
index 1469c87adc6face684bea826357fc544fc35adfe..60aa2af442164040f3cb1d8d51661882c735fc68 100644 (file)
@@ -111,20 +111,14 @@ static void pango_loadimage_ps(GVJ_t * job, usershape_t *us, boxf b, boolean fil
        stride = cairo_image_surface_get_stride(surface);
        data = cairo_image_surface_get_data(surface);
 
-        fprintf(out, "gsave\n");
-
-        /* this sets the position of the image */
-        fprintf(out, "%g %g translate %% lower-left coordinate\n", b.LL.x, b.LL.y);
-
-        /* this sets the rendered size to fit the box */
-        fprintf(out,"%g %g scale\n", b.UR.x - b.LL.x, b.UR.y - b.LL.y);
-
-        /* xsize ysize bits-per-sample [matrix] */
-        fprintf(out, "%d %d 8 [%d 0 0 %d 0 %d]\n", X, Y, X, -Y, Y);
-
-        fprintf(out, "{<\n");
+        fprintf(out, "save\n");
 
+       /* define image data as string array (one per raster line) */
+       /* see parallel code in gd_loadimage_ps().  FIXME: refactor... */
+        fprintf(out, "/myctr 0 def\n");
+        fprintf(out, "/myarray [\n");
         for (y = 0; y < Y; y++) {
+           fprintf(out, "<");
            ix = data + y * stride;
             for (x = 0; x < X; x++) {
                /* FIXME - this code may have endian problems */
@@ -134,13 +128,23 @@ static void pango_loadimage_ps(GVJ_t * job, usershape_t *us, boxf b, boolean fil
                alpha = *ix++;
                 fprintf(out, "%02x%02x%02x", red, green, blue);
             }
-            fprintf(out, "\n");
+           fprintf(out, ">\n");
         }
+       fprintf(out, "] def\n");
+        fprintf(out,"/myproc { myarray myctr get /myctr myctr 1 add def } def\n");
+
+        /* this sets the position of the image */
+        fprintf(out, "%g %g translate %% lower-left coordinate\n", b.LL.x, b.LL.y);
+
+        /* this sets the rendered size to fit the box */
+        fprintf(out,"%g %g scale\n", b.UR.x - b.LL.x, b.UR.y - b.LL.y);
+
+        /* xsize ysize bits-per-sample [matrix] */
+        fprintf(out, "%d %d 8 [%d 0 0 %d 0 %d]\n", X, Y, X, -Y, Y);
 
-        fprintf(out, ">}\n");
-        fprintf(out, "false 3 colorimage\n");
+        fprintf(out, "{myproc} false 3 colorimage\n");
 
-        fprintf(out, "grestore\n");
+        fprintf(out, "restore\n");
     }
 }