GEM VDI description excerpted from: ST Picture Formats ------------------ Edited by: David Baggett Internet: dmb@ai.mit.edu (Please report errors or additions.) Copyright (C) 1988 -- 1995 by David M. Baggett Non-profit redistribution of this document is permitted, provided the document is not modified in any way. Reproduction of this document in whole or in part for commercial purposes is expressly forbidden without the prior written consent of David M. Baggett. The information presented here is not guaranteed to be correct. The editor and contributors will in no event be liable for direct, indirect, incidental, or consequential damages resulting from the use of the information in this document. This document is the product of many hours of volunteer work by a large number of people. Please respect this -- do not violate the distribution policy. CONTRIBUTORS Steve Belczyk Phil Blanchfield Marcel Boom Jason Blochowiak John Brochu** David Brooks Daniel Deimert Martyn Dryden Neil Forsyth Stefan Hoehn Gerfried Klein G. "Maddog" Knauss Ken MacLeod Shamus McBride Jim McCabe Lars Michael Darek Mihocka David Mumper George Nassas Jim Omura Chris Ridd George Seto Joe Smith Greg Wageman Roland Waldi* Gerry Wheeler Introductory Information ------------------------ word = 2 bytes long = 4 bytes palette = Hardware color palette, stored as 16 words. First word is color register zero (background), last word is color register 15. Each word has the form: Bit: (MSB) 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 (LSB) -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 0 0 0 0 0 R2 R1 R0 0 G2 G1 G0 0 B2 B1 B0 R2 = MSB of red intensity R0 = LSB of red intensity G2 = MSB of green intensity G0 = LSB of green intensity B2 = MSB of blue intensity B0 = LSB of blue intensity Intensity ranges from 0 (color not present) to 7 (highest intensity). Example: { red = 7, green = 3, blue = 5 } -> 0735 (hex) Caveat: It is wise to mask off the upper four bits of each palette entry, since a few programs store special information there (e.g., Art Studio). *.GEM Marcel Boom recently sent me this format description. I have reproduced it here, largely unchanged. The file consists out of a header and the data records. The header has the following format: word mf_header: should be -1, which indicates a metafile word mf_hlength: The length of the header part (usually 24 words) word mf_version: Version number (usually 101) word mf_ndcrcfl: 0: NDC coordinates, 2: Raster coordinates word mf_extends1: Optional, minimal used x coordinate word mf_extends2: Optional, minimal used y coordinate word mf_extends3: Optional, maximal used x coordinate word mf_extends4: Optional, maximal used y coordinate word mf_width: Optional, page width in 0.1 mm word mf_height: Optional, page height in 0.1 mm word mf_coords1: Optional, coordinate system param 1 word mf_coords2: Optional, coordinate system param 2 word mf_coords3: Optional, coordinate system param 3 word mf_coords4: Optional, coordinate system param 4 word mf_imgflag: 0: No images, 1 contains bit images word mf_reserved1: reserved. . . word mf_reserved9: reserved. After the header follows the data records of the following format: word 0: VDI command number word 1: n: Number of parameters for ptsin array word 2: m: Number of parameters for intin array word 3: Subopcode word 4 to 4+n: ptsin array word 4+n to 4+n+m: intin array A VDI command number of -1 signals the end of file. VDI command numbers: 5: Escape functions: Subopcode: 1: Inquire addressable character cells 2: Exit alpha mode 3: Enter alpha mode 20: Form advance 21: Output window 22: Clear display list 23: Output bit image file 98: Update metafile extents 99: Write metafile item 100: Change GEM VDI filename 6: Polyline 7: Polymarker 8: Text 9: Filled area 11: GDP: subopcode: 1: Bar 2: Arc 3: Pie 4: Circle 5: Ellipse 6: Elliptical arc 7: Elliptical Pie 8: Rounded rectangle 9: Filled rounded rectangle 10: Jutified graphic text 12: Set character height, absolute mode 13: Set character baseline vector 14: Set color representation 15: Set polyline linetype 16: Set polyline line width 17: Set polyline color index 18: Set polymarker type 19: Set polymarker height 20: Set polymarker color index 21: Set text face 22: Set graphic text color index 23: Set fill interior style 24: Set fill style index 25: Set fill color index 26: Inquire color representation 32: Set writing mode 35: Inquire current polyline attributes 36: Inquire current polymarker attributes 37: Inquire current fill area attributes 38: Inquire current graphic text attributes 39: Set graphic text allignment 102: Extended inquire function 103: Countour fill 104: Set fill perimeter visibility 106: Set graphic text special effects 107: Set character cell height, points mode 108: Set polyline end styles 112: Set user defines fill pattern 113: Set user defined line style pattern 114: Fill rectangle 117: Inquire character cell width 129: Set clipping rectangle 131: Inquire current face information The meaning of the arrays can be found in the several GEM programming books. NOTE: The word qualifier is not the Motorola word, but the Intel word, so high and low byte are swapped! *.PAC (high resolution only) 4 bytes "pM86" (vertically packed) or "pM85" (horizontally packed) 1 byte id byte 1 byte pack byte (most frequently occuring byte in bitmap) 1 byte "special" byte ------- 7 bytes total for header ? bytes data The data is encoded as follows. For each byte x in the data section: x = id byte Read one more byte, n. Use pack byte n + 1 times. x = "special" byte Read two more bytes, d, and n (in order). Use byte d n times. otherwise Use byte x literally. *.IC1 (low resolution) *.IC2 (medium resolution) *.IC3 (high resolution) 4 bytes "IMDC" 1 word resolution (0 = low res, 1 = medium res, 2 = high res) 16 words palette 1 word date (GEMDOS format) 1 word time (GEMDOS format) 8 bytes name of base picture file (for delta compression), or zeroes 1 word length of data (?) 1 long registration number 8 bytes reserved 1 byte compressed? (0 = no, 1 = yes) If compressed { 1 byte delta-compressed? (-1 = no, > -1 = yes) 1 byte ? 1 byte escape byte } ------- 65 bytes total for header (68 bytes if compressed) ? bytes data Compressed data may be either stand-alone or delta-compressed (relative to the base picture named in the header). Delta compression involves storing only how the picture differs from the base picture (i.e., only portions of the screen that have changed are stored). This is used to to encode animated sequences efficiently. Compressed data, stand-alone: For each byte x in the data section: x = escape byte Read one more byte, n. (n is unsigned). If n >= 2, use the next byte n times. If n = 1, keep reading bytes until a byte k not equal to 1 is encountered. Then read the next byte d. If the number of 1 bytes encountered is o, use d (256 * o + k) times. I.e., if (n == 1) { o = 0; while (n == 1) { o++; n = next byte; } k = n; d = next byte; Use d (256 * o + k) times. } else { d = next byte; Use d (n) times. } x != escape byte Use x literally. Compressed data, delta compressed: For each byte x in the data section: x = escape byte Read one more byte, n. (n is unsigned). If n >= 3, use the next byte n times. If n = 1, do the same as for n = 1 in stand-alone compression (above). If n = 2, then set n = next byte. If n = 0, end of picture. If n >= 2, take n bytes from base picture. If n = 1, do the same as for n = 1 in stand-alone compression (above), but take (256 * o + k) bytes from base picture. x != escape byte Use x literally. * Roland Waldi contributed extensive information on the following formats: GEM, IMG, Doodle, STAD, Imagic Film/Picture, Art Director, IFF ** John Brochu, ST picture formats guru, provided sage advice and many corrections to the following formats: NeoChrome, DEGAS Elite Compressed, Spectrum 512 Compressed, GEM Bit Image, IFF, MacPaint Version of...........Sun Oct 30 12:40:13 EST 1994 (Last change: Extended GEM .IMG format updated)