I wanted to teach myself how to program Swift and needed something a little more complicated than just Hello Worldso I decided to write a program that would decode QuickDraw image files and display them. This was basically a rewrite of the Java Quickdraw code I wrote many years ago.
This program is functional, although there are many edge case rendering and the UI is a little clunky and the code could certainly be improved. I originally decided to release it for the 40th anniversary of the original Macintosh computer.
This program is not intended to be a pixel-corrected QuickDraw renderer, but behaves more like a printer driver did this with classic Mac OS and tries to render images as best as possible on a modern Mac OS
The screen on my 14″ 2021 laptop has a resolution of around 264 DPI, closer to the resolution of LaserWriter printers (300 DPI) than that of a compact Macintosh’s screen (72 DPI) and well above the resolution of an ImageWriter dot-matrix printer (144 DPI). Mac OS X’s rendering engine is also closer to a printer PostScript than the QuickDraw model.
So this program mainly translates QuickDraw instructions and delegates the actual rendering to Core Graphics. Instructions for printers (QuickDraw comments) are also used in this translation.
quick drawing was the graphical language of the original Macintosh and the format used to store and exchange images on the computer. The original interpreter was largely written on Motorola 68K by the late Bill Atkinson. Support for these files has been slowly declining with newer versions of Mac OS X, and on my PowerBook M1, Preview can only open a small subset of the files I have.
The decoder is mainly based on Inside Macintosh - Imaging With QuickDraw published in 1994. The book contains the resource definition of a very simple QuickDraw image.
data 'PICT' (128) {
$"0078" /* picture size; don't use this value for picture size */
$"0000 0000 006C 00A8" /* bounding rectangle of picture at 72 dpi */
$"0011" /* VersionOp opcode; always $0011 for extended version 2 */
$"02FF" /* Version opcode; always $02FF for extended version 2 */
$"0C00" /* HeaderOp opcode; always $0C00 for extended version 2 */
/* next 24 bytes contain header information */
$"FFFE" /* version; always -2 for extended version 2 */
$"0000" /* reserved */
$"0048 0000" /* best horizontal resolution: 72 dpi */
$"0048 0000" /* best vertical resolution: 72 dpi */
$"0002 0002 006E 00AA" /* optimal source rectangle for 72 dpi horizontal
and 72 dpi vertical resolutions */
$"0000" /* reserved */
$"001E" /* DefHilite opcode to use default hilite color */
$"0001" /* Clip opcode to define clipping region for picture */
$"000A" /* region size */
$"0002 0002 006E 00AA" /* bounding rectangle for clipping region */
$"000A" /* FillPat opcode; fill pattern specified in next 8 bytes */
$"77DD 77DD 77DD 77DD" /* fill pattern */
$"0034" /* fillRect opcode; rectangle specified in next 8 bytes */
$"0002 0002 006E 00AA" /* rectangle to fill */
$"000A" /* FillPat opcode; fill pattern specified in next 8 bytes */
$"8822 8822 8822 8822" /* fill pattern */
$"005C"
$"0008"
$"0008"
$"0071"
/* fillSameOval opcode */
/* PnMode opcode */
/* pen mode data */
/* paintPoly opcode */
$"001A" /* size of polygon */
$"0002 0002 006E 00AA" /* bounding rectangle for polygon */
$"006E 0002 0002 0054 006E 00AA 006E 0002" /* polygon points */
$"00FF" /* OpEndPic opcode; end of picture */
};
You can download the compiled Pict file. The representation in the book looks like this:
This is how the image is rendered in Preview 11.0 on Mac OS X 14.4 (Sonoma).
This is how it is rendered in QuickDraw Viewer:
This application basically handles QuickDraw image files, but also two related (but distinct) image formats:
- QuickTime Images (
QTIF) - MacPaint Images (
PNTG)
These two formats are handled by converting them to QuickDraw at load time. QuickTime images are supported as long as the underlying codec is supported. MacPaint images are simply converted to a bitmap. Technically they are compatible because it is a possible QuickTime codec for an image, although I have yet to find an image like that in the wild.
This program basically consists of four parts:
- A library that parses QuickDraw files, which only depends on the
Foundationstructure. - A library that is rendered in a CoreGraphics context, which depends on CoreGraphics, CoreText, and CoreImage (AppKit is built in for some color logic, but can be easily removed).
- A library that uses Core Video to decode QuickTime embedded images that use RGB video codecs.
- A minimalist Swift-UI app that displays images.
This architecture is intended to allow the code to be used in other applications that want to handle QuickDraw files.
The library basically parses QuickDraw version 1 and version 2 files and supports the following primitives:
- Pattern
- Basic shapes
- Rectangles
- Ovals
- round rectangles
- Arches
- Regions
- Text, with the following characteristics:
- Selection of size, font and style.
- Rotation
- Patterns
- original 1-bit 8×8 patterns
- Color patterns of arbitrary size.
- Color selection:
- Quickdraw 1 (colorful airplanes)
- Express Drawing 2 RGB
- Owner (canvas) CMYK
- pallet images
- Direct images (RGB)
- QuickTime PiPs with the following codecs:
- External image formats: JPEG, TIFF, PNG, BMP, JPEG-2000, GIF, SGI; processing is delegated to Core Graphics
- RAW (
raw) – Decoded to RGB - MacPaint – Decoded to BitMap
- Targa (
tga) for 8-bit RLE, 24-bit RLE RGB, 8-bit RLE grayscale palette. - Apple Video (
RPZA) – Decoded to 555 RGB - Apple Component Video (
YUV2) – Decoded to RGB - Apple Graphics (
smc) – Decoded in palette. - Apple animation (
RLE) with depths of 2,4,8,16, 24 and 32 bits/pixel - Flat video (
8BPS) – Decoded to RGB - Raw Intel (
YVU9) – Decoded to RGB - Cinepak (
CVID) – Decoded to palette or RGB - Digital video variants (
dvc,dvcp,dv5n,dvpp,dv5p) – Decoded to RGB using Core Video h263– Decoded to RGB using Core Video.qktk– Images captured with the QuickTake 100 camera.
Some basic comment analysis is used to improve the images, in particular:
Currently, the following QuickDraw features do not work:
- Some exotic layout modes (not typically supported by printers)
- text alignment
- Polygon smoothing
- Exotic QuickTime codecs, such as Photo-CD or Sorenson.
Currently the application is very simple, you can view images, copy and paste them in Preview. There is an export icon on the toolbar that allows you to export to PDF files. There is some primitive drag and drop that as of Mac OS
A small conversion command line tool is provided that takes PICT files as input and writes PDF files. Please note that this tool has minimal error handling. I would recommend keeping the original files as the quality of the conversion will hopefully improve over time.
I wrote a small Python script to convert QuickDraw data into a text resource description in actual PICT files. This can be useful for recover data from clipping or applications.
The code is distributed under the Apache 2.0 license.


