============================================================================
                           ChangeFSI file formats
============================================================================


This file lists the file formats that ChangeFSI uses, and then gives more
detail on each one.


Summary of formats
==================

Input formats
-------------
RISC OS sprites
ArVis 15-bit HIP + LOP sprites
Watford digitiser pictures, 512Χ256, 64 greys -
   and triple red, green, blue separations
ProArtisan compressed pictures, 640Χ256, 256 colours
JPEG 'JFIF' files
Kodak PhotoCD images
TimeStep satellite images, 800Χ800, 256 greys
PC TGA images
MTV 24-bit PIC images
QRT 24-bit RAW images
ZSoft .PCX files
Degas PI1, PI2, PI3 images
!Translator Clear format files
CCIR 601 4:2:2 images
!RayShade 'RGB' images
TimeStep satellite images, 128Χ256, 256 greys -
   and triple red, green, blue separations
Wild Vision Hawk V12, 512Χ512, 256 greys
AIM/Wild Vision Hawk V10, 256Χ256, 256 greys
Wild Vision/Hawk V9, 256Χ256, 24 bit triple image
Wild Vision Hawk V9, 512Χ256, 12-bit colour
Wild Vision Hawk V9 Mk II, 16-bit colour
Pineapple 16 bit per pixel images
FITS astronomical format images
Irlam Instruments YUV 411 files
Irlam Instruments 24-bit files
Windows 3 .BMP files
Compuserve's GIF files up to 8 bit per pixel
.PIC 8 bit per pixel files
Sun 'pixrect' raster files
GEM IMG images
Apollo GPR 16-colour images
RIX Softworks ColoRIX 8 bit per pixel files
TIFF pictures
UNIX rle format files
Portable Bit Map (pbm) binary encoded formats
ChangeFSI packed portable bitmaps
PocketBook I and II PIC format files
Electronic Art's IFF ILBM pictures
MILLIPEDE PRISMA, 768Χ576, 8-bit colour images
MacPaint files, 576Χ720, 1 bit per pixel
Mac PICT2 v2 8 and 24/32 bit per pixel
RT 24-bit run length coded IMAGE files
PC EGA .DSP images, 640Χ350, 16 colours
Kodak RGB images, 24 bits per pixel


Output formats
--------------
RISC OS sprites
AIM/Wild Vision Hawk V10, 256Χ256, 256 greys
JPEG 'JFIF' files
Portable Bit Map (pbm) ASCII and binary encoded formats
ChangeFSI packed portable bitmaps


Details of formats
==================

RISC OS sprites
---------------

The old RISC OS sprite format
·····························
Contains 1, 2, 4 or 8 bits per pixel with a modification palette of up to
16 entries; any number of pixels wide and high uncompressed. Details are in
Acorn's Programmer's Reference Manual.

 Recognised by file type FF9 (a paint brush and house icon).

 Details of how many bits per pixel and the pixel size are obtained from
  the operating system (rather than being in the file) from the "MODE"
  number. Mode extensions can result in a source image containing a MODE
  number which your computer does not understand.

 Mask information ignored.

 Lefthand wastage ignored.

The new RISC OS sprite format
·····························
Contains 1, 2, 4, 8, 16 or 32 bits per pixel.

 Recognised by file type FF9.

 No problem with mode extensions: information is coded into the format.

 Mask information ignored.

ArVis 15-bit HIP + LOP sprites
------------------------------
Contains 5 bits of red, green and blue information encoded into two RISC OS
sprites "HIP.<filename>" and "LOP.<filename>" comprising a 640 pixel wide
and 256 line tall image with pixels sized 1:2. Details from ArVis
Multimedia.

 Recognised by file type FF9, and the file is beneath a directory named
  HIP, and a corresponding LOP file exists.

 Uncompressed (indeed represents 16 bits instead of 15).

Watford digitiser pictures
--------------------------
Contains a run length encoded 64 grey level 512 pixel wide, 256 line image,
with pixels sized 1:2. Details from Watford Electronics Ltd.

 Recognised by file type DFA (a small grey picture of Stevie Nicks).

 Warning: don't forget to save the pictures in *un-dithered* state!

When used with a colour converter, ChangeFSI can read three colour
separations stored in a directory of separate "red", "green" and "blue"
files of file type DFA. Beware of auto-gain/contrast when using such
information!

ProArtisan compressed pictures
------------------------------
Contains a (mildly) compressed MODE 15 (640 by 256 by 256 colours) picture.
Details from Clares.

 Recognised by file type DE2 (a beige monitor in a grey surround).

JPEG 'JFIF' files
-----------------

The JPEG File Interchange Format contains up to 24 bits R,G,B, compressed by
the JPEG compression system.

 Recognised by file type C85 (an eye), or by JFIF at offset 6 in the file.
  (You may have to cut headers off files, particularly if they are from
  Macs).

 Often highly compressed.

 If ChangeFSI$Cache is large enough (i.e. bigger than the file), then high
  speed routines are used to decompress. Otherwise:

 ChangeFSI calls a djpeg routine. This can be on the Run$Path, implemented
  as an Alias (in which case it *must* use WimpTask to start) or found
  inside ChangeFSI$Dir if all else fails. cjpeg (the compressor) is also
  available inside ChangeFSI$Dir - you will need to convert the image to P6
  format before it can be compressed. Djpeg and cjpeg are by the PD JPEG
  group

  and therefore slow. Needs a lot of space in <Wimp$Scrap>.

 No resolution specified; equal to mode 27 assumed.

Kodak PhotoCD images
--------------------
24 bit per pixel images at various resolutions.

 Recognised by file type BE8, or the file's name ends /PCD.

 Set ChangeFSI$PCDIndex to read resolutions other than base (=3).

TimeStep satellite images, 800Χ800
----------------------------------
This gives an uncompressed 800 by 800 with 256 grey levels.

 Recognised by file type 7A0 (icon never seen).

 No resolution specified; equal to mode 27 assumed.

 Documentation never seen. An extra header file <name>! is not understood
  at all.

PC TGA images
-------------
This 'Targa' format is used by TrueVision for Vista boards. Up to 32 bits
per pixel.

 Recognised by file type 69D, or the file's name ends with TGA or VDA.

 Only uncompressed formats readable.

 Only 8 and 16 bit per pixel formats tested.

MTV 24-bit PIC images
---------------------
Output from Mark Terrence VandeWettering public domain ray tracer: arbitrary
size in 2^24 colours, uncompressed. Documentation part of MTV. Also used by
"RayShade".

 Recognised by file type 699, or the file is beneath a directory named PIC.

 No resolution specified; equal to mode 27 assumed.

QRT 24-bit RAW images
---------------------
Output from Steve Koren's public domain ray tracer: arbitrary size in 2^24
colours, uncompressed. Documentation part of QRT.

 Recognised by file type 698, or the file's name is RAW.

 No resolution specified; equal to mode 27 assumed.

ZSoft .PCX files
----------------
Used by PC Paintbrush. Usually a 4 bit per pixel image (CGA, EGA, VGA), but
can be 1-8 bits per pixel.

 Recognised by file type 697, or &0A,&00|02|03|04|05,&01 at the start of
  the file, or the file is beneath a directory named PCX, or the file's name
  ends /PCX.

 Intelligent check for resolution of the DACs on the PC card. Use -info to
  find out what ChangeFSI thinks it is.

 Pixel size information read. You may need to stop the scaling with
  -nosize, since it's often wrong.

Degas PI1, PI2, PI3 images
--------------------------
The Atari ST "Degas" format contains 1, 2 or 4 bits per pixel, clear or run
length encoded. RISC OS file type by John Kortink of !Translator.

 Recognised by file type 691.

 No documentation, and only 5 images read.

 No resolution specified; equal to mode 27 assumed.

!Translator Clear format files
------------------------------
This provides 1, 2, 4, 8 and 24 bits per pixel.

 Recognised by file type 690.

 Uncompressed - especially for <8 bits per pixel, which is recorded at one
  byte per pixel.

 No resolution specified; equal to mode 27 assumed.

CCIR 601 4:2:2 images
---------------------
Contain 720 pixels by 288 rows (PAL) (243 rows NTSC), YUV coded, with pixels
sized 1:2.

 Recognised by file type 601.

 One field only.

!RayShade 'RGB' images
----------------------
 Recognised by file type 371.

TimeStep satellite images, 128Χ256
----------------------------------
Giving an uncompressed 128 pixels wide by 256 lines with 256 grey levels,
pixels sized 2:1. Used by TimeStep's !ImProcess application.

 Recognised by file type 300 (an "i" in a document frame).

 Documentation never seen.

 A bit coarse.

The grey levels represent intensity in various different wave bands. By
naming files of type 300 "red", "green" and "blue", and handing ChangeFSI the
directory, you can produce a false colour image. Hours of experimentation
can produce an almost reasonable picture

Wild Vision Hawk V12
--------------------
This provides an uncompressed 512 by 512 image with 256 grey levels.

 Recognised by file type 006.

 No resolution specified; equal to mode 27 assumed.

AIM/Wild Vision Hawk V10
------------------------
This provides an uncompressed 256 by 256 image with 256 grey levels. Details
from Delft University of Technology and ECD Computers Delft B.V.

 Recognised by file type 004 (a picture of 'Trui' with "TU" in blue).

 ChangeFSI can write to this format; specify the output mode as "AIM", and
  specify "=" in the sizing to get a 256 by 256 output (otherwise it will be
  the same size as the source image).

 No resolution specified; equal to mode 27 assumed.

 The associated file <name>+ (file type 010) which contains additional
  information is ignored by ChangeFSI. The grey levels may represent
  intensity in various different wave bands. By naming files "red", "green"
  and "blue" and handing ChangeFSI the directory (see Wild Vision/Hawk V9 24
  bit triple image below), you can produce a false colour image. Hours of
  experimentation can produce an almost reasonable picture

 As a special feature, ChangeFSI will also write out files in this
  format if you specify the mode string as "AIM". You should use the =
  operation to restrict the picture to 256x256y, otherwise it will be the
  same size as the input.

Wild Vision/Hawk V9 24 bit triple image
---------------------------------------
Three files, resolution 256 by 256, giving a 24-bit image.

 Recognised by a directory holding type 004 files named RED, GREEN and
  BLUE.

Wild Vision Hawk V9 12-bit colour
---------------------------------
This provides an uncompressed 512 by 256 image with 4 bits of red, green and
blue, pixels sized 1:2. Also used by SnapShot.

 Recognised by 'MercSoft' or 'SnapShot' at the start of the file.

Wild Vision Hawk V9 Mk II, 16-bit colour
----------------------------------------
 Recognised by 'MercSof1' at the start of the file.

Pineapple 16 bit per pixel images
---------------------------------
Pineapple Software's colour digitiser format contains 6 bits of green, 5
bits of red and blue information filed as a single data file starting
"FSIfile" comprising a 512 pixel wide and 256 line tall image with pixels
sized 1:2.

 Recognised by 'FSIFile' at the start of the file.

 Uncompressed.

FITS astronomical format images
-------------------------------
The "Flexible Image Transport System" (FITS) format is used for astronomical
data. Up to 16 bits per pixel component.

 Recognised by 'SIMPLE  ' at the start of the file.

 Only 8 and 16 bit per pixel component formats tested.

 Only two files ever seen!

 No resolution specified; equal to mode 27 assumed.

Irlam Instruments YUV 411 files
-------------------------------
7 bits Y, up to 7 bits U and V.

 Recognised by 'IRLAM YUV 411' at the start of the file.

 No resolution specified; equal to mode 27 assumed.

Irlam Instruments 24-bit files
------------------------------
24 bit per pixel from colour scanner.

 Recognised by 'Irlam' at the start of the file.

 No resolution specified; equal to mode 27 assumed.

 May need gamma correction.

 Can be written.

Windows 3 .BMP files
--------------------
Used by MicroSoft in Windows 3 and PaintBrush for Windows 3. Provides an
arbitrary sized image and 1, 4 or 8 bits per pixel. Uncompressed.

 Recognised by 'BM' at the start of the file; or 'RIFF' at the start of the
  file, and 'RDIBdata' at offset 8 and 'BM' at offset 20 in file.

 No resolution specified; equal to mode 27 assumed.

 Documentation never seen - 7 files examined and intelligent guesses made!

Compuserve's GIF files up to 8 bit per pixel
--------------------------------------------
Used for wide area network transfer of images. It provides an LZW compressed
up to 256 colours from 2^24 arbitrary sized image. Details from CompuServe
(USA), or usenet.

 Recognised by 'GIF8' at the start of the file.

 LZW compression is efficient even for dithered images.

 ChangeFSI can decompress LZW quickly.

 No resolution specified; equal to mode 27 assumed.

 Many low quality images around from PCs.

.PIC 8 bit per pixel files
--------------------------
Used for some VGA demos, the format provides an uncompressed 320 by 200 by
256 colour (from 2^24) VGA screen dump.

 Recognised by 'AV_VO' at the start of the file.

 Documentation never seen.

 Pixel size assumed the same as MODE 13 (45 pixels per inch).

Sun 'pixrect' raster files
--------------------------
Used under SunOS and also under X11. Commonly 1 or 8 bits per pixel, but up
to 24 bits per pixel can be found (see the Sun NeWS release tape!).

 Recognised by &956AA659 at the start of the file.

 No resolution specified; equal to mode 27 assumed.

 Sun didn't specify the pixel ordering of 24 bit per pixel images: many
  assume RGB when it was actually BGR. Change byte &17 in the Sun rasterfile
  between 1 and 3 if you have a problem.

GEM IMG images
--------------
Used by Digital Research's GEM (and GEM Paint) on both PC and Atari ST.
Provides an arbitrary sized image and number of bits per pixel (though it's
only usually used with up to 5 bits per pixel) and pixel size. Compressed by
run length encoding and line repeats.

 Recognised by &08000100 at the start of the file ("version 1, header
  length 8"), or the file is beneath a directory named IMG , or the file's
  name ends /IMG.

 Planar file format slow to read.

 Palette not specified: ChangeFSI assumes linear shades of grey. You might
  need to use -invert if the image is a negative.

 The size of a pixel is specified in microns. The standard RISC OS 90
  pixels per inch translates to (1/90Χ2.54Χ10,000) microns - 282. (Use -info
  to get information about the scaling, -nosize to stop it.)

 Documentation from the "ST World" magazine's clinic.

Apollo GPR 16-colour images
---------------------------
 Recognised by &01000100 at the start of the file.

RIX Softworks ColoRIX 8 bit per pixel files
-------------------------------------------
Used by VGA Paint, image extension .SCE  .SCX. 4 or 8 bits per pixel.

 Recognised by 'RIX3' at the start of the file.

 Documentation never seen.

 Only 5 files read; ChangeFSI checks to see if the header is the same as
  these files, and complains otherwise.

 No resolution specified; equal to mode 27 assumed.

TIFF pictures
-------------
Frequently used by scanners, the Aldus/MicroSoft TIFF format is a common
interchange format for graphics images on the Mac and PC (particularly DTP
and Windows). It provides an arbitrary number of bits per pixel, size etc
using a numeric tag scheme allowing new information to be introduced without
upsetting existing programs. The format may be compressed (in 5 different
ways at present). Details from Aldus UK, MicroSoft, Hewlett Packard

 Recognised by 'II' plus the 16 bit number 42 at the start of the file for
  little endian machines (ix86, ARM, VAX)

 Recognised by 'MM' plus the 16 bit number 42 at the start of the file for
  big endian machines (M680x0)

 Can read PackBits images and LZW compressed forms (at least the 3 it's
  seen so far).

 Cannot read predictor compressed LZW images.

 So far ChangeFSI has only done 1, 4, 8 and 24 bit images. It can't read
  "planar" images or CCITT compressed forms.

 Some TIFF images have incorrect pixel sizes: use -nosize if this is true.
  If no pixel size is specified, ChangeFSI assumes mode 27 size.

 TIFF is a trademark of Aldus Corporation

 Assigned RISC OS file type FF0; correctly typed files are recognised more
  quickly.

UNIX rle format files
---------------------
Used by a program called "svfb" to save the contents of large frame buffers;
checked with four images at 24 bits per pixel.

 Recognised by &CC52 at the start of the file.

 No resolution specified; equal to mode 27 assumed.

Portable Bit Map (pbm) binary encoded formats

The "pbm" 'portable bitmap' file format
---------------------------------------
Used by the "PBM-PLUS" toolkit (mainly Unix) by Jef Poskanzer. 1-24 bits
per pixel (more can be specified in the format but ChangeFSI cannot read
them). There are 3 types of format: black/white ('pbm'), grey ('pgm'), and
colour ('ppm'); there are ASCII and binary encodings of each. ChangeFSI can
read only the binary encoded formats (which use big-endian bytes), but for
portability to other machines it can write the binary and ASCII encoded
formats.

 Recognised by 'P4', 'P5' or 'P6' at the start of the file.

 Writable by ChangeFSI - first characters of file are:

                  Binary  ASCII (output only)
  black/white     P4      P1
  grey            P5      P2
  true colour     P6      P3

 No resolution specified; equal to mode 27 assumed.

Files can be read with Jef Poskanzer's portable toolkit on other machines. The
p2 format is easily convertible by programmers; it consists of:

P2
# comment line
xsize ysize
maximum_value
pixel_value <whitespace> pixel_value

where all the numbers are in decimal (ASCII). 0 means black, maximum_value
(=15) means white. The p3 format is similar with r, g, b triples for each
pixel value. The number of bits per component (default 8) can be set from
the command line with, for example, "p3,4" for 4 bits per component.

ChangeFSI packed portable bitmaps
---------------------------------
 Recognised by 'P15' at the start of the file.

 Special packed output format. Binary pixel values, 5 bits per component,
  little endian RGB order packed into 16 bits. Header information as the
  other p formats.

PocketBook I and II PIC format files
------------------------------------
 Recognised by 'PIC' at the start of the file.

Electronic Art's IFF ILBM pictures
----------------------------------
Provides an arbitrary sized image with up to 4096 colours, sometimes run
length encoded. ChangeFSI understands the generic format and also the
special Amiga format for "HAM" and "Half-bright" images.

 Recognised by 'FORM' at the start of the file and 'ILBM' at offset 8 in
  file.

 Only pixel aspect ratio specified, not its size (and then sometimes
  incorrectly): use -nosize *and* a size change (a:b) if it's wrong.

 Images often small.

 Doesn't understand Amiga "hires".

 Can't convert HAM pictures directly to monochrome.

MILLIPEDE PRISMA 8-bit colour images
------------------------------------
The Millipede Prisma 3 is a 768 pixels wide by 574 line interlaced display
board for the Archimedes and BBC Microcomputer. It allows use of 256 colours
from 2^24. Files may be stored uncompressed (432KBytes!) or run length
encoded. This format is also used by CadSoft. More details from CadSoft or
Millipede Electronic Graphics.

 Recognised by 'MILLIPEDE' at offset 16 in file.

 No resolution specified; equal to mode 27 assumed.

 Slowish to read the compressed formats.

 Scaling the picture using = can be poor, since 574 lines don't relate very
  well to 512 or 256. Use -info to display the scale ratios.

MacPaint files
--------------
Provides a 576 by 720 bitmap, run length coded by the Mac's "PackBits"
algorithm (repeated bytes).

 Recognised by 'PNTG' at offset 65 or 196 in the file. The former may only
  relate to files which have been through a program called "MacFix". Data
  assumed to start at position 128 in the file. Header ignored.

 No resolution specified; equal to mode 25 assumed.

MacPICT2 v2 8 and 24/32 bit per pixel)
----------------------------------------------
The PICT extended version 2 format provides an arbitary size packed picture,
run length coded by the Mac's "PackBits" algorithm (repeated bytes).

 Recognised by &00,&11,&02,&FF,&0C,&00,&FF,&FE (the PICT header) at offset
  522 in the file.

 Documentation available but mostly useless (it assumes you are about to
  call QuickDraw routines - "Note: for maximum safety and convenience, let
  QuickDraw generate and interpret your pictures." Apple fail to describe
  the PackBits algorithm in Inside Mac)

 PICT is the loose equivalent of RISC OS Draw file format, but without the
  explicit sizing of objects - for PICT, if there is an object that you
  don't understand, there's no way of skipping it (whereas for Draw, the
  size of the object is specified in an object indep. way). Apple present a
  large table of the sizes of the objects (0000 - FFFF) which is not in
  ChangeFSI. Consequently, if ChangeFSI finds an object it doesn't know
  about before the picture, it stops

 Only PackBitsRect (0098) (8bpp) and DirectBitsRect (009A) (24/32 bpp) are
  allowed.

 ChangeFSI tries to skip a Clip (0001) region if it encounters it, since it
  is hard to get the Mac OS to make PICT files without a clip opcode in
  them.

 Size of pixel specified.

 Only 3 pictures read - since the format is very complicated (e.g. the size
  of things change if >250 rows in the picture!) this is no guarentee that
  anything else will be right.

RT 24-bit run length coded IMAGE files
--------------------------------------
Output from "RT", a private ray tracer by Brian D Watt(?). Arbitrary size in
2^24 colours, run length encoded.

 Recognised by file being beneath a directory named IMAGE.

 No resolution specified; equal to mode 27 assumed.

PC EGA .DSP images
------------------
Experimentally determined that it holds a 640 by 350 EGA picture at 4 bits
per pixel. ChangeFSI "knows" the default EGA palette (from IBM literature).

 Recognised by file being beneath a directory named DSP, or the file's name
  ends /DSP.

 Documentation never seen.

 No resolution specified; equal to mode 27 assumed.

 Only two examples read.

Kodak RGB images, 24 bits per pixel
-----------------------------------
 Recognised by the file's name ending /RGB.
