[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: srcPtr of a window?



On Wed, 10 Aug, Tom McDougal asks:
  Simple question, I hope.  How do I get (or calculate) the srcPtr of a
  black-and-white window?  (e.g. if I want to do a copy-bits from the screen
  to an off-screen bitmap)


There is some contributed code (available by anonymous ftp from cam
cambridge.apple.com) in the file /pub/MCL2/contrib/menu-enhancements.sit.hqx.
The file is a binhex of an archive file. One particular file contains
code that will do what you want. The code supports marking menus and allows
the programmer to save a portion of the screen image, write on the screen
and then restore the screen image.

The following code is an example that uses the file oout-utils.lisp to
fill the entire screen with a grey pattern, create a window, display a portion
of the original screen, and then restore the screen.  The code was 
developed with help from Bill St. Clair.

mark

;;  first define menu package and then use it
(unless (find-package :menu-enhancements)
  (defpackage :menu-enhancements
  (:use :common-lisp :ccl)
  (:nicknames :menus)))
(in-package :menus)
;;  load the oou-utils.lisp file
(load (choose-file-dialog))             ; select the oou-utils file

(defun test-screen-saver (topLeft bottomRight)
  (rlet ((r :rect :topLeft topLeft :bottomRight bottomRight))
    
    (let ((win (make-instance 'window 
                 :view-size #@(450 450)
                 :view-position :centered)))
      (with-saved-screen-map (win r :saved-picture saved-picture) ; so we can 
use the saved-picture
        (window-select win)
        (with-wmgr-view 
          (#_fillRect :ptr r :ptr *light-gray-pattern*))
        (with-port (wptr win)
          (#_drawPicture :ptr saved-picture :ptr r)    ; draw the saved pixel 
map
          (sleep 1))
        (print-record saved-picture :picture))
      (sleep 1)                         ; show the restored portion of the 
screen
      (window-close win))))

(let ((screen-rect (rref (get-wmgrport) :grafport.portRect)))
  (test-screen-saver (rref screen-rect :rect.topLeft)
                     (rref screen-rect :rect.bottomRight)))

Here's the output:
#<Record :PICTURE 
          :PICSIZE 7815 
         :PICFRAME #<Record :RECT :TOP 0 :LEFT 0 :BOTTOM 480 :RIGHT 640>>