PIC file format
This document provides an overview of the Softimage® 3D Picture File Format. This format has been used by Softimage 3D and many other application programs for storing true color image data.
The format consists of two parts: file header and image data. The header contains general information about image and specification for each channel. The image data records pixel values.
|Table of contents|
The file header can be divided into two sections:
- Picture info section
- Channel info section
Picture Info Section
This section contains general information about the picture. It is summarized by the following table.
|Offset||Length (in bytes)||Name||Description|
|0||4||magic||A predefined magic number: BINARY_MAGIC_NUMBER. It is 5380f634 (in hex.).|
|4||4||version||Version of format (float).|
|92||2||width||image width, in pixels|
|94||2||height||image height, in pixels|
|96||4||ratio||Pixel aspect ratio. Corresponds to pixel width / height. In the case of square pixel, this ratio is 1.|
|100||2||fields||Indicates the picture field type (depending on the manner of using video scanline).|
|102||2||pad||Unused. Should be zero.|
The fields field can take one of following codes:
Channel Info Section
This section contains one or more "channel packet". Each one describes one or several channels. For instance, we can use a channel packet to describe the Red, Green, Blue channels, and another one to describe Alpha channel. The format of the channel packet is shown in the following table.
|104||1||chained||0 if last packet 1 if there is another packet after this one.|
|105||1||size||Number of bits for each pixel value by channel. Set to 8.|
|106||1||type||Data and encoding type.|
Encoding Type Codes
|UNCOMPRESSED||0x00||Image is uncompressed|
|MIXED_RUN_LENGTH||0x02||Run Length compression|
In the Softimage 3D standard picture file, we use one or two of the following packets depending on whether or not there is an alpha channel.
chained = 1 (or 0, if only one packet is used) size = 8 type = MIXED_RUN_LENGTH channel = RED_CHANNEL | GREEN_CHANNEL | BLUE_CHANNEL
chained = 0 size = 8 type = MIXED_RUN_LENGTH channel = ALPHA_CHANNEL
The first packet is for three colors channels, the second, for alpha channel. So the order for encoding each data is:
- First, data for three colors are encoded together.
- Then, the alpha channel data are encoded.
Image is compressed. 8 bits for each pixel value by channel. So the pixel value has a range of [0, 255].
The image data are stored by scanline, from top to bottom, and from left to right. The order for encoding each channel data is determined in channel packets. For example, when using the two packets of section 1.2, for a 3x3 (width x height) RGBA image, the data are formatted like this:
- (line 0) RGBRGBRGBAAA
- (line 1) RGBRGBRGBAAA
- (line 2) RGBRGBRGBAAA
There are two ways to encode data:
- Mixed Run Length Compression
Data are actual pixel values.
Mixed Run Length Compressed Data
Two cases are considered:
- Sequences of repeated values (such as "aaaaa").
- Sequences of non-repeated values (such as "abcde").
A sequence of repeated values is denoted by one or two counts (depending on sequence length) and a single value.
If length < 128, a one byte count is used.
count = length + 127