[comp.sys.mac.programmer] Opening and Displaying PICT files

jmidili@hub.cs.jmu.edu (jeff midili) (11/06/90)

I wish to open a version 2 PICT file, but I do not know how to 
use the OpenPicture command.  According to Inside Mac V, OpenPicture
will correctly open a version 2 PICT file on a color mac.  I have
been able to open the PICT file with SFOpen() , and then assign
a new  PicHandle pointer to it, but this will only display version
1 PICT files.  So basically, my color PICT is reduced to 4 levels
of  gray.  

Can anyone out there show me the C code that will open a version two
PICT file with SFOpen and OpenPicture?  I would greatly appreciate it.

Jeff Midili

jmidili@hub.cs.jmu.edu

oster@well.sf.ca.us (David Phillip Oster) (11/10/90)

There is a tech note on dispaying pictures. OpenPicture has nothing to
do with opening PICT files and displaying them. OpenPicture records a
PICT into a data structure so you can WRITE it. To READ a Pict, the
easy way is, if it will fit in memory, read it into a handle, then:

	Rect	r;
	PicHandle	pic;

	... get pic...
	r = (**pic).picFrame;
	OffsetRect(&r, -r.left, -r.top);
	DrawPicture(pic, &r);

remember that you must be using a color window for a PICT 2 to play correctly,
and that while NewCWindow() manipulates palettes for you, if you are using
a 'wtcb', a 'actb', or a 'dctb' resource to get color from GetNewWindow(),
GetNewDialog(), or Alert() respectively, that these won't manipulate the
palettes for you.

Remember that when you are recording pictures you should do a 
ClipRect(&thePort->portRect) to keep the clip included in the picture from
overflowing.
-- 
-- David Phillip Oster - Note new signature. Old one has gone Bye Bye.
-- oster@well.sf.ca.us = {backbone}!well!oster