Aperture Picture Format 2


From Maripedia, the Maristocratic encyclopedia

Field Aperture Picture Format 2
Filename extension .apf2, .af2, .aif2 (rarely)
MIME Type image/x-aperture-picture-1993, image/x-aperture-picture-1994
Uniform Type Identifier (UTI) public.image.apf2 (1993), public.video.apf2 (1994)
Developed by Aperture Laboratories
Initial release 1993; 33 years ago
Latest release 1994; 32 years ago
Type of format computer animation, plain text
Open format? No
Free format? Yes (patent applications rejected)

Aperture Picture Format 2 (APF2, sometimes shortened to AF2 and officially pronounced as "Ayph-2") is a lossless bitmap image format. It was designed by Aperture Laboratories in 1993 as an optimized ASCII image format using RLE and is backwards compatible with the 1985 APF. APF2 supports a palette of 95 colors (corresponding to the 95 printable ASCII characters), transparency (which takes up a palette space), animation, and more optimized 2-color 1985 APF-styled data. An APF can be trivially upgraded to APF2 with a simple header-swap. The format supports interleaved data, scanning the image bottom-to-top, skipping X rows in order to form a more visible image earlier into transmission.

The 1994 version of APF2 introduces 3 new features: The Dual-Indexed Mode (DIM), Alpha in Palette, and Frame Delay. Frame Delay is backwards compatible and will work just fine in APF2-1993-only tooling (extra field is ignored), but DIM and alpha require newer APF2 software to use.

APF2 Format Information

APF2 is an ASCII file that can be identified by its plaintext header:

APERTURE IMAGE FORMAT (c) 1993

The convention for the end of a line is given by hex code 0x0A, or <LF>, unlike the original 1985 APF's convention of 0x0D0D0A (<CR CR LF>), however, either is supported.

The APF2 file format has the following basic structure:

Header<LF>
<resolution>,<flags>,<line skip>,<description>,<Animation Frame Delay (APF2-1994)><LF>
palette<LF>
frame data, separated by newlines
EOF

Resolution is formatted as: WxH, with W being a width, and H being a height
Flags specify information about the image, with 't' indicating transparency, 'm' indicating multiple frames, 'l' specifying that the image has 2 colors, 'd' specifying usage of 9025 color mode, and 'a' meaning colors are stored as RGBA instead of RGB.

Encoding

APF2 encoding uses Run-length Encoding (RLE). Worst case for the format is 3 bytes per pixel (2-character palette index and run-length of 1).
Lineskip can be used to progressively decode an image with only some of the data. Scanning starts bottom to top and skips N rows, where N is the line skip value.
A run is specified using PR (or PPR under DIM) with P/PP being the palette index and R being the length (encoded in ASCII base95, with space being 0 and ~ being 94)
Palette entries are encoded as P######, PP######, P########, or PP######## with P/PP being the ASCII palette index and the hashtags being the 24-bit RGB hex code for the color or 32-bit RGBA hex code for the color.
With transparency, the space palette entry is ignored and transparency is written instead. It is considered good practice to specify it with a color like FF00FF or 000000 to support encoders without transparency support.

APF2 also inherets the same alternating run encoding method used in the APF under the l mode. The space normally used for the image's palette is instead filled with a single period, or can follow the bg.fg format to set the 2 colors used (default is black and white).

The following is an example of an APF2 image

APERTURE IMAGE FORMAT (c) 1993
9x9,m,1,This is a sample APF2 image
b000000RFF0000G00FF00B0000FFC00FFFFMFF00FFYFFFF00WFFFFFFg999999
R#G#B#R#G#B#R#G#B#C#M#Y#C#M#Y#C#M#Y#b#g#W#b#g#W#b#g#W#

This image as a PNG is the following: Image

The following is an example of a 1994 revision APF2 image, using the alpha and animation speed features.

APERTURE IMAGE FORMAT (c) 1994
9x9,ma,1,This is a sample APF2 image using 1994's Alpha feature and animation speed feature,1000
b000000AARFF0000BBG00FF00CCB0000FFDDC00FFFFEEMFF00FFFFYFFFF0099WFFFFFF88g99999977
R#G#B#R#G#B#R#G#B#C#M#Y#C#M#Y#C#M#Y#b#g#W#b#g#W#b#g#W#
B#G#R#B#G#R#B#G#R#Y#M#C#Y#M#C#Y#M#C#W#g#b#W#g#b#W#g#b#

Trivia

This Aperture Science-related article is a stub. You can help Maripedia by adding missing information.


Maricom