[comp.sys.mac.programmer] Question about clipRect and OpenPicture

ark@cs.rit.edu (11/09/88)

I was reading about the picture-related calls (OpenPicture, ClosePicture, etc.)
in Inside Macintosh Volume I the other day.  The description of OpenPicture
said that if the grafPort's clipRect is set to the default arbitrarily-large
clipping rectangle when a picture is opened, there may be problems later when
the picture is drawn; it may happen that nothing appears.

I found all this very obscure.  Can someone (a) tell me why one can't use the
default clipRect, and (b) post or send a code fragment (C or Pascal) that shows
me everything I am supposed to do when I create a picture and when I draw the
picture?

Thank you for your support.

Alan Kaminsky                           P. O. Box 9887
School of Computer Science              Rochester, NY  14623
Rochester Institute of Technology       716-475-5255
ark@cs.rit.edu

lsr@Apple.COM (Larry Rosenstein) (11/10/88)

In article <749@cs.rit.edu> ark@cs.rit.edu (Alan Kaminsky) writes:
>
>I found all this very obscure.  Can someone (a) tell me why one can't use the
>default clipRect, and (b) post or send a code fragment (C or Pascal) that shows
>me everything I am supposed to do when I create a picture and when I draw the
>picture?

The problem is that if you then draw the picture at some place other than
its original position, that default clipRect gets offset as well.
Unfortunately, the coordinates will overflow if the offset is more than 1
pixel (or so).

The solution is to call ClipRect before or after calling OpenPicture.  In
general, you would pass the same rectangle to ClipRect and OpenPicture.  

		 Larry Rosenstein,  Object Specialist
 Apple Computer, Inc.  20525 Mariani Ave, MS 46-B  Cupertino, CA 95014
	    AppleLink:Rosenstein1    domain:lsr@Apple.COM
		UUCP:{sun,voder,nsc,decwrl}!apple!lsr