[net.micro.mac] Problem with DA's, PICT, and Scrap

llad@ur-tut.UUCP (Dennis Venable) (10/03/85)

I need help!  I am trying to write a nifty desk accessory that creates a
Quickdraw picture then copies it to the Desk Scrap for pasting into 
Scrapbook, MW, or whatever.  The problem is I can't get anything to show
up when I do the paste except a blank rectangle corresponding to the
picture frame I used in the OpenPicture call.  Here is the set of code
(Aztec C) I use to copy to the desk scrap:

toDeskScrap()
	{
	Picture **h;
	long len,io,offset;

	h = OpenPicture(&picF);
	Replay();
	ClosePicture();
	len = (long)((**h).picSize);
	io = ZeroScrap();
	HLock(h);
	io = PutScrap(len,'PICT',(char *)(*h));
	HUnlock(h);
	KillPicture(h);
	h = (Picture **)NewHandle(0L);
	EraseRect(&picF);
	len = GetScrap(h,'PICT',offset);
	DrawPicture(h,&picF);
	}

picF is a Rect defining the rectangle I have been drawing into, Replay() is a
function that redraws the rectangle (simple Qdraw calls).  The scrap routines
return zero's for io indicating their are happy with the call.  The GetScrap() 
successfully gets the picture just PutScrapped and DrawPicture() draws it just
fine.  If, however, I bring up Scrapbook (or anything else) and try to paste
the picture I get a blank rectangle!

WHAT AM I DOING WRONG???????????

Any aid here will be greatly appreciated!! Either personal or net responses are
fine with me, just please respond!

Thanks a lot!!

/Dennis L. Venable
{decvax,allegro,seismo}!rochester!ur-tut!llad

lsr@apple.UUCP (Larry Rosenstein) (10/07/85)

[Note: original article is after the reply.]

As a rule of thumb, whenever you create a Quickdraw picture it is a
good idea to set the clipping rectangle before calling OpenPicture.
When you call OpenPicture, Quickdraw writes the current state of the
clipping into the new picture.

You should not rely on the fact that the initial clipping region of a
grafPort is set to a huge rectangle.  If you create a picture with
this huge clipping rectangle and then draw it offset from its
original place, Quickdraw must also offset the clipping rectangle.
In most cases, however, the rectangle coordinates will wraparound and
cause the effective clipping to be 0.

Larry

*****

In article <144@ur-tut.UUCP> llad@ur-tut.UUCP (Dennis Venable) writes:
>I need help!  I am trying to write a nifty desk accessory that creates a
>Quickdraw picture then copies it to the Desk Scrap for pasting into 
>Scrapbook, MW, or whatever.  The problem is I can't get anything to show
>up when I do the paste except a blank rectangle corresponding to the
>picture frame I used in the OpenPicture call.  Here is the set of code
>(Aztec C) I use to copy to the desk scrap:
>
>toDeskScrap()
>	{
>	Picture **h;
>	long len,io,offset;
>
>	h = OpenPicture(&picF);
>	Replay();
>	ClosePicture();
>	len = (long)((**h).picSize);
>	io = ZeroScrap();
>	HLock(h);
>	io = PutScrap(len,'PICT',(char *)(*h));
>	HUnlock(h);
>	KillPicture(h);
>	h = (Picture **)NewHandle(0L);
>	EraseRect(&picF);
>	len = GetScrap(h,'PICT',offset);
>	DrawPicture(h,&picF);
>	}
>
>picF is a Rect defining the rectangle I have been drawing into, Replay() is a
>function that redraws the rectangle (simple Qdraw calls).  The scrap routines
>return zero's for io indicating their are happy with the call.  The GetScrap() 
>successfully gets the picture just PutScrapped and DrawPicture() draws it just
>fine.  If, however, I bring up Scrapbook (or anything else) and try to paste
>the picture I get a blank rectangle!
>
>WHAT AM I DOING WRONG???????????
>
>Any aid here will be greatly appreciated!! Either personal or net responses are
>fine with me, just please respond!
>
>Thanks a lot!!
>
>/Dennis L. Venable
>{decvax,allegro,seismo}!rochester!ur-tut!llad