rln@metasoft.UUCP (Roberta Norin) (02/09/90)
I am trying to read the contents of a PICT and convert the data to my own format. I have noticed other applications doing this. In my first attempt I just used the documentation on PICT opcodes and processed through pointer to the picture data. This worked but documentation seems to indicate that you should not do this. So I installed my own StdPutPic procedure, opened a new picture, drew the picture, and then closed and killed the new picture. Is this a legitimate approach? The Mac repeatedly calls my StdPutPic procedure with a pointer to the data and a count. For the the most part it sends me the code one time and the data the next time. However, this is not always the case. For the ShortLine opcode, for example, my procedure gets called with the code first, then with a point, then with a vertical offset, and then with a horizontal offset. For the Version opcode my routine is called with the code and the data. I am having difficulty writing a StdPutPic procedure that handles all these cases. If anyone has any insights, suggestions, or references, please e-mail them to me. Thanks, Roberta Norin rln%metasoft@bbn.com
root@brain.UUCP (Chuck Shotton) (02/11/90)
rln@metasoft.UUCP (Roberta Norin) writes: >I am trying to read the contents of a PICT and convert the data to my >own format. I have noticed other applications doing this. In my first >attempt I just used the documentation on PICT opcodes and processed >through pointer to the picture data. As you guessed, Apple says playing with PICT opcodes is naughty. >This worked but documentation seems to indicate that you should not do >this. So I installed my own StdPutPic procedure, opened a new >picture, drew the picture, and then closed and killed the new picture. >Is this a legitimate approach? StdPutPic just gives you raw PICT opcode data. This is not the way to do it if you want to write in your own format. You need to patch ALL of the GrafProcs to point to your own routines. Here's what you do..... 1) Create a PICT somehow (OpenPicture, read a resource, whatever....). 2) Patch the standard drawing procedures StdRect, StdPoly, etc. using the GrafProcs data structure to point to YOUR routines instead of the ones supplied by QuickDraw. 3) For each routine you supply, take the arguments sent to you by QuickDraw, translate the particular object or drawing command into your own format and the write it out. 4) Call DrawPicture to "play back" the picture for your routines to write out. This approach avoids having to have ANY knowledge whatsoever about the format of PICTs or PICT opcodes. That way, Apple can come up with PICT 3 or something and your program won't break. Chuck Shotton cshotton@girch1.hsch.utexas.edu ...!buster!brain!root