[cl-pdf-devel] cl-pdf image question

Cyrus Harmon ch-lisp at bobobeach.com
Wed May 9 16:39:42 UTC 2007


On May 9, 2007, at 12:15 AM, Marc Battyani wrote:
> What you do seems OK and it works when the image is converted to  
> jpg. So there is probably a problem with the png reading.
> Indeed (pdf::read-png-file "circles.png") gives a png-image with 4  
> bytes.

Duh. Should have checked that I guess. Looks like we were only saving  
the last chunk. The following patch fixes things.

Thanks again,

Cyrus

Index: png.lisp
===================================================================
--- png.lisp	(revision 139)
+++ png.lisp	(working copy)
@@ -101,8 +101,15 @@
                                 (let ((position (position 0 trns)))
                                   (when position (list position))))))))
                ((string= marker "IDAT")				; image data block
-               (setq data (make-array octet-length :element-type  
'(unsigned-byte 8)))
-               (read-sequence data stream))
+               (let ((start 0))
+                 (if (null data)
+                     (setf data (make-array octet-length
+                                            :element-type '(unsigned- 
byte 8)
+                                            :adjustable t))
+                     (progn
+                       (setf start (first (array-dimensions data)))
+                       (adjust-array data (+ start octet-length))))
+                 (read-sequence data stream :start start)))
                ((string= marker "IEND")
                 (return))
                (t		;"pHYs"




More information about the cl-pdf-devel mailing list