[comp.sys.mac.programmer] ColorMaps and Pictures

tonyg@merlin.cvs.rochester.edu (Tony Giaccone) (08/29/89)

Ok folks, I'm slightly confused. I've been working on a program to take sun
raster files, and display them on a Mac II. Which currently works pretty
well (I intend to post this code to sources.mac when I'm done). The last
problem I'm having deals with color maps. 


I read in the color map from the sun, and create a macintosh color map.
Once the color map has been created, I associate it with the offscreen
pixmap that holds the Sun Raster Image.

I then use that colormap to create a palette which I associate with the
window that I've created to display the image. I then copybits the off
screen image in to the port rect of the widow. This all works just fine.

My problem comes when I want to save this picture to disk. Here's what I do
when the user selects save. First I query the user for a file name to save
the picture as. Next I create the file with Creator 'MDTS' and type 'PICT'
( I user the creator 'MDTS' so the file is associated with the Apple's 
PICTviewer). Then I change the Standard Graf Procs so that a spooling
routine will be used when I create the picture (as described in a Tech Note,
and I.M. Volume 5. I then open a Picture, do a copy bits ( of the same kind
I did to create the window's contents in the first place). Call
ActivatePalette, and then close the picture. Finally I do the file clean up
described in Inside Mac, and the Technote and then close the file. This all
seems to work as excepted. When I view the PICT file with PICT viewer
everything seems fine. However, all is not well in Whoville. 

The original colomap isn't associated with the PICT.  If I display a
different image than the one I saved (so that the color map is changed) and
then enter PICTviewer and display the PICT file that I created it uses the
color map of the most recently displayed file. Which has me confused. I
expected it to use the colormap in use when I did the CopyBits.

So folks what did I do wrong. Is there something I forgot. Should I somehow
associate the colormap I want with the mac window as well as the offscreen
bitmap, or is it sufficent to have a palette associated with the window.
What's the scoop? Can anybody give me a hand with this?


					Thanks in Advance,
						Tony Giaccone
					
					tonyg@cvs.rochester.edu