Extra file format information
Image file formats often specify more information than is represented by CgDeviceIndependentImage. For example, image data in BMP format can either be uncompressed or compressed using run-length encoding. The application might need to know the data compression technique used by a loaded image's file so that the image can later be unloaded in the same way. The image file format objects preserve this extra information as part of their state when an image is loaded, and use this information when an image is unloaded. 
Each of the CgFileFormat classes provides format-specific methods to access and change the extra information. These methods are outlined in the following sections. 
Following these sections, an example illustrates how to manipulate extra information. 
GIF
aspect
Aspect ratio of the creating device 
background 
Background pixel value of the image 
extensions 
GIF89a control extensions of the image file 
screenExtent 
Point specifying the extent of the screen on which the image was created 
signature 
signature of the GIF file. Possible values are: 'GIF87a' and 'GIF89a 
transparentPixel 
Color index of the transparent pixel or nil if none 
JPEG
acHuffmanTables 
AC-component Huffman tables of the receiver 
app0 
Application defined segment of the receiver 
arithmeticCoding 
Arithmetic coding state (true or false) 
arithmeticTables 
Arithmetic conditioning tables 
bufferCurrentPosition 
Current position of the local data buffer 
byteStream 
Byte stream 
comments 
Comments 
dataBuffer 
Local data buffer
dcHuffmanTables
DC-component Huffman tables
errorHandler
Error handler
frameHeader
Frame header 
imageComponents
Image components
nextRestartNumber
Next restart number
quantizationTables
Quantization tables
restartInterval
Restart interval
restartsToGo
Restarts-to-go counter
scanHeader
Scan header
 
PCX
The following methods provide extra information preserved and used by the CgPCXFileFormat class: 
hRes 
Horizontal resolution of device 
paletteInfo 
How to interpret palette (color or gray scale) 
version 
Format version number 
vRes 
Vertical resolution of device 
PM BMP
The following methods provide extra information preserved and used by the CgPMBMPFileFormat class: 
colorEncode 
Color encoding scheme 
colorsUsed 
Number of colors used by the image 
compression 
Data compression algorithm used 
ident 
Application specific identifier 
importantColors 
Number of colors important for displaying image 
recording 
Recording algorithm used 
rendering 
Halftoning algorithm used 
resUnits 
Units of measure for xRes and yRes 
size1 
Halftoning correction factor 
size2 
Halftoning correction factor 
xRes 
Horizontal resolution of device 
yRes 
Vertical resolution of device 
TIFF
The following methods provide extra information preserved and used by the CgTIFFFileFormat class: 
colorScheme 
Color scheme (gray scale, palette, RGB) 
compression 
Data compression algorithm used 
predictor 
Prediction method, used with some types of compression 
Windows BMP
The following methods provide extra information preserved and used by the CgWinBMPFileFormat class: 
compression 
Data compression algorithm used 
importantColors 
Number of colors important for displaying image 
pelsPerMeter 
Horizontal and vertical resolution of device 
Example
The following code illustrates how to unload an image in Windows BMP format, using run-length encoding of the data if the image has a depth of 4 or 8. The device resolution and number of important colors are also specified. 
| image format |
image := self imageToUnload.
format := CgWinBMPFileFormat new.
format compression: 0.           "No compression by default."
image depth = 8
    ifTrue: [format compression: 1]. "RLE8 compression."
image depth = 4
    ifTrue: [format compression: 2]. "RLE4 compression."
format importantColors: (1 bitShift: image depth) - 3.
"All but 3 colors are important. Approx. 75 dots per inch."
format pelsPerMeter: 3000 @ 3000.     
format unload: image intoFile: 'img-out.bmp'