QuickDrawViewer: A Mac OS X utility to visualise QuickDraw (PICT) files

I wanted to teach myself Swift programming and needed something a bit more involved than just “Hello World,” so I decided to write a program that would decode QuickDraw image files and display them. This project was essentially a rewrite of Java QuickDraw code I wrote many years ago.

The program is functional, although there are many rendering edge cases, the UI is a bit rough, 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 meant to be a pixel-perfect QuickDraw renderer; instead, it behaves more like a printer driver did under the classic Mac OS, trying to render pictures as well as possible on a modern macOS screen.

### Why QuickDraw?

The screen of my 2021 14″ laptop has a resolution of around 264 DPI, closer to the resolution of the LaserWriter printers (300 DPI) than that of the screen of a compact Macintosh (72 DPI), and well above the resolution of an ImageWriter dot matrix printer (144 DPI). The rendering engine of macOS is also closer to a PostScript printer than the QuickDraw model.

So, this program mostly translates QuickDraw instructions and delegates actual rendering to Core Graphics. Instructions meant for printers (QuickDraw comments) are also used in this translation.

QuickDraw was the graphical language of the original Macintosh and served as the format to store and exchange images on the computer. The original interpreter was written largely in Motorola 68K assembly by the late Bill Atkinson. Support for QuickDraw files has slowly been decaying with newer versions of macOS. On my M1 MacBook, Preview can only open a small subset of the files I have.

### Technical Background

The decoder is mostly based on *Inside Macintosh: Imaging With QuickDraw*, published in 1994. This book contains the resource definition for very simple QuickDraw pictures. You can download the compiled PICT file from the book’s resources.

Here is how the picture is rendered in Preview version 11.0 on macOS Sonoma 14.4:

*(Note: Image comparison would be inserted here.)*

This is how it is rendered in my QuickDraw Viewer:

*(Note: Image comparison would be inserted here.)*

### Supported Formats

This application primarily handles QuickDraw image files but also supports two related (though distinct) image formats:

– **QuickTime images (QTIF)**
– **MacPaint images (PNTG)**

These two formats are handled by converting them into QuickDraw at load time. QuickTime images are supported insofar as the underlying codec is supported. MacPaint images are just converted into a bitmap. Technically, they are supported because MacPaint is one possible QuickTime codec, although I have yet to encounter such an image in the wild.

### Architecture

This program has four main parts:

1. **QuickDraw Parsing Library**
Parses QuickDraw files and depends only on the Foundation framework.

2. **Rendering Library**
Renders into a Core Graphics context, depending on CoreGraphics, CoreText, and CoreImage. (AppKit is pulled in for some color logic but could easily be removed.)

3. **Core Video Decoder Library**
Uses Core Video to decode QuickTime embedded images that use video codecs into RGB.

4. **SwiftUI Application**
A minimalistic SwiftUI app that displays the pictures.

This modular architecture allows the code to be used in other applications that want to handle QuickDraw files.

### Supported QuickDraw Features

The library supports QuickDraw versions 1 and 2 files and the following primitives:

– Lines
– Basic shapes
– Rectangles
– Ovals
– Round-Rectangles
– Arcs
– Regions
– Text, with support for size, font, style, and rotation
– Patterns (original 8×8 1-bit patterns and color patterns of arbitrary size)
– Color selection for QuickDraw 1 (color planes), QuickDraw 2 RGB, Proprietary (Canvas), and CMYK
– Palette images
– Direct (RGB) images
– QuickTime embedded images with various codecs

### External Image Formats Supported

– JPEG
– TIFF
– PNG
– BMP
– JPEG-2000
– GIF
– SGI

Rendering delegates to Core Graphics, while the following formats are decoded to RGB or palettes:

– RAW (raw)
– MacPaint (decoded to bitmap)
– Targa (TGA) for RLE 8-bit palette, RLE 24-bit RGB, RLE 8-bit grayscale
– Apple Video (RPZA)
– Apple Component Video (YUV2)
– Apple Graphics (SMC)
– Apple Animation (RLE) with depths from 2 to 32 bits/pixel
– Planar Video (8BPS)
– Intel Raw (YVU9)
– Cinepak (CVID)
– Digital Video variants (dvc, dvcp, dv5n, dvpp, dv5p)
– H.263 decoded using Core Video
– QKTK pictures captured with the QuickTake 100 Camera

### Enhancements via Comment Parsing

Some basic comment parsing is employed to improve image rendering in particular ways, including:

– Polygon annotations to connect lines and closed polygons
– Fractional pen width
– Text rotation
– ICC Color profiles
– CMYK colors embedded in proprietary Deneba / Canvas comments

### Limitations

Currently, the following QuickDraw features are not supported:

– Some exotic compositing modes (typically unsupported by printers)
– Text alignment
– Polygon smoothing
– Exotic QuickTime codecs such as Photo-CD or Sorenson

### User Experience

The application is currently very simple. You can view pictures, copy and paste them into Preview, and there is an export icon in the toolbar that allows exporting to PDF files. Some primitive drag-and-drop functionality exists, which as of macOS 15.5 seems to work with most targets tested.

Additionally, a small command-line conversion tool is provided. It accepts PICT files as input and writes PDF files. Note that this tool has minimal error handling, so it’s recommended to keep the original files unchanged. Hopefully, conversion quality will improve with time.

### Additional Tools

I also wrote a small Python script that converts QuickDraw data in a text resource description into actual PICT files. This can be useful for recovering data from clippings or from applications.

This project has been a rewarding way to explore Swift programming while preserving and interacting with a fascinating piece of Macintosh history. If you’re interested in QuickDraw image handling, I hope you find this code and application useful!
https://github.com/wiesmann/QuickDrawViewer

Leave a Reply

Your email address will not be published. Required fields are marked *