TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: PAUL MADDOX
from: JASON BOLBACH
date: 1997-03-17 20:59:00
subject: BMP Files

        I noticed that you are interested in reading
bitmap files.  I have been working on a couple classes that would do this.  
My coding might be a little rudimentary since i threw these together in 20 
minuts.  The bitmap file is really easy to read. 99% of the time it is 
uncompressed.  The file consists of two headers. The file header, and an info 
header.
#define BMP_SIGNATURE_WORD 0x42d2 // 'BM'
// File Header
class struct BMP_F_HEADER
{
   unsigned short bfType;        // signature - 'BM'
   unsigned long  bfSize;        // file size in bytes
   unsigned short bfReserved1;   // 0
   unsigned short bfReserved2;   // 0
   unsigned long  bfOffBits;     // offset to bitmap
   BMP_F_HEADER()_HEADER()
   {
      bfType = BMP_SIGNATURE_WORD;
      bfSize = bfOffBits = 0;
      bfReserved1 = bfReserved2 = 0;
      return 0;
   }
};
//Info Header
class struct BMP_INF_HEADER
{
   unsigned long  biSize;          // size of this class  struct
   long           biWidth;         // bmap width in pixels
   long           biHeight;        // bmap height in pixels
   unsigned short biPlanes;        // num planes - always 1
   unsigned short biBitCount;      // bits per pixel
   unsigned long  biCompression;   // compression flag
   unsigned long  biSizeImage;     // image size in bytes
   long           biXPelsPerMeter; // horz resolution
   long           biYPelsPerMeter; // vert resolution
   unsigned long  biClrUsed;       // 0 -> color table size
   unsigned long  biClrImportant;  // important color count
   BMP_INF_HEADER()
   {
      biSize = sizeof(BMP_INF_HEADER);
      biWidth = biHeight = 0;
      biPlanes = 1;
      biBitCount = 0;
      biCompression = biSizeImage = 0;
      biXPelsPerMeter = biYPelsPerMeter = 0;
      biClrUsed = biClrImportant = 0;
   }
 };
The next part of the file it the palette. In 256 color mode, there is
a 768 byte palette. The order goes Blue Green Red.  The 24 bit bitmaps dont 
have a palette.  The rest of the information is the actual image. The only 
problem is that it is stored upside down.  The bottom scan line is first.
                I hope this helps you.
                                                        JAson
--- FMail/386 1.22
---------------
* Origin: YRU On-Line Toledo Ohio 419-474-1170 (1:234/106)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.