[cl-typesetting-devel] Fwd: make-image vs. make-jpeg-image incl-typesetting

Dmitriy Ivanov divanov at aha.ru
Tue Jun 9 07:48:45 UTC 2009


Cyrus Harmon wrote on Mon, 8 Jun 2009 22:29:49 -0700 09:29:

| This change doesn't seem to have hit the repo. Any interest in adding
| this on the part of the maintainers?
|
| Begin forwarded message:
|
| In graphics.lisp/stroke there's a call to pdf:make-jpeg-image that could
| just as easily
| (and better yet) be call to pdf::make-image, which unfortunately isn't
| exported. This
| would allow me to embed PNGs in my pdfs. Any chance of seeing this
| changed to make-image and exporting make-image from cl-pdf?

I use the following "versions of my own". In cl-pdf/pdf-base.lisp:

(defun read-bitmap-image-file (pathname &key (type (pathname-type pathname))
                                                   header-only)
  (cond ((member type '("jpeg" "jpg") :test #'equalp)
         (read-jpeg-file pathname))
        ((equalp type "png")
         (read-png-file pathname :header-only header-only))
        (t (error "Unsupported image file type ~s." type))))

(defmethod make-image ((object pathname) &rest args
                               &key (type (pathname-type object)))
  (apply 'make-image (read-bitmap-image-file object :type type) args))

In cl-typesetting/graphics.lisp:

(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)))

This staff has been waiting for "official approval" much longer :-)
--
Sincerely,
Dmitriy Ivanov
lisp.ystok.ru





More information about the cl-typesetting-devel mailing list