[NTG-pdftex] open problems with 1.20a

Hartmut Henkel hartmut_henkel@gmx.de
Fri, 2 Jul 2004 02:09:43 +0200 (CEST)


> > http://www.ndh.net/home/mauz/majox.de/newsgroup/compile-ablauf.png

writepng.c patch was wrong, corrected below, sorry.

Regards, Hartmut


--- writepng.c.orig	Mon Jul  1 18:07:00 2002
+++ writepng.c	Fri Jul  2 01:58:59 2004
@@ -67,9 +67,9 @@

 void write_png(integer img)
 {
-    int i, j;
+    int i, j, k, l;
     integer palette_objnum = 0;
-    png_bytep row, *rows;
+    png_bytep row, r, *rows;
     pdf_puts("/Type /XObject\n/Subtype /Image\n");
     pdf_printf("/Width %i\n/Height %i\n/BitsPerComponent %i\n",
                (int)png_info(img)->width,
@@ -100,9 +100,15 @@
         row = xtalloc(png_info(img)->rowbytes, png_byte);
         for (i = 0; i < (int)png_info(img)->height; i++) {
             png_read_row(png_ptr(img), row, NULL);
-            pdfroom(png_info(img)->rowbytes);
-            for (j = 0; j < (int)png_info(img)->rowbytes; j++)
-                pdfbuf[pdfptr++] = row[j];
+	    r = row;
+	    k = png_info(img)->rowbytes;
+	    while(k > 0) {
+		l = (k > pdfbufsize)? pdfbufsize : k;
+		pdfroom(l);
+		for (j = 0; j < l; j++)
+		    pdfbuf[pdfptr++] = *r++;
+		k -= l;
+	    }
         }
         xfree(row);
     }
@@ -115,9 +121,14 @@
         png_read_image(png_ptr(img), rows);
         for (i = 0; i < (int)png_info(img)->height; i++) {
             row = rows[i];
-            pdfroom(png_info(img)->rowbytes);
-            for (j = 0; j < (int)png_info(img)->rowbytes; j++)
-                pdfbuf[pdfptr++] = *row++;
+	    k = png_info(img)->rowbytes;
+	    while(k > 0) {
+		l = (k > pdfbufsize)? pdfbufsize : k;
+		pdfroom(l);
+		for (j = 0; j < l; j++)
+		    pdfbuf[pdfptr++] = *row++;
+		k -= l;
+	    }
             xfree(rows[i]);
         }
         xfree(rows);