[comp.sys.mac.programmer] Still need help creating a QuickDraw picture

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

I still don't get it. Let me give a bit more detail. I have an image file, 512
lines by 512 pixels per line. I create a pixMap and read the image data,
storing at the location starting at the baseAddr of the pixMap. The high bit of
the rowBytes field is set. I create a color window via NewCWindow (windPtr is
the pointer to it), and also open a color GrafPort via OpenCPort (myCGrafPtr is
the pointer to it). The baseAddr, rowBytes, and bounds of the portPixMap of the
cGrafPort are assigned the corresponding values of the pixMap. When I do

CopyBits((BitMap *) *(*myCGrafPtr).portPixMap, &(windPtr->portBits),
        &(*pixMapHndl)->bounds,(windPtr->portRect), srcCopy, NULL);

the image appears in the window.

So far so good. Now I would like to creat a QuickDraw picture. If I do

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

no copybits opcode shows up, but the sequence: version op, version, header op,
size, fBBox, <4 bytes reserved>, DefHilite, Clip, opEndPic occurs.
If I try

SetPort(myCGrafPtr);
picHndl = OpenPicture(&(windPtr->portRect));
CopyBits((BitMap *) *(*myCGrafPtr).portPixMap,
         (BitMap *) *(*myCGrafPtr).portPixMap, 
         &(myCGrafPtr->portRect), &(myCGrafPtr->portRect),
         srcCopy, NULL);
ClosePicture();

then after the version opcode of 0011, the 4 following bytes are 0000, DD50,
rather than 02FF, 0C00. After that it looks like a picture, with a copybits
opcode. This doesn't seem to qualify as a picture, and a call to DrawPicture
doesn't draw anything. Just what is the correct way to create the picture?

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"

kaufman@Neon.Stanford.EDU (Marc T. Kaufman) (06/02/90)

In article <2223@dftsrv.gsfc.nasa.gov> seiler@amarna.gsfc.nasa.gov writes:
... (stuff deleted)
>SetPort(windPtr);
>picHndl = OpenPicture(&(windPtr->portRect));
>CopyBits(&(windPtr->portBits), &(windPtr->portBits),
>         &(windPtr->portRect), &(windPtr->portRect), srcCopy, NULL);
>ClosePicture();

>no copybits opcode shows up, but the sequence: version op, version, header op,
>size, fBBox, <4 bytes reserved>, DefHilite, Clip, opEndPic occurs.

Let me try (after all, everyone else has :-) ).  I don't see why you are
changing ports.  Why not just do the OpenPicture on your screen grafPort?
The picture traps will catch everything.

If you really want to use another port, you need to make sure that the
portRect, clipRgn, and visRgn are correct.  You do NOT need to worry about
the portBits.bounds, and indeed, you do not need any bitMap/Pixmap actually
allocated for a port that is only used for capturing a picture.

Marc Kaufman (kaufman@Neon.stanford.edu)