| 1 | This is a copy of the document "ST Picture Formats" : [http://www.umich.edu/~archive/atari/Graphics/picfmts.doc picfmts.doc] |
| 2 | |
| 3 | We use it as a reference for implementing NEOchrome images support. |
| 4 | |
| 5 | The original document is enclosed in tags to prevent wiki formatting, but otherwise unmodified. |
| 6 | |
| 7 | {{{ |
| 8 | ST Picture Formats |
| 9 | ------------------ |
| 10 | Edited by: |
| 11 | |
| 12 | David Baggett |
| 13 | 5640 Vantage Point Road |
| 14 | Columbia, MD 21044 USA |
| 15 | (301) 596-4779 |
| 16 | (usenet: dmb@TIS.COM) |
| 17 | |
| 18 | (Please report errors or additions.) |
| 19 | |
| 20 | Copyright (C) 1988, 1989, 1990, 1991 by David M. Baggett |
| 21 | |
| 22 | |
| 23 | Non-profit redistribution of this document is permitted, provided |
| 24 | the document is not modified in any way. |
| 25 | |
| 26 | Reproduction of this document in whole or in part for commercial |
| 27 | purposes is expressly forbidden without the prior written consent |
| 28 | of David M. Baggett. |
| 29 | |
| 30 | The information presented here is not guaranteed to be correct. |
| 31 | The editor and contributors will in no event be liable for direct, |
| 32 | indirect, incidental, or consequential damages resulting from the |
| 33 | use of the information in this document. |
| 34 | |
| 35 | This document is the product of many hours of volunteer work by a |
| 36 | large number of people. Please respect this -- do not violate the |
| 37 | distribution policy. |
| 38 | |
| 39 | |
| 40 | CONTRIBUTORS |
| 41 | |
| 42 | Steve Belczyk Phil Blanchfield Jason Blochowiak John Brochu** |
| 43 | David Brooks Daniel Deimert Neil Forsyth Stefan Hoehn |
| 44 | Gerfried Klein Ken MacLeod Jim McCabe Darek Mihocka |
| 45 | David Mumper George Nassas George Seto Joe Smith |
| 46 | Greg Wageman Roland Waldi* Gerry Wheeler |
| 47 | |
| 48 | |
| 49 | Contents |
| 50 | -------- |
| 51 | |
| 52 | NEOchrome *.NEO |
| 53 | NEOchrome Animation *.ANI |
| 54 | DEGAS *.PI? ? = 1, 2, 3 |
| 55 | DEGAS Elite *.PI? ? = 1, 2, 3 |
| 56 | DEGAS Elite (Compressed) *.PC? ? = 1, 2, 3 |
| 57 | Tiny *.TN? ? = 1, 2, 3, Y |
| 58 | Spectrum 512 *.SPU |
| 59 | Spectrum 512 (Compressed) *.SPC |
| 60 | Art Director *.ART |
| 61 | C.O.L.R. Object Editor Mural *.MUR |
| 62 | Doodle *.DOO |
| 63 | Animatic Film *.FLM |
| 64 | GEM Bit Image *.IMG |
| 65 | STAD *.PAC |
| 66 | Imagic Film/Picture *.IC? ? = 1, 2, 3 |
| 67 | IFF *.IFF |
| 68 | MacPaint *.MAC |
| 69 | PackBits Compression Algorithm |
| 70 | |
| 71 | |
| 72 | Introductory Information |
| 73 | ------------------------ |
| 74 | word = 2 bytes |
| 75 | long = 4 bytes |
| 76 | palette = Hardware color palette, stored as 16 words. First word is |
| 77 | color register zero (background), last word is color register |
| 78 | 15. Each word has the form: |
| 79 | |
| 80 | Bit: (MSB) 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 (LSB) |
| 81 | -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- |
| 82 | 0 0 0 0 0 R2 R1 R0 0 G2 G1 G0 0 B2 B1 B0 |
| 83 | |
| 84 | R2 = MSB of red intensity |
| 85 | R0 = LSB of red intensity |
| 86 | |
| 87 | G2 = MSB of green intensity |
| 88 | G0 = LSB of green intensity |
| 89 | |
| 90 | B2 = MSB of blue intensity |
| 91 | B0 = LSB of blue intensity |
| 92 | |
| 93 | Intensity ranges from 0 (color not present) to 7 (highest |
| 94 | intensity). |
| 95 | |
| 96 | Example: { red = 7, green = 3, blue = 5 } -> 0735 (hex) |
| 97 | |
| 98 | Caveat: It is wise to mask off the upper four bits of each |
| 99 | palette entry, since a few programs store special |
| 100 | information there (most notably Art Studio). |
| 101 | |
| 102 | |
| 103 | The Formats |
| 104 | ----------- |
| 105 | |
| 106 | <NEOchrome> *.NEO |
| 107 | |
| 108 | 1 word flag byte [always 0] |
| 109 | 1 word resolution [0 = low res, 1 = medium res, 2 = high res] |
| 110 | 16 words palette |
| 111 | 12 bytes filename [usually " . "] |
| 112 | 1 word color animation limits. High bit (bit 15) set if color |
| 113 | animation data is valid. Low byte contains color animation |
| 114 | limits (4 most significant bits are left/lower limit, |
| 115 | 4 least significant bits are right/upper limit). |
| 116 | 1 word color animation speed and direction. High bit (bit 15) set |
| 117 | if animation is on. Low order byte is # vblanks per step. |
| 118 | If negative, scroll is left (decreasing). Number of vblanks |
| 119 | between cycles is |x| - 1 |
| 120 | 1 word # of color steps (as defined in previous word) to display |
| 121 | picture before going to the next. (For use in slide shows) |
| 122 | 1 word image X offset [unused, always 0] |
| 123 | 1 word image Y offset [unused, always 0] |
| 124 | 1 word image width [unused, always 320] |
| 125 | 1 word image height [unused, always 200] |
| 126 | 33 words reserved for future expansion |
| 127 | 16000 words picture data (screen memory) |
| 128 | ----------- |
| 129 | 32128 bytes total |
| 130 | |
| 131 | |
| 132 | <NEOchrome Animation> *.ANI |
| 133 | |
| 134 | NOTE: To get this feature on versions 0.9 and later select the Grabber |
| 135 | icon and click both mouse buttons in the eye of the second R in the |
| 136 | word GRABBER. |
| 137 | Interestingly enough, some versions of NEO only require you |
| 138 | to press the right button, not both. Hmmm... |
| 139 | |
| 140 | 1 long magic number BABEEBEA (hex) (seems to be ignored) |
| 141 | 1 word width of image in bytes (always divisible by 8) |
| 142 | 1 word height of image in scan lines |
| 143 | 1 word size of image in bytes + 10 (!) |
| 144 | 1 word x coordinate of image (must be divisible by 16) - 1 |
| 145 | 1 word y coordinate of image - 1 |
| 146 | 1 word number of frames |
| 147 | 1 word animation speed (# vblanks to delay between frames) |
| 148 | 1 long reserved; should be zero |
| 149 | -------- |
| 150 | 22 bytes total for header |
| 151 | |
| 152 | ? words image data (words of screen memory) for each frame, in |
| 153 | order |
| 154 | |
| 155 | |
| 156 | <DEGAS> *.PI1 (low resolution) |
| 157 | *.PI2 (medium resolution) |
| 158 | *.PI3 (high resolution) |
| 159 | |
| 160 | 1 word resolution (0 = low res, 1 = medium res, 2 = high res) |
| 161 | Other bits may be used in the future; use a simple bit |
| 162 | test rather than checking for specific word values. |
| 163 | 16 words palette |
| 164 | 16000 words picture data (screen memory) |
| 165 | ----------- |
| 166 | 32034 bytes total |
| 167 | |
| 168 | |
| 169 | <DEGAS Elite> *.PI1 (low resolution) |
| 170 | *.PI2 (medium resolution) |
| 171 | *.PI3 (high resolution) |
| 172 | |
| 173 | 1 word resolution (0 = low res, 1 = medium res, 2 = high res) |
| 174 | Other bits may be used in the future; use a simple bit |
| 175 | test rather than checking for specific word values. |
| 176 | 16 words palette |
| 177 | 16000 words picture data (screen memory) |
| 178 | 4 words left color animtion limit table (starting color numbers) |
| 179 | 4 words right color animation limit table (ending color numbers) |
| 180 | 4 words animation channel direction flag (0 = left, 1 = off, 2 = right) |
| 181 | 4 words 128 - animation channel delay in 1/60's of a second. [0 - 128] |
| 182 | (I.e., subtract word from 128 to get 1/60th's of a second.) |
| 183 | ----------- |
| 184 | 32066 bytes total |
| 185 | |
| 186 | |
| 187 | <DEGAS Elite (Compressed)> *.PC1 (low resolution) |
| 188 | *.PC2 (medium resolution) |
| 189 | *.PC3 (high resolution) |
| 190 | |
| 191 | 1 word resolution (same as Degas, but high order bit is set; |
| 192 | i.e., hex 8000 = low res, hex 8001 = medium res, |
| 193 | hex 8002 = high res). Other bits may be used in the |
| 194 | future; use a simple bit test rather than checking |
| 195 | for specific word values. |
| 196 | 16 words palette |
| 197 | < 32000 bytes control/data bytes |
| 198 | 4 words left color animation limit table (starting color numbers) |
| 199 | 4 words right color animation limit table (ending color numbers) |
| 200 | 4 words animation channel direction flag [0 = left, 1 = off, 2 = right] |
| 201 | 4 words 128 - animation channel delay in 1/60's of a second. [0 - 128] |
| 202 | (I.e., subtract word from 128 to get 1/60th's of a second.) |
| 203 | ----------- |
| 204 | < 32066 bytes total |
| 205 | |
| 206 | Compression Scheme: |
| 207 | |
| 208 | PackBits compression is used (see below). Each scan line is compressed |
| 209 | separately; i.e., all data for a given scan line appears before any data |
| 210 | for the next scan line. The scan lines are specified from top to bottom |
| 211 | (i.e., 0 is first). For each scan line, all the data for a given bit plane |
| 212 | appears before any data for the next higher order bit plane. Note this is |
| 213 | identical to the IFF 'BODY' image data. |
| 214 | To clarify: The first data in the file will be the data for the lowest |
| 215 | order bit plane of scan line zero, followed by the data for the next higher |
| 216 | order bit plane of scan line zero, etc., until all bit planes have been |
| 217 | specified for scan line zero. The next data in the file will be the data |
| 218 | for the lowest order bit plane of scan line one, followed by the data for |
| 219 | the next higher order bit plane of scan line one, etc., until all bit planes |
| 220 | have been specified for all scan lines. |
| 221 | |
| 222 | Caveats: |
| 223 | |
| 224 | DEGAS Elite's picture loading routine places some restrictions on |
| 225 | compressed DEGAS files: |
| 226 | |
| 227 | o Elite uses a 40-byte buffer to store data being decompressed. |
| 228 | |
| 229 | o Whenever a control command is encountered, bytes are stuffed |
| 230 | in this buffer. |
| 231 | |
| 232 | o The buffer is only emptied when there are EXACTLY 40 |
| 233 | characters in it. |
| 234 | |
| 235 | The important conclusion here is that |
| 236 | |
| 237 | No control command may cause the buffer to have more than 40 |
| 238 | bytes in it. In other words, all control commands must end on |
| 239 | or before the 40-byte boundary. |
| 240 | |
| 241 | Any picture violating the last condition will cause Elite to get a bus |
| 242 | error when the picture is loaded. |
| 243 | |
| 244 | |
| 245 | <Tiny> *.TNY (any resolution) |
| 246 | *.TN1 (low resolution) |
| 247 | *.TN2 (medium resolution) |
| 248 | *.TN3 (high resolution) |
| 249 | |
| 250 | Several people have reported sightings of mutated Tiny pictures that |
| 251 | do not follow the standard format, so let's be careful out there. What |
| 252 | is described here is the format that David Mumper's original |
| 253 | TNYSTUFF.PRG produces. |
| 254 | |
| 255 | 1 byte resolution (same as NEO, but +3 indicates rotation |
| 256 | information also follows) |
| 257 | |
| 258 | If resolution > 2 { |
| 259 | 1 byte left and right color animation limits. High 4 bits |
| 260 | hold left (start) limit; low 4 bits hold right (end) |
| 261 | limit |
| 262 | 1 byte direction and speed of color animation (negative value |
| 263 | indicates left, positive indicates right, absolute value |
| 264 | is delay in 1/60's of a second. |
| 265 | 1 word color rotation duration (number of iterations) |
| 266 | } |
| 267 | |
| 268 | 16 words palette |
| 269 | 1 word number of control bytes |
| 270 | 1 word number of data words |
| 271 | 3-10667 bytes control bytes |
| 272 | 1-16000 words data words |
| 273 | ------------- |
| 274 | 42-32044 bytes total |
| 275 | |
| 276 | Control byte meanings: |
| 277 | |
| 278 | For a given control byte, x: |
| 279 | |
| 280 | x < 0 Absolute value specifies the number of unique words to |
| 281 | take from the data section (from 1 to 127) |
| 282 | x = 0 1 word is taken from the control section which specifies |
| 283 | the number of times to repeat the next data word (from |
| 284 | 128 to 32767) |
| 285 | x = 1 1 word is taken from the control section which specifies |
| 286 | the number of unique words to be taken from the data |
| 287 | section (from 128 - 32767) |
| 288 | x > 1 Specifies the number of times to repeat the next word |
| 289 | taken from the data section (from 2 to 127) |
| 290 | |
| 291 | Format of expanded data: |
| 292 | |
| 293 | The expanded data is not simply screen memory bitmap data; instead, the |
| 294 | data is divided into four sets of vertical columns. (This results in |
| 295 | better compression.) A column consists of one specific word taken |
| 296 | from each scan line, going from top to bottom. For example, column 1 |
| 297 | consists of word 1 on scanline 1 followed by word 1 on scanline 2, etc., |
| 298 | followed by word 1 on scanline 200. |
| 299 | The columns appear in the following order: |
| 300 | |
| 301 | 1st set contains columns 1, 5, 9, 13, ..., 69, 73, 77 in order |
| 302 | 2nd set contains columns 2, 6, 10, 14, ..., 70, 74, 78 in order |
| 303 | 3rd set contains columns 3, 7, 11, 15, ..., 71, 75, 79 in order |
| 304 | 4th set contains columns 4, 8, 12, 16, ..., 72, 76, 80 in order |
| 305 | |
| 306 | Note that Tiny partitions the screen this way regardless of resolution; i.e., |
| 307 | these aren't bitplanes. For example, medium resoltion only has two bitplanes, |
| 308 | but Tiny still divides medium resolution pictures into four parts. |
| 309 | |
| 310 | |
| 311 | <Spectrum 512> *.SPU |
| 312 | |
| 313 | 80 words first scan line of picture (unused) -- should be zeroes |
| 314 | 15920 words picture data (screen memory) for scan lines 1 through 199 |
| 315 | 9552 words 3 palettes for each scan line (the top scan line is |
| 316 | not included because Spectrum 512 can't display it) |
| 317 | ----------- |
| 318 | 51104 bytes total |
| 319 | |
| 320 | Note that the Spectrum 512 mode's three palette changes per scan |
| 321 | line allow more colors on the screen than normally possible, but a |
| 322 | tremendous amount of CPU time is required to maintain the image. |
| 323 | |
| 324 | The Spectrum format specifies a palette of 48 colors for each scan line. |
| 325 | To decode a Spectrum picture, one must be know which of these 48 colors |
| 326 | are in effect for a given horizontal pixel position. |
| 327 | |
| 328 | Given an x-coordinate (from 0 to 319) and a color index (from 0 to 15), |
| 329 | the following C function will return the proper index into the Spectrum |
| 330 | palette (from 0 to 47): |
| 331 | |
| 332 | /* |
| 333 | * Given an x-coordinate and a color index, returns the corresponding |
| 334 | * Spectrum palette index. |
| 335 | * |
| 336 | * by Steve Belczyk; placed in the public domain December, 1990. |
| 337 | */ |
| 338 | int |
| 339 | FindIndex(x, c) |
| 340 | int x, c; |
| 341 | { |
| 342 | int x1; |
| 343 | |
| 344 | x1 = 10 * c; |
| 345 | |
| 346 | if (1 & c) /* If c is odd */ |
| 347 | x1 = x1 - 5; |
| 348 | else /* If c is even */ |
| 349 | x1 = x1 + 1; |
| 350 | |
| 351 | if (x >= x1 && x < x1 + 160) |
| 352 | c = c + 16; |
| 353 | else if (x >= x1 + 160) |
| 354 | c = c + 32; |
| 355 | |
| 356 | return c; |
| 357 | } |
| 358 | |
| 359 | |
| 360 | <Spectrum 512 (Compressed)> *.SPC |
| 361 | |
| 362 | 1 word flag word [$5350 or "SP"] |
| 363 | 1 word reserved for future use [always 0] |
| 364 | 1 long length of data bit map |
| 365 | 1 long length of color bit map |
| 366 | <= 32092 bytes compressed data bit map |
| 367 | <= 17910 bytes compressed color bit map |
| 368 | -------------- |
| 369 | <= 50014 bytes total |
| 370 | |
| 371 | Data compression: |
| 372 | |
| 373 | Compression is via a modified run length encoding (RLE) scheme, |
| 374 | similar to DEGAS compressed and Tiny. The data map is stored as a |
| 375 | sequence of records. Each record consists of a header byte followed by |
| 376 | one or more data bytes. The meaning of the header byte is as follows: |
| 377 | |
| 378 | For a given header byte, x: |
| 379 | |
| 380 | 0 <= x <= 127 Use the next x + 1 bytes literally (no repetition) |
| 381 | -128 <= x <= -1 Use the next byte -x + 2 times |
| 382 | |
| 383 | The data appears in the following order: |
| 384 | |
| 385 | 1. Picture data, bit plane 0, scan lines 1 - 199 |
| 386 | 2. Picture data, bit plane 1, scan lines 1 - 199 |
| 387 | 3. Picture data, bit plane 2, scan lines 1 - 199 |
| 388 | 4. Picture data, bit plane 3, scan lines 1 - 199 |
| 389 | |
| 390 | Decompression of data ends when 31840 data bytes have been used. |
| 391 | |
| 392 | Color map compression: |
| 393 | |
| 394 | Each 16-word palette is compressed separately. There are three |
| 395 | palettes for each scan line (597 total). The color map is stored as a |
| 396 | sequence of records. Each record starts with a 1-word bit vector which |
| 397 | specifies which of the 16 palette entries are included in the data |
| 398 | following the bit vector (1 = included, 0 = not included). If a palette |
| 399 | entry is not included, it is assumed to be zero (black). The least |
| 400 | significant bit of the bit vector refers to palette entry zero, while the |
| 401 | most significant bit refers to palette entry 15. Bit 15 must be zero, |
| 402 | since Spectrum 512 does not use palette entry 15. Bit 0 should also be |
| 403 | zero, since Spectrum 512 always makes the background color black. |
| 404 | The words specifying the values for the palette entries indicated in |
| 405 | the bit vector follow the bit vector itself, in order (0 - 15). |
| 406 | |
| 407 | |
| 408 | <Art Director> *.ART (low resolution only) |
| 409 | |
| 410 | 16000 words picture data (screen memory) |
| 411 | 16 words palette |
| 412 | 15 * 16 words 15 more palettes for animation |
| 413 | ------------- |
| 414 | 32512 bytes total |
| 415 | |
| 416 | |
| 417 | <C.O.L.R. Object Editor Mural> *.MUR (low resolution only) |
| 418 | |
| 419 | 16000 words picture data (screen memory) |
| 420 | (palettes are stored in separate files) |
| 421 | ----------- |
| 422 | 32000 bytes total |
| 423 | |
| 424 | |
| 425 | <Doodle> *.DOO (high resolution only) |
| 426 | |
| 427 | 16000 words picture data (screen memory) |
| 428 | ----------- |
| 429 | 32000 bytes total |
| 430 | |
| 431 | |
| 432 | <Animatic Film> *.FLM (low resolution only) |
| 433 | |
| 434 | 1 word number of frames |
| 435 | 16 words palette |
| 436 | 1 word speed (0 - 99; value is 99 - # vblanks to delay between frames) |
| 437 | 1 word direction (0 = forwards, 1 = backwards) |
| 438 | 1 word end action (what to do after the last frame) |
| 439 | 0 = pause, then repeat from beginning |
| 440 | 1 = immediately repeat from beginning |
| 441 | 2 = reverse (change direction) |
| 442 | 1 word width of film in pixels |
| 443 | 1 word height of film in pixels |
| 444 | 1 word Animatic version number (major) |
| 445 | 1 word Animatic version number (minor) |
| 446 | 1 long magic number 27182818 (hex) |
| 447 | 3 longs reserved for expansion (should be all zeros) |
| 448 | -------- |
| 449 | 32 words total for header |
| 450 | |
| 451 | ? words image data (words of screen memory) for each frame, in order |
| 452 | |
| 453 | |
| 454 | <GEM Bit Image> *.IMG |
| 455 | |
| 456 | 1 word version number of image file [1] |
| 457 | 1 word length of header in words [usually 8] |
| 458 | 1 word number of color planes [1 for monochrome] |
| 459 | 1 word pattern length in bytes [1-8, usually 2 for screen images] |
| 460 | 1 word pixel width in microns (1/1000 mm, 25400 microns per inch) |
| 461 | 1 word pixel height in microns |
| 462 | 1 word line width in pixels |
| 463 | 1 word number of lines |
| 464 | ------- |
| 465 | ? words header length defined in 2nd word of header |
| 466 | |
| 467 | ? bytes data |
| 468 | |
| 469 | NOTES: If the image is a color image (planes > 1), the planes are stored |
| 470 | separately starting with plane 0. There is, however, no standard way of |
| 471 | storing the color palette. Some programs may save the palette in separate |
| 472 | files, some may extend the header. For this reason, you should never |
| 473 | assume the header is 8 words long, always get the header length from the |
| 474 | 2nd word of the header. Also, the line width in the 7th word is the number |
| 475 | of pixels in a line. Since the data is encoded in byte-wide packets, the |
| 476 | actual unpacked line width is always a multiple of 8, and may be 1-7 pixels |
| 477 | longer than the length specified in the header. |
| 478 | |
| 479 | For each byte x in the data section, |
| 480 | |
| 481 | x = 0 Pattern/scanline run. |
| 482 | Read the next byte, n (unsigned). |
| 483 | |
| 484 | If n > 0 then: |
| 485 | Read a number of bytes equal to the "pattern |
| 486 | length" word in the header. Repeat this |
| 487 | pattern n times. |
| 488 | |
| 489 | If n = 0 then: |
| 490 | Scanline run. Data for the next scanline |
| 491 | is to be used multiple times. Read the |
| 492 | following record: |
| 493 | |
| 494 | 1 byte flag byte [$FF] |
| 495 | 1 byte number of times to use |
| 496 | next scanline data |
| 497 | |
| 498 | The data for the next scanline follows, |
| 499 | compressed normally. |
| 500 | |
| 501 | x = 80 (hex) Uncompressed bit string. The next byte |
| 502 | determines the number of bytes to use |
| 503 | literally. The literal data bytes follow. |
| 504 | |
| 505 | otherwise Solid run. The value of x determines |
| 506 | what to draw. The high bit specifies whether |
| 507 | the pixels are set or cleared. A 1 indicates |
| 508 | a byte-run using $FF, a 0 indicates a byte-run |
| 509 | using $00. The low 7 bits, taken as an unsigned |
| 510 | quantity, specify the length of the run in bytes. |
| 511 | |
| 512 | |
| 513 | <STAD> *.PAC (high resolution only) |
| 514 | |
| 515 | 4 bytes "pM86" (vertically packed) or "pM85" (horizontally packed) |
| 516 | 1 byte id byte |
| 517 | 1 byte pack byte (most frequently occuring byte in bitmap) |
| 518 | 1 byte "special" byte |
| 519 | ------- |
| 520 | 7 bytes total for header |
| 521 | |
| 522 | ? bytes data |
| 523 | |
| 524 | The data is encoded as follows. For each byte x in the data section: |
| 525 | |
| 526 | x = id byte Read one more byte, n. Use pack byte |
| 527 | n + 1 times. |
| 528 | x = "special" byte Read two more bytes, d, and n (in order). |
| 529 | Use byte d n times. |
| 530 | otherwise Use byte x literally. |
| 531 | |
| 532 | |
| 533 | <Imagic Film/Picture> *.IC1 (low resolution) |
| 534 | *.IC2 (medium resolution) |
| 535 | *.IC3 (high resolution) |
| 536 | |
| 537 | 4 bytes "IMDC" |
| 538 | 1 word resolution (0 = low res, 1 = medium res, 2 = high res) |
| 539 | 16 words palette |
| 540 | 1 word date (GEMDOS format) |
| 541 | 1 word time (GEMDOS format) |
| 542 | 8 bytes name of base picture file (for delta compression), or zeroes |
| 543 | 1 word length of data (?) |
| 544 | 1 long registration number |
| 545 | 8 bytes reserved |
| 546 | 1 byte compressed? (0 = no, 1 = yes) |
| 547 | |
| 548 | If compressed { |
| 549 | 1 byte delta-compressed? (-1 = no, > -1 = yes) |
| 550 | 1 byte ? |
| 551 | 1 byte escape byte |
| 552 | } |
| 553 | ------- |
| 554 | 65 bytes total for header (68 bytes if compressed) |
| 555 | |
| 556 | ? bytes data |
| 557 | |
| 558 | Compressed data may be either stand-alone or delta-compressed (relative |
| 559 | to the base picture named in the header). Delta compression involves |
| 560 | storing only how the picture differs from the base picture (i.e., only |
| 561 | portions of the screen that have changed are stored). This is used to |
| 562 | to encode animated sequences efficiently. |
| 563 | |
| 564 | Compressed data, stand-alone: |
| 565 | |
| 566 | For each byte x in the data section: |
| 567 | |
| 568 | x = escape byte Read one more byte, n. (n is unsigned). |
| 569 | |
| 570 | If n >= 2, use the next byte n times. |
| 571 | If n = 1, keep reading bytes until a |
| 572 | byte k not equal to 1 is encountered. |
| 573 | Then read the next byte d. |
| 574 | If the number of 1 bytes encountered is o, |
| 575 | use d (256 * o + k) times. I.e., |
| 576 | |
| 577 | if (n == 1) { |
| 578 | o = 0; |
| 579 | while (n == 1) { |
| 580 | o++; |
| 581 | n = next byte; |
| 582 | } |
| 583 | |
| 584 | k = n; |
| 585 | d = next byte; |
| 586 | |
| 587 | Use d (256 * o + k) times. |
| 588 | } |
| 589 | else { |
| 590 | d = next byte; |
| 591 | Use d (n) times. |
| 592 | } |
| 593 | |
| 594 | x != escape byte Use x literally. |
| 595 | |
| 596 | Compressed data, delta compressed: |
| 597 | |
| 598 | For each byte x in the data section: |
| 599 | |
| 600 | x = escape byte Read one more byte, n. (n is unsigned). |
| 601 | |
| 602 | If n >= 3, use the next byte n times. |
| 603 | If n = 1, do the same as for n = 1 in |
| 604 | stand-alone compression (above). |
| 605 | If n = 2, then set n = next byte. |
| 606 | If n = 0, end of picture. |
| 607 | If n >= 2, take n bytes from base |
| 608 | picture. |
| 609 | If n = 1, do the same as for n = 1 |
| 610 | in stand-alone compression (above), |
| 611 | but take (256 * o + k) bytes from |
| 612 | base picture. |
| 613 | |
| 614 | x != escape byte Use x literally. |
| 615 | |
| 616 | |
| 617 | <IFF Format> *.IFF |
| 618 | |
| 619 | 4 bytes "FORM" (FORM chunk ID) |
| 620 | 1 long length of file that follows |
| 621 | 4 bytes "ILBM" (InterLeaved BitMap file ID) |
| 622 | |
| 623 | 4 bytes "BMHD" (BitMap HeaDer chunk ID) |
| 624 | 1 long length of chunk [20] |
| 625 | 20 bytes 1 word = image width in pixels |
| 626 | 1 word = image height in lines |
| 627 | 1 word = image x-offset [usually 0] |
| 628 | 1 word = image y-offset [usually 0] |
| 629 | 1 byte = # bitplanes |
| 630 | 1 byte = mask (0=no, 1=impl., 2=transparent, 3=lasso) |
| 631 | 1 byte = compressed [1] or uncompressed [0] |
| 632 | 1 byte = unused [0] |
| 633 | 1 word = transparent color (for mask=2) |
| 634 | 1 byte = x-aspect [5=640x200, 10=320x200/640x400, 20=320x400] |
| 635 | 1 byte = y-aspect [11] |
| 636 | 1 word = page width (usually the same as image width) |
| 637 | 1 word = page height (usually the same as image height) |
| 638 | |
| 639 | 4 bytes "CMAP" (ColorMAP chunk ID) |
| 640 | 1 long length of chunk [3*n where n is the # colors] |
| 641 | 3n bytes 3 bytes per RGB color. Each color value is a byte |
| 642 | and the actual color value is left-justified in the |
| 643 | byte such that the most significant bit of the value |
| 644 | is the MSB of the byte. (ie. a color value of 15 ($0F) |
| 645 | is stored as $F0) The bytes are stored in R,G,B order. |
| 646 | |
| 647 | 4 bytes "CRNG" (Color RaNGe chunk ID) |
| 648 | 1 long length of chunk [8] |
| 649 | 8 bytes 1 word = reserved [0] |
| 650 | 1 word = animation speed (16384 = 60 steps per second) |
| 651 | 1 word = active [1] or inactive [0] |
| 652 | 1 byte = left/lower color animation limit |
| 653 | 1 byte = right/upper color animation limit |
| 654 | |
| 655 | 4 bytes "CAMG" (Commodore AMiGa viewport mode chunk ID) |
| 656 | 1 long length of chunk [4] |
| 657 | 1 long viewport mode bits (bit 11 = HAM, bit 3 = interlaced) |
| 658 | |
| 659 | 4 bytes "BODY" (BODY chunk ID) |
| 660 | 1 long length of chunk [# bytes of image data that follow] |
| 661 | ? bytes actual image data |
| 662 | |
| 663 | NOTES: Some of these chunks may not be present in every IFF file, and may |
| 664 | not be in this order. You should always look for the ID bytes to find a |
| 665 | certain chunk. All chunk IDs are followed by a long value that tells the |
| 666 | size of the chunk. This is the number of bytes that FOLLOW the 4 ID bytes |
| 667 | and size longword. The exception to this is the FORM chunk. The size |
| 668 | longword that follows the FORM ID is the size of the remainder of the file. |
| 669 | The FORM chunk must always be the first chunk in an IFF file. |
| 670 | |
| 671 | The R,G,B ranges of AMIGA and ST are different (AMIGA 0...15, ST 0...7), |
| 672 | as is the maximum number of bitplanes (AMIGA: 5, ST: 4). |
| 673 | |
| 674 | Format of body data |
| 675 | |
| 676 | An expanded picture is simply a bitmap. The packing method is PackBits |
| 677 | (see below), and is identical to MacPaint and DEGAS Elite compressed. |
| 678 | |
| 679 | The (decompressed) body data appears in the following order: |
| 680 | |
| 681 | line 1 plane 0 ... line 1 plane 1 ... ... line 1 plane m |
| 682 | [line 1 mask (if appropriate)] |
| 683 | line 2 plane 0 ... line 2 plane 1 ... ... line 2 plane m |
| 684 | [line 2 mask (if appropriate)] |
| 685 | ... |
| 686 | line x plane 0 ... line x plane 1 ... ... line x plane m |
| 687 | [line x mask (if appropriate)] |
| 688 | |
| 689 | The FORM chunk identifies the type of data: |
| 690 | |
| 691 | "ILBM" = interleaved bit map |
| 692 | "8SVX" = 8-bit sample voice |
| 693 | "SMUS" = simple music score |
| 694 | "FTXT" = formatted text (Amiga) |
| 695 | |
| 696 | |
| 697 | <MacPaint> *.MAC |
| 698 | |
| 699 | 1 long version number [0=ignore header, 2=header valid] |
| 700 | 38 * 8 bytes 8x8 brush/fill patterns. Each byte is a pattern row, |
| 701 | and the bytes map the pattern rows top to bottom. The |
| 702 | patterns are stored in the order they appear at the bottom |
| 703 | of the MacPaint screen top to bottom, left to right. |
| 704 | 204 bytes unused |
| 705 | ------------- |
| 706 | 512 bytes total for header |
| 707 | |
| 708 | < 51200 bytes compressed bitmap data |
| 709 | ------------- |
| 710 | < 51712 bytes total |
| 711 | |
| 712 | NOTE: The version number is actually a flag to MacPaint to indicate if |
| 713 | the brush/fill patterns are present in the file. If the version is 0, |
| 714 | the default patterns are used. Therefore you can simply save a MacPaint |
| 715 | file by writing a blank header (512 $00 bytes), followed by the packed |
| 716 | image data. |
| 717 | |
| 718 | Bitmap compression: |
| 719 | |
| 720 | The bitmap data is for a 576 pixel by 720 pixel monochrome image. |
| 721 | The packing method is PackBits (see below). There are 72 bytes per |
| 722 | scan line. Each bit represents one pixel; 0 = white, 1 = black. |
| 723 | |
| 724 | |
| 725 | <PackBits Compression Algorithm> |
| 726 | |
| 727 | The following packing algorithm originated on the Mac, was adopted by |
| 728 | Electronic Arts/Commodore for use in the IFF standard, and then by Tom |
| 729 | Hudson for use in DEGAS Elite. The algorithm is currently used in |
| 730 | MacPaint, IFF, and DEGAS Elite compressed file formats. Each scan line |
| 731 | is packed separately, and packing never extends beyond a scan line. |
| 732 | |
| 733 | For a given control byte 'n': |
| 734 | 0 <= n <= 127 : use the next n + 1 bytes literally (no repetition). |
| 735 | -127 <= n <= -1 : use the next byte -n + 1 times. |
| 736 | n = -128 : no operation, not used. |
| 737 | |
| 738 | ------------------------------------------------------------------------- |
| 739 | |
| 740 | * Roland Waldi contributed extensive information on the following formats: |
| 741 | |
| 742 | GEM, IMG, Doodle, STAD, Imagic Film/Picture, Art Director, IFF |
| 743 | |
| 744 | ** John Brochu, ST picture formats guru, provided sage advice and many |
| 745 | corrections to the following formats: |
| 746 | |
| 747 | NeoChrome, DEGAS Elite Compressed, Spectrum 512 Compressed, |
| 748 | GEM Bit Image, IFF, MacPaint |
| 749 | |
| 750 | Version of Wed Dec 19 11:20:55 EST 1990 |
| 751 | Cosmetic changes Tue Jan 29 00:17:51 EST 1991 |
| 752 | }}} |