[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bitmaps
- To: info-mcl@cambridge.apple.com
- Subject: bitmaps
- From: montbrj@herald.usask.ca
- Date: Thu, 27 Oct 1994 16:14:29 -0600
- Full-name: Majordomo Mailing List Server
- Sender: owner-info-mcl@cambridge.apple.com
Hi!
I have a whole bunch of BitMap routines I'm willing to make available
to the MCL bunch. They're compatible with bitmaps made by the
make-bitmap function, and they include flips, rotates, laso, paintbucket,
and some other functions.
the down side: they're written in mpw c. I'd like to supply them
in a .fasl file so folks using them don't have to bother with the
ff interface. is this possible? having being stuck in the c world (ug!)
for some time now, I'm not totally adept at what would be involved
in doing this. so if you can help, please send verbose directions
so I can start right away.
Some time ago, I posted directions on how to draw to offscreen bitmaps. At
the time, what I posted wasn't too practical. Since then, I've boiled
it down to a macro:
;; with-bitmap sets the drawing environment to draw into
;; the bitmap bm and executes the statements in the body
;; of the macro. with-bitmap uses with-port to set the port
;; hence, the statements in body are executed with *without-interrupts*
;; and if you do any drawing, you should use the traps directly.
(defmacro with-bitmap ((bm) &body body)
`(rlet ((myport :GrafPort)
(current-port :GrafPtr))
(unwind-protect
(progn ; protected part
(#_GetPort current-port)
(with-port (%get-ptr current-port) (#_OpenPort myport))
(with-port myport
(#_SetPortBits ,bm) ; set the port's bitmap
(#_PortSize (rref ,bm bitmap.bounds.right) (rref ,bm bitmap.bounds.bo
ttom)) ; and set the new size
(progn ,@body)))
(#_ClosePort myport))))
to use it, first make a bitmap:
(mybits (make-bitmap 0 0 100 100)) ;; 100 * 100 square offscreen bitmap
then, to draw to the bitmap:
(with-bitmap (mybits)
(#_EraseRect (pref mybits bitmap.bounds))
(with-pstrs ((s "MCL2"))
(#_MoveTo 20 60)
(#_DrawString s)))
then, to put the image in a window:
(copy-bits mybits
(pref (wptr <insert some window here>) windowrecord.portbits)
(pref mybits bitmap.bounds)
(pref mybits bitmap.bounds) ;; destination rectangle
:patCopy))
any help with the .fasl thing would be gratefully appreciated!
thanx in advance
-john montbriand