daveh@tekcrl.LABS.TEK.COM (David Hatcher) (02/15/90)
I'm new to mac programming so if I'm not clear please bear with me. What I'm trying to do is spool a picture to a file. I've translated the code from Inside Macintosh V, page 89 to Lightspeed C 3.02. Where I hang up is on: newPICThand = OpenPicture(&pFrame); At that point I get an "illegal instruction" notice. My gut feeling is that there is something wrong with "pFrame". But I'm not sure about that, and there could very easly be other errors that I have introduced to this code. I have included my code below. Thanks David Hatcher -------------------------------------------------------- /*** spool picture globals ***/ PicHandle myPictHand; WindowPtr myWindow; long PICTcount; int globalRef; PicHandle newPICThand; pascal putPICTdata(dataPtr, byteCount) Ptr dataPtr; int byteCount; { long longCount; int err; longCount = (long)byteCount; PICTcount += byteCount; err = FSWrite(globalRef, &longCount, dataPtr); if(newPICThand != 0L) (*newPICThand)->picSize = PICTcount; } doSpoolPICT() { OSErr err; short i; Point wher; long longCount, longZero; Rect pFrame; SFReply reply; CQDProcs myProcs; Rect limit; wher.h = 20; wher.v = 20; SFPutFile(wher, "\pSave the PICT as:", "\puntitled", 0L, &reply); if(reply.good){ SetPort(myWindow); err = Create(reply.fName, reply.vRefNum, '????', 'PICT'); if ((err == noErr) || (err == dupFNErr)){ (void)(FSOpen(reply.fName, reply.vRefNum, &globalRef)); SetStdCProcs(&myProcs); myWindow->grafProcs = (QDProcs *)&myProcs; myProcs.putPicProc = (Ptr)(putPICTdata); longZero = 0; longCount = 4; PICTcount = (sizeof(Picture)); for ( i = 0; i++ < (512/4 + sizeof(Picture));) FSWrite(globalRef, &longCount, &longZero); pFrame = myWindow->portRect; newPICThand = 0L; ClipRect(&pFrame); /*********** This is where I get "illegal instruction" **********/ newPICThand = OpenPicture(&pFrame); DrawPicture(myPictHand, &pFrame); ClosePicture(); Signal(SetFPos(globalRef, fsFromStart, 512)); longCount = (sizeof(Picture )); Signal(FSWrite(globalRef, &longCount, (Ptr)(*newPICThand))); Signal(FSClose(globalRef)); myWindow->grafProcs = 0L; KillPicture(newPICThand); } else Signal(err); } --------------------------