esp_05@jhunix.HCF.JHU.EDU (Stdnt 05) (12/19/89)
Although this is probably a mundane question, it's not working like I'd expect it, so I'll ask: I'm trying to save a PICT resource to disk after a certain program draws the picture so that another program can reproduce that picture later. In theory, I should just have to do a save of the length of the PICT resource at the address of the resource, then to load it create a resource large enough to contain the original and load it in. Doesn't seem to work. Just the loading part doesn't seem to work with MacDraw PICTS either. Can someone send me quick 'n dirty code to do this in Think C? Thanks in advance. Please respond to RICK @ JHUVM (bitnet). Eric
earleh@eleazar.dartmouth.edu (Earle R. Horton) (12/19/89)
In article <3729@jhunix.HCF.JHU.EDU> esp_05@jhunix.UUCP (Stdnt 05) writes: > >Although this is probably a mundane question, it's not working like >I'd expect it, so I'll ask: > >I'm trying to save a PICT resource to disk after a certain program >draws the picture so that another program can reproduce that picture >later. In theory, I should just have to do a save of the length of >the PICT resource at the address of the resource, then to load it >create a resource large enough to contain the original and load it in. >Doesn't seem to work. Just the loading part doesn't seem to work with >MacDraw PICTS either. Can someone send me quick 'n dirty code to do >this in Think C? It sounds like you are confusing "Handle" and "resource" a little here. If you have managed to define a Picture successfully, it will be stored in a relocatable memory block, referenced by the PicHandle returned to you by your initial OpenPicture call. You can take the PicHandle, and use AddResource to turn it into a resource Handle. It then becomes a resource which is a part of the default resource file. Displaying a PICT resource created in this manner is simple. You just open the file containing the resource, load it with GetPicture, and call DrawPicture with the PicHandle. Another method is to store the Picture in the data fork of a document file. This is how MacDraw PICT documents are stored. The actual Picture data starts 512 bytes into the file, however, and that may be why you are having trouble loading them. A very good source for saving and loading pictures to/from PICT files may be found in the QuickDraw chapter of Inside Macintosh V. Be a little careful when using it with C, because the sizeof() operator can produce different results from those intended if your compiler does not allow zero-length arrays in structure declarations. Earle R. Horton