home *** CD-ROM | disk | FTP | other *** search
/ Encyclopedia of Graphics File Formats Companion / GFF_CD.ISO / formats / inspix / spec / pix.txt
Text File  |  1994-06-01  |  15KB  |  400 lines

  1.                          INSET PIX FILE SPECIFICATION
  2.  
  3. Introduction
  4.  
  5.         This document containts a description of InSet PIX files for use with
  6.         the Inset technology products such as InSet and HiJaak.
  7.  
  8.         The Inset PIX files were designed with the following considerations in
  9.         mind:
  10.  
  11.             o   Ability to access compressed portions of images in a random
  12.         manner
  13.             o   Open design for adding new information without obsoleting old
  14.         files
  15.             o   Device independence
  16.  
  17.         Currently PIX files primarily contain either bit mapped image data or
  18.         alpha-numeric screens with attribute information.  However, since the
  19.         file structure is open, new data types may be added to the file at a
  20.         later time without changing the basic file structure.
  21.  
  22.         In the PIX File Structure section, the actual structure of the PIX
  23.         file is laid out.  Later sections provide more detail in the areas of
  24.         data compression, data structures, and definitions.
  25.  
  26. PIX File Structure
  27.  
  28.         PIX files can be described as an indexed database of data items.  Data
  29.         items may contain any information pertaining to the image.   Data
  30.         items currently found in PIX files include:
  31.  
  32.             o   Image information (size, type, origin, colors etc.)
  33.             o   Printing options such as clipping, size, rotation, etc.
  34.             o   Color Pallete information
  35.             o   Image tiles (compressed sections of the image)
  36.             o   Information on how the image is sectioned into tiles
  37.  
  38.         The size and location of each of these data items is contained in a
  39.         table in the beginning of each PIX file.  To find a particular item,
  40.         the index table is scanned for a matching Item ID to obtain the item
  41.         location and size.
  42.  
  43.         The structure of the PIX file header and index table as well as the
  44.         Item IDs and data structures are provided in the following sections.
  45.  
  46. Pix File Header
  47.  
  48.         At the begining of the PIX file are two words.  The first word
  49.         contains the revision level of the PIX file which is currently 3.  The
  50.         second word contains the number of Item Records in the index table.
  51.  
  52.         Following this brief header is the index table containing an array of
  53.         item record structures.  These structures are defined in C as:
  54.  
  55.  
  56.         struct Item_Rec {
  57.                 unsigned        app_id;         /* Application Id # */
  58.                 unsigned        app_len;        /* Length of application data
  59.         */
  60.                 long                    app_loc;        /* Location in file of
  61.         app data */
  62.         };
  63.  
  64.         To obtain a data item, you search through this array of records for a
  65.         matching app_id structure which then contains the location and length
  66.         of the item.  Empty item records contain an app_id=-1.
  67.  
  68. Image Information
  69.  
  70.         The application ID for the image structure is 0.  This data item
  71.         contains information on the overall image size, type, and  origin of
  72.         the image.  The structure (in C) of this data item is:
  73.  
  74.         struct mode_data {
  75.                 unsigned char    hmode;
  76.                 unsigned char    htype;
  77.                 unsigned char    cfore;
  78.                 unsigned char    cback;
  79.                 unsigned char    tattr;
  80.                 unsigned char    tcpr;
  81.                 unsigned char    trows;
  82.                 unsigned char    thfnts;
  83.                 unsigned char    tlfnts;
  84.                 unsigned char    tcpf;
  85.                 unsigned int     tfsize[4];
  86.                 unsigned int     gcols;
  87.                 unsigned int     grows;
  88.                 unsigned char    gfore;
  89.                 unsigned char    prepal;
  90.                 unsigned char    lodpal;
  91.                 unsigned char    lintens;
  92.                 unsigned char    lred;
  93.                 unsigned char    lgreen;
  94.                 unsigned char    lblue;
  95.                 unsigned char    pages;
  96.                 unsigned char    haspect;
  97.                 unsigned char    vaspect;
  98.         };
  99.  
  100.         Following is a description of each member of this structure:
  101.  
  102.             hmode
  103.                 Hardware specific mode.  0 if not specifically related to a
  104.                 specific hardware mode of a board.
  105.             htype
  106.  
  107.                 Hardware type.  Bit 0=0 if alphanumeric and Bit 0=1 if bit map
  108.                 graphics.  Board types are ORed into this byte.  Board types
  109.                 include:
  110.  
  111.                 8=CGA
  112.                 16=Hercules
  113.                 24=EGA
  114.  
  115.             cfore
  116.                 Text foreground color bits (ignore if graphics) 4 for CGA
  117.             tattr
  118.                 Text background color bits (ignore if graphics) 3 for CGA
  119.             tcpr
  120.                 Text characters per row (ignore if graphics)
  121.             trows
  122.                 Text rows (ignore if graphics)
  123.             thfnts
  124.                 Text hardware fonts (not used)
  125.             tlfnts
  126.                 Text loadable fonts (not used)
  127.             tcpf
  128.                 Text characters per font (Not used).
  129.             tfsize
  130.                 Font size (not used).
  131.             gcols
  132.                 Graphics columns
  133.             grows
  134.                 Graphics rows
  135.             gfore
  136.                 Graphics foreground color bits
  137.             prepal
  138.                 Number of preset pallettes (default to 0)
  139.             lodpal
  140.                 Number of loadable pallettes
  141.             lintens
  142.                 Number of pallette bits for intesity
  143.             lred
  144.                 Number of pallette bits for red
  145.             lgreen
  146.                 Number of pallette bits for green
  147.             lblue
  148.                 Number of pallette bits for blue
  149.             pages
  150.                 Number of possible pages (not used)
  151.             haspect
  152.                 Horizontal component of aspect ratio (number of horizontal
  153.                 pixels to fit in a square)
  154.             vaspect
  155.                 Vertical component of aspect ratio (number of vertical pixels
  156.                 to fit in a square)
  157.  
  158.  
  159.         A sample image structure for 600 rows by 800 columns single bit plane
  160.         image might be initialized as follows:
  161.  
  162.         struct mode_data {
  163.                 unsigned char hmode=0;
  164.                 unsigned char htype=1;
  165.                 unsigned char cfore=0;
  166.                 unsigned char cback=0;
  167.                 unsigned char tattr=0;
  168.                 unsigned char tcpr=80;
  169.                 unsigned char trows=25;
  170.                 unsigned char thfnts=0;
  171.                 unsigned char tlfnts=0;
  172.                 unsigned char tcpf=0;
  173.                 unsigned int  tfsize[4]=0;
  174.                 unsigned int  gcols=800;
  175.                 unsigned int  grows=600;
  176.                 unsigned char gfore=1;
  177.                 unsigned char prepal=0;
  178.                 unsigned char lodpal=0;
  179.                 unsigned char lintens=1;
  180.                 unsigned char lred=0;
  181.                 unsigned char lgreen=0;
  182.                 unsigned char lblue=0;
  183.                 unsigned char pages=0;
  184.                 unsigned char haspect=1;
  185.                  
  186.                 unsigned char vaspect=1;
  187.         };
  188.  
  189. Printing Options
  190.  
  191.         The application ID for InSet Printing options is 11 Hexidecimal.  The
  192.         C structure containing these items follows:
  193.  
  194.         struct prt_options {
  195.                 int
  196.                                 pitch,
  197.                         scol,
  198.                         ecol,
  199.                         srow,
  200.                         erow,
  201.                         p_wid,
  202.                         siz,
  203.                         rotat,
  204.                         do_sw;
  205.                         res_1,
  206.                         res_2,
  207.                         pcolor,
  208.                         row_dp,
  209.                         col_dp,
  210.                         flags;
  211.                         char ink_tab[16];
  212.         };
  213.  
  214.         pitch
  215.                 Printer Pitch divided by 10 (e.g. 100 = 10 pitch) (not
  216.                 required, set to 100)
  217.         scol
  218.                 Start column clip boundary
  219.         ecol
  220.                 End column clip boundary
  221.         srow
  222.                 Start row clip boundary
  223.         erow
  224.                 End row clip boundary
  225.         p_wid
  226.                 Printer width (not required, set to 0)
  227.         size
  228.                 Size (not used, set to 0)
  229.         rotat
  230.                 Rotation (0=Horizontal, -1=Left, 1=Right)
  231.         do_sw
  232.                 Option Bits ORed.  Applicable bits to set include:
  233.  
  234.                     Double Pass |=   2
  235.                     Letter Quality |= 4
  236.                     Border On |=  10 (Hex)
  237.  
  238.         res_1
  239.         res_2
  240.                 Internal Use (don't use, set to 0)
  241.         pcolor
  242.                 Low order byte indicates whether the image setting are
  243.                 intended for color printer      (True=1, False=0)
  244.  
  245.                 High order byte is a selects which dither pattern type to use
  246.                 ( 0=Old, 1=Gray, 2=Contrast).
  247.  
  248.         row_dp
  249.                 Height of image in Decipoints (1/720 inches)
  250.         col_dp
  251.                 Width of image in Decipoints (1/720 inches)
  252.         flags
  253.                 Modify flags
  254.  
  255.                 Size option bits:
  256.  
  257.                 #define INDATA_USE_COL  0x1
  258.                 #define INDATA_USE_INCH 0x2
  259.                 #define INDATA_USE_DP   0x3
  260.  
  261.                 Modify/Ink Selection:
  262.  
  263.                 #define INDATA_INK_INV  0x8
  264.                 #define INDATA_INK_BW   0x10
  265.                 #define INDATA_INK_TAB  0x18
  266.  
  267.                 #define INDATA_VDISK    0x20
  268.                 #define INDATA_VSIZE    0x40
  269.                 #define INDATA_DYNAMIC  0x80
  270.  
  271.         ink_tab
  272.                 16 byte table mapping screen colors to printer colors/gray
  273.                 patterns (see the MODIFY/INKS section of the InSet manual for
  274.                 more information on ink tables).  If you want to select your
  275.                 own Ink table mapping the flags variable must have a 0x18
  276.                 or'ed in.  Preset InSet Ink tables are set as follows:
  277.  
  278.                 Color Number  0 1 2 3 4 5 6 7 8 9 A B C D E F
  279.                 _____________________________________________________
  280.  
  281.                 Standard      F 1 2 3 4 5 6 7 8 9 A B C D E 0
  282.  
  283.                 Invert        0 1 2 3 4 5 6 7 8 9 A B C D E F
  284.  
  285.                 B&W           F 0 0 0 0 0 0 0 F 0 0 0 0 0 0 0
  286.  
  287.  
  288. Pallette Data
  289.  
  290.         Application ID=1 contains display pallette information.  Pallette
  291.         information is stored in an array of pallette structures of the
  292.         following form:
  293.  
  294.         struct pallette {
  295.                 char    intens, red, green, blue;
  296.         };
  297.  
  298.         The number of significant pallette items in the array is determined by
  299.         the number of available colors (gfore in the image data structure) in
  300.         the image.  The significant bits are determined by the lintens lred
  301.         lgreen, and lblue items in the modedata structure.
  302.  
  303. Tile Information
  304.  
  305.         Information as to how the image is broken down into tiles is contained
  306.         in the data item with ID=2.  This structure follows:
  307.  
  308.         struct Tile_Data {
  309.                 unsigned        page_rows;
  310.                 unsigned        page_cols;
  311.                 unsigned        stp_rows;
  312.                 unsigned        stp_cols;
  313.         };
  314.  
  315.         page_rows
  316.                 Number of rows within each tile.
  317.         page_cols
  318.                 Number of columns in each tile (must be divisible by
  319.                 8)
  320.         stp_rows
  321.                 Number of horizontal tile strips within the image
  322.         stp_cols
  323.                 Number of vertical tile strips
  324.  
  325.         Each tile is limited to a maximum of 4096 bytes of uncompressed data.
  326.  
  327.         The actual tiles are numbered starting with the upper left row as tile
  328.         0 and incremented from left to right as illustrated below.
  329.  
  330.                  ---------------
  331.                 | 0 | 1 | 2 | 3 |
  332.                 |---------------
  333.                 | 4 | 5 | 6 | 7 |
  334.                 |---------------|
  335.                 | 8 | 9 | A | B |
  336.                  ---------------
  337.  
  338.         The ID of a tile is the tile number ORed with a Hex 8000.  For
  339.         example, the lower right tile can be found by finding the record with
  340.         ID=800B (Hex).
  341.  
  342.         Images may be broken down into a checker board sections or Horizontal
  343.         strips.  However, if the image is broken into horizontal strips
  344.         processing the image as rotated by InSet will be slowed.
  345.  
  346. Pixel Tiles
  347.  
  348.         Each individual Pixel tile ID is determined by ORing in Hex 8000 with
  349.         the tile number as described in the preceding tile information
  350.         section.
  351.  
  352.         The image is organized into bitplanes with 8 Pixels per byte  with the
  353.         most significant bit containing the left-most pixel.  For multiple bit
  354.         plane images, all scan lines for a plane are written out before the
  355.         scan lines in the next plane.
  356.  
  357.         If the actual column boundary of the tile exceeds the column bounds of
  358.         the image it is padded with blank bytes to fill out the tile.  If the
  359.         actual row bound of the tile exceeds the image, the extra rows are not
  360.         present.
  361.  
  362.         When the tile is store on disk it is in compressed format using a
  363.         vertical compression technique.  The first scan line of each tile is
  364.         written out with no modification.  Then before the following scan
  365.         lines there are compression bytes which indicate which bytes in the
  366.         scan line are differrent than the preceding line.  Each bit in the
  367.         compression byte indicates whether a particular byte in that scan has
  368.         changed (1 if changed, 0 if not).  Then following the compression
  369.         bytes, only the modified scan bytes are written to the file.
  370.  
  371.         For example, if we had a tile that was 8 colomns wide and the first
  372.         scan line was all blank and there was a dot at the beginning and end
  373.         of the second scan line it would be written to disk as follows:
  374.  
  375.            00 00 00 00 00 00 00 00 <- First Scan Line
  376.         81 80                   01 <- Changed Bytes
  377.         ^
  378.         |
  379.         Compression Byte
  380.  
  381.  
  382.         In multiple bit plane images, the first scan is uncompressed and
  383.         following lines compressed in the same manner.
  384.  
  385. Character Tiles
  386.  
  387.         Alpha/Numeric images can be generally described as a two plane image
  388.         with the first plane containing the alphanumeric character data and
  389.         the second containing the attribute information.  Alphanumeric
  390.         characters are presumed to correspond the the IBM extended ASCII
  391.         character set with attribute information corresponding to the IBM CGA
  392.         standard.
  393.  
  394.         The character and text planes compressed in the same manner as image
  395.         bit planes with one caveat.  The text scan line lenght is twice what
  396.         it should be (i.e. 160 bytes go out uncompressed for an 80 column
  397.         screen).
  398.  
  399.  
  400.