3DSoftware.com > Programming > File Formats > BIP > Page 3
BIP File Format  Page 3
 
File Header
 
Each BIP file contains data at the beginning of the file to provide information about the file.
 
 
File Signature Bytes
Bytes 0 – 3

 
The first 4 bytes of the BIP file are the File Signature Bytes which identify the file as a BIP file, and must have these values:
 
Byte 0  =  
Byte 1  =  
Byte 2  =  
Byte 3  =  
0x42
0x49
0x50
0x00
 
Those are the ASCII characters ‘B’, ‘I’ and ‘P’ respectively.
 

 
File Header (Unsigned Integers)
Bytes 0 – 56   (0x0 – 0x38)

 
The first 64 bytes of the BIP file is file header information in an array of unsigned integers. There are 16 unsigned integers in this array. Each unsigned integer is 32-bits. In C/C++, we declare the array:
 
unsigned int uivecHeader[ 16 ];        
 
When writing this array to file, since each variable in the array is multi-byte, write one variable at a time to ensure proper byte ordering of each 32-bit variable:
 
for ( i = 0; i < 16; i++ )
    WriteUIntMSBFIRST( uivecHeader[ i ], pFile );
 
When reading the multi-byte variables from file, read one variable at a time:
 
for ( i = 0; i < 16; i++ )
    uivecHeader[ i ] = ReadUIntMSBFIRST( pFile );
 
This array of variables defines the following file settings:
 
uivecHeader[ 0 ]  =  
uivecHeader[ 1 ]  =  
uivecHeader[ 2 ]  =  
uivecHeader[ 3 ]  =  
uivecHeader[ 4 ]  =  
uivecHeader[ 5 ]  =  
uivecHeader[ 6 ]  =  
uivecHeader[ 7 ]  =  
uivecHeader[ 8 ]  =  
uivecHeader[ 9 ]  =  
uivecHeader[ 10 ]  =  
uivecHeader[ 11 ]  =  
uivecHeader[ 12 ]  =  
uivecHeader[ 13 ]  =  
uivecHeader[ 14 ]  =  
uivecHeader[ 15 ]  =  
File Signature
File Version
File Size High
File Size
Grid Width
Grid Height
Tile Width
Tile Height
Number of Planes
Byte Flags
Ptr to Tile Addresses
Ptr to Block Addresses
Ptr to Band Addresses
Ptr to Copyright Notice
Ptr to Comments
Ptr to Custom Data
 
File Signature (Magic Number)
Must be 0x42495000
 
File Version
Must be 1
 
File Size High
0 = Default
If the file size is 64 bits, then this is the high order 32 bits of the file size. If the file size is 32 bits, then this is zero.
 
File Size
Size of the file (number of bytes).  If the file size is 64 bits, this is the low order 32 bits of the file size.
 
Grid Width and Height
Number of columns and rows of pixels in each image. This is how wide and high the grid is, in pixels. Both of these variables (Grid Width and Height) can be zero if only blocks are used (without bands), and if both variables (not just one of these variables) are zero, in which case the two variables can be ignored (or determined by examining the blocks).
 
Tile Width and Tile Height
Size of each tile, in pixels. These variables are zero if tiles are not used.
 
Number of Planes
This is how many bit planes are stored. If only one image is stored, the Number of Planes is 1.
 
Byte Flags
Bytes settings that are accessed with shifting:
Compression = 
Bit Order = 
Default Color = 
Reserved = 
 
uivecHeader[ 9 ] & 255
( uivecHeader[ 9 ] >> 8 ) & 255
( uivecHeader[ 9 ] >> 16 ) & 255
( uivecHeader[ 9 ] >> 24 ) & 255
 
Compression
0x00 if compression is turned OFF for the file, or 0x01 if compression is turned ON for the file.
 
Bit Order
0x01 = Low bit first
0x80 = High bit first
This is the bit ordering within each image byte. Low bit first stores the bits within a byte beginning with the least significant bit of the byte. High bit first stores the bits within a byte beginning with the most significant bit of the byte.
        Historically, low bit first was commonly used for data (bit streams), high bit first for graphic images (bit planes).
        Within a byte, the least significant bit is 0x01 (the bit sequence 0000 0001), and the high bit is 0x80 (1000 0000). That is right to left ordering.
        Conceptually, the bytes in computer memory are ordered left to right, but the bits within a byte are ordered right to left (Comer, Essentials of Computer Architecture, p. 31).
        Raster graphic image bitmaps are ordered left to right (and top to bottom). The first (upper-left) dot, in a standard monochrome raster bitmap image, is the most significant bit (0x80) in the first byte of that bitmap's raster memory. In that case, set the BIP file's Bit Order to 0x80 (High bit first).
 
Default Color
0 = Black
1 = White
This color is used for tiles that do not exist.
 
Reserved
This byte setting is reserved for future use and must be 0x00.
 
Pointer to Tile Addresses
This is the offset in bytes (from beginning of file) to the list of Tile Addresses. This is zero if tiles are not used.
 
Pointer to Block Addresses
This variable points (is the offset in bytes from beginning of file) to the list of Block Addresses. This must be zero if blocks are not used. Blocks can only be used if Tiles are not used (if Pointer to Tile Addresses is zero).
 
Pointer to Band Addresses
This variable points (is the offset in bytes from beginning of file) to the list of Diagonal Bands. This must be zero if diagonal bands are not used. Diagonal bands can only be used if Tiles are not used (if Pointer to Tile Addresses is zero).
 
Pointer to Copyright Notice
This is the offset in bytes (from beginning of file) to a Copyright Notice. This is optional. If this is null (zero), there is no copyright notice. The Copyright Notice consists of Simple Unicode UTF-16 text characters.
 
Pointer to Comments
This is the offset in bytes (from beginning of file) to Text Comments. If this is null (zero), there are no comments. That is the default. Comments are optional, and are Simple Unicode UTF-16 text characters.
 
Pointer to Custom Data
0 = Default
If this variable is non-zero, it is the offset in bytes (from beginning of file) to Custom Data. The Custom Data consists of an unsigned int (32-bit number) that specifies the size (in bytes) of the custom data, followed by that many bytes of your custom binary data. The binary data can be any binary data you need to transfer with the file, and can be ignored by decoders.
 
—  Page 3  —
 « Page 2 Contents Page 4 » 
 
Copyright © 2008 by 3D Software. All rights reserved.
3D Software, P.O. Box 221190, Sacramento CA 95822 USA
www.3DSoftware.com     Contact us
Tuesday, 06-Jan-2009 04:31:43 GMT