[cl-typesetting-devel] [cl-pdf-devel] PNG Support Patches

Dmitriy Ivanov divanov at aha.ru
Sun Feb 27 09:10:55 UTC 2011


Cyrus Harmon wrote on Sat, 26 Feb 2011 08:52:07 -0700 18:52:

| I seem to recall some discussion of this a few years back, and there is
| some support for PNG images in cl-pdf, but there is currently no way to
| embed a PNG document in a cl-typesetting document. The following
| patches provide support for PNG images in cl-typesetting. Any chance of
| seeing this (or similar code) accepted into the repository?

Thanks. I use a similar code in my "internal version":

(defclass image-box (soft-box)
  ((file :accessor file :initform nil :initarg :file)  ; pathname or
bitmap-image
   (pdf-image :accessor pdf-image :initarg :pdf-image :initform nil)))

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

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

I consider the class jpeg-box (and png-box offered) useless. Additionally,
the background-jpeg-box class could also be replaced with a more general
background-box.

Does anybody specialize on them?
--
Sincerely,
Dmitriy Ivanov
lisp.ystok.ru





More information about the cl-typesetting-devel mailing list