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

Re: difficulty with copy-bits



The copy-text method works for an ordinary grafport (black and white)
It creates a picture containing a shifted portion of the view bit map
 (The rectangle (:topleft #@(0 0) :bottomRight #@(160 35)))

This portion of the bit map is shifted down by 20 pixels #@(0 20)
 
(require 'traps)
(require 'records)
(require 'quickdraw)
(defmethod copy-text ((view window))
  (let ((wptr (wptr view)))
    (with-focused-view view
      (rlet ((view-rect :rect :topLeft #@(0 0)
                        :bottomRight (view-size view))
             (source-rect :rect
                          :topleft #@(0 0)
                          :bottomright #@(160 35))
             (dest-rect :rect
                        :topleft #@(0 20)
                        :bottomright #@(160 55)))  ;; changed from 20
        (let* ((pict (#_OpenPicture :ptr view-rect :ptr))
               (bits (rref wptr :window.portbits)))
          (#_CopyBits :ptr bits
           :ptr bits
           :ptr source-rect
           :ptr dest-rect
           :word 0        ;transfer mode
           :ptr (%null-ptr))
          (#_ClosePicture)
          pict)))))
#|
; Try executing this line with the window selected
(progn (setq my-pic (copy-text (first (windows))))
       (draw-picture (first (windows)) my-pic))
(kill-picture my-pic)
|#