Softimage "pic" file converter

Written by Paul Bourke
Based upon code by Halfdan Ingvarsson


Softimage and support software such as MentalRay export images in what they call "pic" files. These support RGB and RGBA images with either no compression or RLE (Run Length Encoding). The code provided here forms the basis of a translator, currently just writing PPM and RAW images with or without the alpha channel and optionally flipped along the horizontal axis.

Source samples
image.c
lookat.c
types.h
utils.c
utils.h
image.h
pic2ppm.c
readpic.c
readpic.h
writepic.c
writepic.h

Identifying a pic file

The first 4 bytes should be 5380f634hex. The file identifier is located at byte 88, it should be 50494354hex otherwise known as "PICT". Following this is the image width and height as unsigned short integers. To be more precise for the C capable, the entire header is as follows

typedef struct
{
   int magic;                    /* PIC_MAGIC_NUMBER        */
   float version;                /* Version of format       */
   char comment[80];             /* Prototype description   */
   char id[4];                   /* "PICT"                  */
   short width;                  /* Image width, in pixels  */
   short height;                 /* Image height, in pixels */
   float ratio;                  /* Pixel aspect ratio      */
   short fields;                 /* Picture field type      */
   short padding;                /* Unused                  */
} HEADER;