LispWorks CAPI User Guide > 12 Graphics Ports > 12.8 Working with images

NextPrevUpTopContentsIndex

12.8.8 Creating external images from Graphics Ports operations

To create an external-image object from an on-screen window, use with-pixmap-graphics-port as in this example:

(defun record-picture (output-pane)
  (gp:with-pixmap-graphics-port
      (port output-pane
            400 400
            :clear t
            :background :red)
    (gp:draw-rectangle port 0 0 200 200
                       :filled t
                       :foreground :blue)
    (let ((image (gp:make-image-from-port port)))
      (gp:externalize-image port image))))

Here output-pane must be a displayed instance of capi:output-pane (or a subclass). The code does not affect the displayed pane.

If you do not already display a suitable output pane, you can create an invisible one like this:

(defun record-picture-1 ()
  (let* ((pl (make-instance 'capi:pinboard-layout))
         (win (capi:display
               (make-instance 'capi:interface
                              :display-state :hidden
                              :layout pl))))
    (prog1 (record-picture pl)
      (capi:destroy win))))

Note: There is no reason to create and destroy the invisible interface each time a new picture is recorded, so for efficiency you could cache the interface object and use it repeatedly.


LispWorks CAPI User Guide (Windows version) - 22 Dec 2009

NextPrevUpTopContentsIndex