PRODUCT : Borland C++ NUMBER : 1174 VERSION : 3.1 OS : DOS DATE : October 22, 1993 PAGE : 1/2 TITLE : Formats used by the putimage()/getimage() functions. The following document provides source code which is equivalent to calling 'getimage()'; the purpose is to illustrate the format used by the 'getimage()' and 'putimage()' functions of the Borland Graphics Interface: The following code could be used in place of a call to: getimage (left, top, right, bottom, &image); /* */ left = left / 8; // Calculate which byte to // start with on line. right= right / 8; // Calculate which byte to end // with on line. *(int *)image = abs (right - left) + 1; // Store width in // first word. image += 2; *(int *)image = abs (bottom - top) + 1;// Store height in // second word. image += 2; // Count partial bytes bytes_per_line = abs (right - left) / 8 + 1; for (line = top; line <= bottom; line++) /* Start at top line, go through to bottom line. */ for (plane = 0; plane < 4; plane++) /* Loop through planes like this: 0 = intensity 1 = red 2 = green 3 = blue */ for (byte = left; byte < bytes_per_line + left; byte++) { *(char *)image++ = video [plane] [byte]; PRODUCT : Borland C++ NUMBER : 1174 VERSION : 3.1 OS : DOS DATE : October 22, 1993 PAGE : 2/2 TITLE : Formats used by the putimage()/getimage() functions. } /* */ In pseudocode, the above would translate into: 1) Store the width and height of the image as the first two words 2) Skip a reserved word. 3) Repeat the following for scan line of the image { Repeat the following for each plane ( 4x ) { Read the bits making up the line. Pad the number of bits to a multiple of 8. Store the bits ( as bytes ) to the buffer. } } NOTES: - i. getimage saves images per byte. This means that even if you are saving one pixel per line, one full byte of space per plane (there are 4 planes) will be used to store the pixel on each line. - there is another word saved at the end of the image, this word is reseved and is unused at this time. A graphical representation of the file would be: ... ... ... where WIDTH and HEIGTH are in pixels and lineL = last line and byteB = last byte. DISCLAIMER: You have the right to use this technical information subject to the terms of the No-Nonsense License Statement that PRODUCT : Borland C++ NUMBER : 1174 VERSION : 3.1 OS : DOS DATE : October 22, 1993 PAGE : 3/3 TITLE : Formats used by the putimage()/getimage() functions. you received with the Borland product to which this information pertains.