QuickDraw is the legacy 2D drawing engine for Macintosh computers and was deprecated in Tiger (10.4) but is still available for 32-bit applications on 10.4, 10.5 and 10.6. 64-bit applications can't use QuickDraw yet and Apple recommends to switch to other technologies like Quartz 2D.
With the QuickDraw technology, you could create PICT images. The picture format was the graphics metafile format in Mac OS 9 and earlier. A picture contains a recorded sequence of QuickDraw imaging operations and associated data, suitable for later playback to a graphics device on any platform that supports the PICT format.
Apple made a good ‘Quartz Programming Guide for QuickDraw Developers’ guide that explains you how to convert your old PICT data to more modern images.
In this post I explain how to read PICT data in a 64-bit application. This might be useful if you ported your application to 64-bit but you want it to be able to read some old data generated by a previous version of your app (and convert the images to a more modern format).
Here is a link to download a small PICT file. If you try to open this image in Preview running in 64-bit on 10.6, you will be told that the PICT format is unsupported but you can run Preview in 32-bit compatibility mode:
There is yet a way to have PICT support in 64-bit apps: you can use the deprecated (but available on x86_64) class NSPICTImageRep. Using this class, you can get an NSImage out of the PICT data.
Here is the source code:
// Get the data contained in the PICT file NSData *data = [NSData dataWithContentsOfFile:@"/tmp/sample.pict"]; // Returns an NSPICTImageRep object initialized with the specified data. NSPICTImageRep *imageRep = [[NSPICTImageRep alloc] initWithData:data]; // Create an NSImage and add the specified image representation object NSImage *image = [[NSImage alloc] init]; [image addRepresentation:imageRep]; // Do something with the NSImage // Cleanup [imageRep release];
When you use this code in a 64-bit app, you will notice that a 32-bit process called ‘picd’ (/usr/sbin/pictd) is started. This is this process that really does the job. As you can also see in Activity Monitor, the 64-bit version of QuickLook uses this ‘pictd’ process to generate the previews of PICT files.
So why does Preview not use this 32-bit process and instead display an error? Apple probably wants to get rid of this old PICT format…