[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Help with pixmaps
- To: info-mcl
- Subject: Help with pixmaps
- From: gat@robotics.jpl.nasa.gov (Erann Gat)
- Date: 6 Mar 92 17:48:44 GMT
- Newsgroups: comp.lang.lisp.mcl
- Organization: Jet Propulsion Laboratory
- Sender: news@elroy.Jpl.Nasa.Gov (Usenet)
I need some help with pixmaps and copybits. When I copy a color
image from a window into another window using copybits everything
works fine. However, when I copy an image into a pixmap which I
have created and then back into a window the image comes back in
black; all the color is gone.
Thanks for any hints,
Erann Gat
gat@robotics.jpl.nasa.gov
Here is some sample code to reproduce this problem:
(require 'traps)
(require 'records)
(require 'quickdraw)
(require '68k-utils)
(defobject *color-window* *window* *color-window-mixin*)
(setq w1 (oneof *color-window*))
;; Draw a color image to play with
(ask w1
(erase-rect 0 0 500 100)
(set-fore-color *red-color*) (move-to 0 0) (line-to 50 50)
(set-fore-color *blue-color*) (line-to 100 100)
(set-fore-color *green-color*) (frame-arc 0 360 20 20 80 80))
;; Setup pointers to the window's pixmap
(setq wptr1 (ask w1 wptr))
(setq pixmap_h (rref wptr1 cgrafport.portpixmap))
(_hlock :check-error :a0 pixmap_h :d0)
(setq pixmap (%get-safe-ptr pixmap_h))
(setq r1 (make-record :rect :topleft #@(0 0) :bottomright #@(100 100)))
(setq r2 (make-record :rect :topleft #@(100 0) :bottomright #@(200 100)))
;; Copying from window to window does the right thing
(copy-bits pixmap pixmap r1 r2)
;; Now make a new pixmap
(setq pm_h (_newpixmap :check-error :ptr))
(_hlock :check-error :a0 pm_h :d0)
(setq pm (%get-safe-ptr pm_h))
;; Allocate some space for the pixels
(setq pixels (_newptr :check-error :d0 10000 :a0))
;; Setup the pixmap
(rset pm_h pixmap.baseaddr pixels)
(rset pm_h pixmap.rowbytes (+ 100 #x8000)) ; Setting bit 15 should enable color
(rset pm_h pixmap.bounds r1)
(rset pixmap_h pixmap.pixelsize 8) ; Oddly, the pixelsize for the window's
(rset pixmap_h pixmap.cmpsize 8) ; pixmap is 1. Results are the same.
(rset pm_h pixmap.table (rref pixmap_h pixmap.table)) ; Use window's color table
;; Now copy pixels into new pixmap and back into window. Result is loss
;; of color.
(copy-bits pixmap pm r1 r1)
(copy-bits pm pixmap r1 r2)