CPC092292 504.DOC MastrScan* Image File Format This document is provided as "For your information" and as is. Neither The Complete PC nor any of it's employees assume any responsibility for consequences resulting from the use of the following information nor can the Complete PC technical support provide help with this document. The user of said information does so at his or her own risk. *MastrScan is the replacement for SmartScan. Only the name changed, no funtionality was added nor was the image format changed. This document describes the file formats used with all releases of The Complete FAX and The Complete FAX 9624, The Complete Hand Scanner (releases prior to 2.0), and all Complete PC Scanners (SmartScan release 2.1 and later MastrScan release 2.22 and later). All of the file formats use a modified run-length encoding, and differ primarily in the file header. Multiple-page irnages (faxes) are stored one page per file; the file extension normally indicates the sequential page number (.001, .002, etc. for Type 1 files; .a0l, .a02, etc. for Type 3 files) All files consist of a header followed by one or more rows of tokens, each of which represents a scan line or line of pixels. In the following descriptions, files are classified as follows: Type 1 Fax File Type 2 Complete Hand Scanner File (Pre-2.0 Release) Type 3 Complete PC Scanner File (Release 2.1 and later) File Header The file header consists of 100 bytes. The format is: Byte Description 0-3 Header. If this is a Type 1 or Type 2 file, the values are 80 01 40 02 hex. If this is a Type 3 file, the values are 80 01 40 00 hex 4-9 Hour, Minute, and Second (2 bytes each) when fax was received. Stored in format used by DOSInt 21H; values are 00 if the time is not needed or not 10-17 available, or this is a Type 2 or Type 3 file Month, Day, WeekDay, Year (2 bytes each) when fax was received. Stored in format used by DOS Int 21H; values are 00 if date is not needed or not available, or this is a Type 2 or Type 3 file Byte Description 18-77 Reserved, ignore when reading file and make all 00 when writing file 78 Resolution, 00 if Standard resolution (100x200), 02 if Fine resolution (200x200). In a Type 2 or Type 3 79 file, this is set to 02 Picture Start, The starting pixel column for the 80-99 image for Type 1 and Type 2 files. This is 00 for Type 3 files Reserved. Should be 00, except for Type 3 files, where Byte 90 represents the image resolution and can have values 1 (100 dpi), 2 (200 dpi), 3 (300 dpi), 4 (400 dpi), 15 (150 dpi), or 75 (75 dpi). Bytes 91-92 represent the number of bytes per scanline (See the next section). In a Type 1 or Type 2 file, each line is set at 1728 pixels. In a Type 3 file, the value can vary with the image so it is specified here Body of File After the header, one EOL is followed by a repeating series of ( scanline, EOL ), and the file ends with 4 EOL's (that would give you 5 EOL's at the end of the file). EOL is 69 hex or 105 decimal. The exception is when a scanline is 7F (a white line); this is NOT followed by an EOL. In Type 1 and Type 2 files, a 7F is interpreted identically to a 91, 1, EOL (all in decimal); for Type 3 files, a 7F is interpreted as a full image-width of white. Each scanline represents the data for one row of the image. The encoding is described below. In a Type 1 or Type 2 file, each scanline is fixed at 1728 pixels. After conversion to a bitmap, that makes 1728 bits or 216 bytes per scanline. In a Type 3 file, the (post-conversion-to-bitmap) scanline length in bytes is set in the header bytes 91-92. ú A token represents a run length of consecutive black or white dots. It can also be used to store a 7-bit image. A run length is representeel by 1 (if the run length is under 64) token or 2 (if the run length is 64 or over) tokens. If 2 tokens are used, the first is the highest multiple of 64 that is less than or equal to the run length, and the second token is (run length mod 64). Tokens represent alternating white and black run lengths; each scanline starts with a white run length. Remember, in a Type 1 or Type 2 file, the run lengths in a scanline must add to 1728. In a Type 3 file, if the scanline is too long to represent with 2 tokens, then the sequence (token, token, 01, token, token, EOL) is used to represent an exceptionally long run of one color. The 01 in the middle is used as a "placeholder" and represents a 0- length run of the other color. The following tokens are defined (values are listed in decimal): Value Run Length Value Run Length 1 0 86 1408 2 1 87 1472 3 2 88 1536 4 3 89 1600 : : 90 1664 : : 91 1728 64 63 92 1792 65 64 93 1856 66 128 94 1920 67 192 95 1984 68 256 96 2048 69 320 97 2112 70 384 98 2176 71 448 99 2240 72 512 100 2304 73 576 101 2368 74 640 102 2432 75 704 103 2496 76 768 104 2560 77 832 105 EOL 78 896 125 Null Token 79 960 127 Blank Scan 80 1024 Line (White 81 1088 Line) 82 1152 83 1216 84 1280 85 1344 A token value of 128 to 255 (high bit set means that the remaining seven bits represent a simple pixel pattern with no encoding. A bit set to 1 indicates a white pixel. A pixel token (high bit set) is always followed by a single-byte token of matching color (matches the last bit).