Example 1: Lumisys X-ray scanner - creates 12 bit unpacked grayscale images with a fixed 2048-byte header, and stores data in big-endian format. No sample image file is needed.
| Target platform | Mac |
| Bit packing | None |
| Format Identification | By Extension |
| Compression | Off |
| Identifier | lum |
| Bytes to skip | 2048 |
| Use header | (not checked) |
| Header file | (leave blank) |
| Header bytes | 0 |
| Default bits/pixel | 16 |
| Default Color type | Grayscale |
| Default x size | 128 |
| Default y size | 128 |
| Default RGB bits/pixel | 0 0 0 |
| Default black bits/pixel | 0 |
| Default no. of frames | 1 |
| Compression command | (leave blank) |
| Compression extension | (leave blank) |
| Decompression command | (leave blank) |
| x size | 806 |
| y size | 808 |
| Bits/pixel | 810 |
| All others | 65535 |
``Bytes to skip'' must be a multiple of 2 in this case, because there are 2 bytes (16 bits) per pixel. Skipping an odd number of bytes will cause the image will look strange because the light and dark areas are partially reversed.
Similarly, if the wrong target platform is selected, the image could look posterized or grainy, because the bytes are being put into the wrong pixels.
Here is the resulting $HOME/.tnimage/formats/lum file:
# Format descriptor for lum image format
# Created by tnimage 2.7.0 on Jun 24 1998
identifier lum
headerfile
compression
decompression
compression_extension
platform 20
packing 0
useheader 0
useidentifier 0
headerbytes 0
skipbytes 2048
compressflag 0
defaultbpp 8
defaultcolortype 0
defaultxsize 128
defaultysize 128
defaultrbpp 0
defaultgbpp 0
defaultbbpp 0
defaultkbpp 0
defaultframes 1
# Offsets into the uncompressed file:
identifieroff 65535
xoff 806
yoff 808
bppoff 810
colortypeoff 65535
compressflagoff 65535
redbppoff 65535
greenbppoff 65535
bluebppoff 65535
blackbppoff 65535
xposoff 65535
yposoff 65535
framesoff 65535
fpsoff 65535
chromakeyoff 65535
chromakey_graymin_off 65535
chromakey_graymax_off 65535
chromakey_rgbmin_off 65535
chromakey_rgbmax_off 65535
paletteoff 65535
imageoff 65535
IMPORTANT: offsets must be set to 65535 unless they are definitely known to be in the image file.
Offsets are not arbitrary locations, and must correspond to the exact position in the file at which the parameter is located. Even when you are creating a new file format, some care must be taken to ensure that offsets do not overlap with each other or with image data. For an existing image in an unknown image format, it is often necessary to find an image of a known size and examine the image file with a hex editor to find out the locations at which the parameters are stored.
If an offset is set to 65535, it will be ignored and a default value will be used instead. Some of these default values are included in the format descriptor file. For example, if bppoff is set to 65535, the value in defaultbpp will be used. If bppoff is any other value, defaultbpp will be ignored and the value will be read from the image at the specified offset.
Example 2: Creating an IMDS file. IMDS is a little-known and rarely
used monochrome format similar to GEM's IMG format, except that IMDS
was used on IBM mainframes running MVS, and there seems to be no
documentation for it.
| Target platform | MVS |
| Bit packing | TIF-like |
| Format Identification | By Extension |
| Extension | IMG |
| Identifier | (none) |
| Bytes to skip | 0 |
| Use header | |
| Header file | (Name of a sample IMDS file) |
| Header bytes | 32 |
| Default bits/pixel | 1 |
| Default No.of colors | 1 |
| x size | 12 |
| y size | 14 |
| All others | 65535 |
The default bits/pixel and default no.of colors are needed only if
the these values are not in the header.
Example 3: Define a file format for multi-frame (3D) images.
| Target platform | PC |
| Bit packing | None |
| Format Identification | By Identifier |
| Compression | On |
| Identifier | 3d |
| Bytes to skip | 0 |
| Use header | (unchecked) |
| Header file | (none) |
| Header bytes | 0 |
| Default bits/pixel | 8 |
| Default color type | Indexed |
| Default x size | 128 |
| Default y size | 128 |
| Default RGB bpp | 0 0 0 |
| Default black bpp | 0 |
| Default no. of frames | 1 |
| Compression command | gzip -f |
| Compression extension | .gz |
| Decompression command | gunzip -c |
| identifier offset | 0 |
| x offset | 4 |
| y offset | 8 |
| bpp offset | 12 |
| colortype offset | 16 |
| compressflag offset | 20 |
| redbpp offset | 24 |
| greenbpp offset | 28 |
| bluebpp offset | 32 |
| blackbpp offset | 36 |
| xpos offset | 40 |
| ypos offset | 44 |
| frames offset | 48 |
| fps offset | 52 |
| chromakey offset | 56 |
| chr.gray min offset | 60 |
| chr.gray max offset | 64 |
| chr. RGB min offset | 68 |
| chr. RGB max offset | 72 |
| palette offset | 76 |
| image offset | 844 |
Here is the resulting $HOME/.tnimage/formats/3d file:
# Format descriptor for 3d image format
# Created by ./tnimage 2.7.0 on Jun 24 1998
identifier 3d
headerfile
compression gzip -f
decompression gunzip -c
compression_extension .gz
platform 21
packing 1
useheader 0
useidentifier 1
headerbytes 0
skipbytes 0
compressflag 1
defaultbpp 8
defaultcolortype 0
defaultxsize 128
defaultysize 128
defaultrbpp 0
defaultgbpp 0
defaultbbpp 0
defaultkbpp 0
defaultframes 1
# Offsets into the uncompressed file:
identifieroff 0
xoff 4
yoff 8
bppoff 12
colortypeoff 16
compressflagoff 20
redbppoff 24
greenbppoff 28
bluebppoff 32
blackbppoff 36
xposoff 40
yposoff 44
framesoff 48
fpsoff 52
chromakeyoff 56
chromakey_graymin_off 60
chromakey_graymax_off 64
chromakey_rgbmin_off 68
chromakey_rgbmax_off 72
paletteoff 76
imageoff 844
Close image Removes the currently-selected image from the screen and frees up its memory. Also erases the image's backup and its FFT if present.
DOS Command Shell to DOS to execute a command or run a different program. Or, to obtain a DOS command line, enter Command. Type Exit to return to tnimage. DOS requires a small amount of memory below 1 megabyte to exit commands. Thus an ``insufficient memory'' error could occur even if there is a lot of high memory.
This function is, of course, not available in the Unix version.
Quit
Return to operating system. Alt-X also can be used to quit.