INSET PIX FILE SPECIFICATION Introduction This document containts a description of InSet PIX files for use with the Inset technology products such as InSet and HiJaak. The Inset PIX files were designed with the following considerations in mind: o Ability to access compressed portions of images in a random manner o Open design for adding new information without obsoleting old files o Device independence Currently PIX files primarily contain either bit mapped image data or alpha-numeric screens with attribute information. However, since the file structure is open, new data types may be added to the file at a later time without changing the basic file structure. In the PIX File Structure section, the actual structure of the PIX file is laid out. Later sections provide more detail in the areas of data compression, data structures, and definitions. PIX File Structure PIX files can be described as an indexed database of data items. Data items may contain any information pertaining to the image. Data items currently found in PIX files include: o Image information (size, type, origin, colors etc.) o Printing options such as clipping, size, rotation, etc. o Color Pallete information o Image tiles (compressed sections of the image) o Information on how the image is sectioned into tiles The size and location of each of these data items is contained in a table in the beginning of each PIX file. To find a particular item, the index table is scanned for a matching Item ID to obtain the item location and size. The structure of the PIX file header and index table as well as the Item IDs and data structures are provided in the following sections. Pix File Header At the begining of the PIX file are two words. The first word contains the revision level of the PIX file which is currently 3. The second word contains the number of Item Records in the index table. Following this brief header is the index table containing an array of item record structures. These structures are defined in C as: struct Item_Rec { unsigned app_id; /* Application Id # */ unsigned app_len; /* Length of application data */ long app_loc; /* Location in file of app data */ }; To obtain a data item, you search through this array of records for a matching app_id structure which then contains the location and length of the item. Empty item records contain an app_id=-1. Image Information The application ID for the image structure is 0. This data item contains information on the overall image size, type, and origin of the image. The structure (in C) of this data item is: struct mode_data { unsigned char hmode; unsigned char htype; unsigned char cfore; unsigned char cback; unsigned char tattr; unsigned char tcpr; unsigned char trows; unsigned char thfnts; unsigned char tlfnts; unsigned char tcpf; unsigned int tfsize[4]; unsigned int gcols; unsigned int grows; unsigned char gfore; unsigned char prepal; unsigned char lodpal; unsigned char lintens; unsigned char lred; unsigned char lgreen; unsigned char lblue; unsigned char pages; unsigned char haspect; unsigned char vaspect; }; Following is a description of each member of this structure: hmode Hardware specific mode. 0 if not specifically related to a specific hardware mode of a board. htype Hardware type. Bit 0=0 if alphanumeric and Bit 0=1 if bit map graphics. Board types are ORed into this byte. Board types include: 8=CGA 16=Hercules 24=EGA cfore Text foreground color bits (ignore if graphics) 4 for CGA tattr Text background color bits (ignore if graphics) 3 for CGA tcpr Text characters per row (ignore if graphics) trows Text rows (ignore if graphics) thfnts Text hardware fonts (not used) tlfnts Text loadable fonts (not used) tcpf Text characters per font (Not used). tfsize Font size (not used). gcols Graphics columns grows Graphics rows gfore Graphics foreground color bits prepal Number of preset pallettes (default to 0) lodpal Number of loadable pallettes lintens Number of pallette bits for intesity lred Number of pallette bits for red lgreen Number of pallette bits for green lblue Number of pallette bits for blue pages Number of possible pages (not used) haspect Horizontal component of aspect ratio (number of horizontal pixels to fit in a square) vaspect Vertical component of aspect ratio (number of vertical pixels to fit in a square) A sample image structure for 600 rows by 800 columns single bit plane image might be initialized as follows: struct mode_data { unsigned char hmode=0; unsigned char htype=1; unsigned char cfore=0; unsigned char cback=0; unsigned char tattr=0; unsigned char tcpr=80; unsigned char trows=25; unsigned char thfnts=0; unsigned char tlfnts=0; unsigned char tcpf=0; unsigned int tfsize[4]=0; unsigned int gcols=800; unsigned int grows=600; unsigned char gfore=1; unsigned char prepal=0; unsigned char lodpal=0; unsigned char lintens=1; unsigned char lred=0; unsigned char lgreen=0; unsigned char lblue=0; unsigned char pages=0; unsigned char haspect=1; unsigned char vaspect=1; }; Printing Options The application ID for InSet Printing options is 11 Hexidecimal. The C structure containing these items follows: struct prt_options { int pitch, scol, ecol, srow, erow, p_wid, siz, rotat, do_sw; res_1, res_2, pcolor, row_dp, col_dp, flags; char ink_tab[16]; }; pitch Printer Pitch divided by 10 (e.g. 100 = 10 pitch) (not required, set to 100) scol Start column clip boundary ecol End column clip boundary srow Start row clip boundary erow End row clip boundary p_wid Printer width (not required, set to 0) size Size (not used, set to 0) rotat Rotation (0=Horizontal, -1=Left, 1=Right) do_sw Option Bits ORed. Applicable bits to set include: Double Pass |= 2 Letter Quality |= 4 Border On |= 10 (Hex) res_1 res_2 Internal Use (don't use, set to 0) pcolor Low order byte indicates whether the image setting are intended for color printer (True=1, False=0) High order byte is a selects which dither pattern type to use ( 0=Old, 1=Gray, 2=Contrast). row_dp Height of image in Decipoints (1/720 inches) col_dp Width of image in Decipoints (1/720 inches) flags Modify flags Size option bits: #define INDATA_USE_COL 0x1 #define INDATA_USE_INCH 0x2 #define INDATA_USE_DP 0x3 Modify/Ink Selection: #define INDATA_INK_INV 0x8 #define INDATA_INK_BW 0x10 #define INDATA_INK_TAB 0x18 #define INDATA_VDISK 0x20 #define INDATA_VSIZE 0x40 #define INDATA_DYNAMIC 0x80 ink_tab 16 byte table mapping screen colors to printer colors/gray patterns (see the MODIFY/INKS section of the InSet manual for more information on ink tables). If you want to select your own Ink table mapping the flags variable must have a 0x18 or'ed in. Preset InSet Ink tables are set as follows: Color Number 0 1 2 3 4 5 6 7 8 9 A B C D E F _____________________________________________________ Standard F 1 2 3 4 5 6 7 8 9 A B C D E 0 Invert 0 1 2 3 4 5 6 7 8 9 A B C D E F B&W F 0 0 0 0 0 0 0 F 0 0 0 0 0 0 0 Pallette Data Application ID=1 contains display pallette information. Pallette information is stored in an array of pallette structures of the following form: struct pallette { char intens, red, green, blue; }; The number of significant pallette items in the array is determined by the number of available colors (gfore in the image data structure) in the image. The significant bits are determined by the lintens lred lgreen, and lblue items in the modedata structure. Tile Information Information as to how the image is broken down into tiles is contained in the data item with ID=2. This structure follows: struct Tile_Data { unsigned page_rows; unsigned page_cols; unsigned stp_rows; unsigned stp_cols; }; page_rows Number of rows within each tile. page_cols Number of columns in each tile (must be divisible by 8) stp_rows Number of horizontal tile strips within the image stp_cols Number of vertical tile strips Each tile is limited to a maximum of 4096 bytes of uncompressed data. The actual tiles are numbered starting with the upper left row as tile 0 and incremented from left to right as illustrated below. --------------- | 0 | 1 | 2 | 3 | |--------------- | 4 | 5 | 6 | 7 | |---------------| | 8 | 9 | A | B | --------------- The ID of a tile is the tile number ORed with a Hex 8000. For example, the lower right tile can be found by finding the record with ID=800B (Hex). Images may be broken down into a checker board sections or Horizontal strips. However, if the image is broken into horizontal strips processing the image as rotated by InSet will be slowed. Pixel Tiles Each individual Pixel tile ID is determined by ORing in Hex 8000 with the tile number as described in the preceding tile information section. The image is organized into bitplanes with 8 Pixels per byte with the most significant bit containing the left-most pixel. For multiple bit plane images, all scan lines for a plane are written out before the scan lines in the next plane. If the actual column boundary of the tile exceeds the column bounds of the image it is padded with blank bytes to fill out the tile. If the actual row bound of the tile exceeds the image, the extra rows are not present. When the tile is store on disk it is in compressed format using a vertical compression technique. The first scan line of each tile is written out with no modification. Then before the following scan lines there are compression bytes which indicate which bytes in the scan line are differrent than the preceding line. Each bit in the compression byte indicates whether a particular byte in that scan has changed (1 if changed, 0 if not). Then following the compression bytes, only the modified scan bytes are written to the file. For example, if we had a tile that was 8 colomns wide and the first scan line was all blank and there was a dot at the beginning and end of the second scan line it would be written to disk as follows: 00 00 00 00 00 00 00 00 <- First Scan Line 81 80 01 <- Changed Bytes ^ | Compression Byte In multiple bit plane images, the first scan is uncompressed and following lines compressed in the same manner. Character Tiles Alpha/Numeric images can be generally described as a two plane image with the first plane containing the alphanumeric character data and the second containing the attribute information. Alphanumeric characters are presumed to correspond the the IBM extended ASCII character set with attribute information corresponding to the IBM CGA standard. The character and text planes compressed in the same manner as image bit planes with one caveat. The text scan line lenght is twice what it should be (i.e. 160 bytes go out uncompressed for an 80 column screen).