[cl-typesetting-devel] extension/analog of IMAGE convenience fn for PNG files in lieu of JPG

Andrew Philpot philpot at ISI.EDU
Sun Jul 15 06:14:36 UTC 2007


I've tried just sticking PNG files, but the IMAGE fn pretty clearly
makes a JPG box, at least in my 0.8 CL-TYPESETTING.

I cloned the JPG code with the following, but it resulted in a broken
PDF (per acroread).

I already have an existing application which wants to use the IMAGE
routine as a primitive.  I see the PNG example, which delves a little
lower than this.  What am I missing?

Andrew

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(in-package :typeset)

(defclass png-box (soft-box)
  ((file :accessor file :initform nil :initarg :file)
   (pdf-png-obj :accessor pdf-png-obj :initform nil :initarg :pdf-png-obj)))

(defun png-image (&rest args &key inline &allow-other-keys)
  (if inline
      (add-box (apply 'make-instance 'png-box :allow-other-keys t args))
      (let ((hbox (make-instance 'hbox :boxes (list (make-hfill-glue)
						    (apply 'make-instance 'png-box :allow-other-keys t args)
						    (make-hfill-glue))
				 :adjustable-p t)))
	(compute-natural-box-size hbox)
	(add-box hbox))))

(defmethod stroke ((box png-box) x y)
  (unless (pdf-png-obj box)
    (setf (pdf-png-obj box) (pdf::make-png-image (pdf::read-png-file (file box)))))
  (pdf:add-images-to-page (pdf-png-obj box))
  (pdf:draw-image (pdf-png-obj box) x (+ (- y (dy box))(offset
  box))(dx box)(dy box) 0 t))

(in-package :pdf)

(defmethod make-png-image (png)
  (make-image png))



More information about the cl-typesetting-devel mailing list