[cl-pdf-devel] Small improvement: pdf:make-image method on pathname

Dmitriy Ivanov divanov at aha.ru
Fri Apr 29 11:13:32 UTC 2005


Hello folks,

I would suggest the small change on the subject (see pdf-base.lisp).
It can help in the situation where the same sampled image is about to be
placed into several pdf-files and the image file type is not known in
advance. To avoid an extra load, the original
    (defmethod make-image ((object pathname) ...) ...)
is divided into the following two primitives:

(defun read-bitmap-image-file (pathname
                &optional (type (pathname-type pathname)))
  (cond ((member type '("jpeg" "jpg") :test #'equalp)
         (read-jpeg-file pathname))
        ((equalp type "png")
         (read-png-file pathname))
        (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) args))
--
Sincerely,
Dmitriy Ivanov
lisp.ystok.ru




More information about the cl-pdf-devel mailing list