Dec 072017
 
Description of the _putimage/_getimage format used by Watcom 9.5.
File IMAGE.ZIP from The Programmer’s Corner in
Category C Source Code
Description of the _putimage/_getimage format used by Watcom 9.5.
File Name File Size Zip Size Zip Type
IMAGE.DOC 1829 721 deflated

Download File IMAGE.ZIP Here

Contents of the IMAGE.DOC file


WATCOM C Graphics Library Image Format
======================================

The graphics images used by the _getimage and _putimage functions
have the following format:

The first six bytes of the image are a header describing the size
of the image. This header is defined as:

struct image_header {
short numxpixels;
short numypixels;
short bp;
};

The numxpixels and numypixels define the size of the image.
The bp field is either the number of bits per pixel used to
store the image (modes 4, 6, 11, 17, 19, 256, 257, 259, 261),
or the number of bit-planes of data (modes 13, 14, 15, 16,
18, 258, 260).

The remainder of the image consists of the actual image data
stored a row at a time. Each row of data starts on a byte
boundary. The length of a row of data is given by the following
formula:

len = ( ( numxpixels * bp + 7 ) / 8 ); // modes 4, 6, 11, 17, 19
or
len = ( ( numxpixels + 7 ) / 8 ) * bp; // modes 13, 14, 15, 16, 18

In modes 4, 6, 11, 17, and 19, pixels are packed into the bytes
of the row of data. In mode 4 (2 bits per pixel) for instance,
the data in the image looks like

7 0
xxxxxxxx

1st pixel
2nd pixel
3rd pixel
4th pixel

In modes 13, 14, 15, 16, and 18, the data in each row is stored
a bit-plane at a time. Each bit-plane of each row starts on a
byte boundary. The bit-planes are stored with the highest numbered
plane first, and bit-plane 0 last. Each pixel value is made up by
taking a bit from each bit-plane.

aaaaaaaabbbbbbbbccccccccdddddddd

bit-plane 0
bit-plane 1
bit-plane 2
bit-plane 3


 December 7, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)