[comp.sys.mac.programmer] Need help creating a Quickdraw picture

seiler@amarna.gsfc.nasa.gov (Ed Seiler) (06/01/90)

I am trying to start with a raster image that I can successfully display in a
window via CopyBits, and make it into a QuickDraw picture. Here's the pertinent
code I am trying with:

picHndl = OpenPicture(&(windPtr->portRect));
CopyBits(&(windPtr->portBits), &(windPtr->portBits),
         &(windPtr->portRect), &(windPtr->portRect), srcCopy, NULL);
ClosePicture();

where picHndl is a PicHandle, and windPtr is a pointer to a window where the
image has already been successfully displayed. It seems that the picture I get
as a result starts off with the usual version opcode, version number, etc.,
but then I get an end-of-picture opcode without any of the copybits opcodes.
What am I missing? BTW, the clip region was set previously via
ClipRect(&(windPtr->portRect)); 

I am doing this using THINK C 3.01 as part of an XCMD for HyperCard.

Edward Seiler                           seiler@dftnic.gsfc.nasa.gov
Mail Code 635                           seiler@chrpserv.gsfc.nasa.gov
Goddard Space Flight Center             (301) 286-9421
Greenbelt, MD 20771

"Against stupidity, the gods themselves contend in vain"

mwilkins@jarthur.Claremont.EDU (Mark Wilkins) (06/01/90)

In article <2205@dftsrv.gsfc.nasa.gov> seiler@amarna.gsfc.nasa.gov writes:


>CopyBits(&(windPtr->portBits), &(windPtr->portBits),
>         &(windPtr->portRect), &(windPtr->portRect), srcCopy, NULL);


  CopyBits just doesn't like it if the source and destination bitmaps are
the same, and I THINK it doesn't like it if the same rectangle data
structure is passed in both places.

  What you need to do is create an offscreen bitmap and copybits the data
into the window.  There are several Tech Notes available from Apple.com
describing how to do just that.

-- Mark Wilkins
-- 
  "According  to  our  contract, at  precisely  midnight  of  the  night 
  of her greatest triumph,  the party of the first  part,  (that's you), 
  agrees to render up  her soul,  now and  forevermore,  to the party of 
  the second part.  (That's me).  Shall we go?"                          

jmunkki@kampi.hut.fi (Juri Munkki) (06/02/90)

In article <7358@jarthur.Claremont.EDU> mwilkins@jarthur.Claremont.EDU (Mark Wilkins) writes:
>In article <2205@dftsrv.gsfc.nasa.gov> seiler@amarna.gsfc.nasa.gov writes:
>>CopyBits(&(windPtr->portBits), &(windPtr->portBits),
>>         &(windPtr->portRect), &(windPtr->portRect), srcCopy, NULL);
>
>
>  CopyBits just doesn't like it if the source and destination bitmaps are
>the same, and I THINK it doesn't like it if the same rectangle data
>structure is passed in both places.

I don't know what 'seiler' is trying to do here, but actually I seem to
remember that only the 64KB ROMs had quickdraw that didn't like copybitsing
within the same bitmap. Giving the same rectangle is fine with any version
of quickdraw.

I have used a similar statement to copy the contents of a window to a picture
definition (later to be copied into the scrap).

   ___________________________________________________________________________
  / Juri Munkki	    /  Helsinki University of Technology   /  Wind  /   HP S /
 / jmunkki@hut.fi  /  Computing Center Macintosh Support  /  Surf  /   48 X /
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

mwilkins@jarthur.Claremont.EDU (Mark Wilkins) (06/02/90)

In article <1990Jun1.173103.11808@santra.uucp> jmunkki@kampi.hut.fi (Juri Munkki) writes:

>I don't know what 'seiler' is trying to do here, but actually I seem to
>remember that only the 64KB ROMs had quickdraw that didn't like copybitsing
>within the same bitmap. Giving the same rectangle is fine with any version
>of quickdraw.


  Funny, I've only been able to make it work using two separate bitmaps.
Every time I've done it copying from a bitmap to itself, it's given me an
empty picture definition.

  Of course, my graphics code is a mixture of luck and voodoo, so all
imaginable disclaimers apply. :-)

-- Mark Wilkins
-- 
  "According  to  our  contract, at  precisely  midnight  of  the  night 
  of her greatest triumph,  the party of the first  part,  (that's you), 
  agrees to render up  her soul,  now and  forevermore,  to the party of 
  the second part.  (That's me).  Shall we go?"                          

lsr@Apple.COM (Larry Rosenstein) (06/02/90)

In article <7366@jarthur.Claremont.EDU> mwilkins@jarthur.Claremont.EDU 
(Mark Wilkins) writes:
> Every time I've done it copying from a bitmap to itself, it's given me an
> empty picture definition.

Perhaps QuickDraw only records operations that involve the current 
grafPort's portBits.  If you copy from one offscreen bitmap to another 
then the operation wouldn't involve the portBits.  You might try 
installing your offscreen bitmap into a grafPort and use that port for 
creating the picture.

Larry Rosenstein, Apple Computer, Inc.
Object Specialist

Internet: lsr@Apple.com   UUCP: {nsc, sun}!apple!lsr
AppleLink: Rosenstein1