Unuk 1.0
src/libUnuk/ImageLoader.h
Go to the documentation of this file.
00001 // ===================================================================
00002 // This image loader will read in a 32-bit bitmap.
00003 // ===================================================================
00004 
00005 #ifndef _IMAGELOADER_H_
00006 #define _IMAGELOADER_H_
00007 
00008 typedef unsigned char   BYTE;
00009 typedef int             LONG;
00010 typedef unsigned int    DWORD;
00011 typedef unsigned short  WORD;
00012 
00013 // Provides general information about the file.
00014 typedef struct __attribute__ ((__packed__)) tagBITMAPFILEHEADER {
00015   WORD  bfType;
00016   DWORD bfSize;
00017   WORD  bfReserved1;
00018   WORD  bfReserved2;
00019   DWORD bfOffBits;
00020 } BITMAPFILEHEADER, *PBITMAPFILEHEADER;
00021 
00022 // The information header provides information specific to the image data.
00023 typedef struct __attribute__ ((__packed__)) tagBITMAPINFOHEADER {
00024   DWORD biSize;
00025   LONG  biWidth;
00026   LONG  biHeight;
00027   WORD  biPlanes;
00028   WORD  biBitCount;
00029   DWORD biCompression;
00030   DWORD biSizeImage;
00031   DWORD biXPelsPerMeter;
00032   DWORD biYPelsPerMeter;
00033   DWORD biCLRUsed;
00034   DWORD biCLRImportant;
00035 } BITMAPINFOHEADER, *PBITAPINFOHEADER;
00036 
00037 // Color palette.
00038 typedef struct __attribute__ ((__packed__)) tagRGBQUAD {
00039   BYTE rbgBlue;
00040   BYTE rgbGreen;
00041   BYTE rgbRed;
00042   BYTE rgbReserved;
00043 } RGBQUAD;
00044 
00045 class ImageLoader {
00046 public:
00047   ImageLoader(void);
00048   ImageLoader(const char *filename);
00049 
00050   virtual ~ImageLoader(void);
00051   
00052   bool LoadBMP(const char *filename);
00053   BYTE *GetAlpha(void) const;
00054   
00055   LONG     GetHeight(void)      const { return height;    }
00056   RGBQUAD  *GetColors(void)     const { return colors;    }
00057   bool     GetLoaded(void)      const { return loaded;    }
00058   BYTE     *GetPixelData(void)  const { return pixelData; }
00059   LONG     GetWidth(void)       const { return width;     }
00060 
00061 private:
00062   BITMAPFILEHEADER  bmfh;
00063   BITMAPINFOHEADER  bmih;
00064   RGBQUAD           *colors;
00065   BYTE              *pixelData;
00066   bool              loaded;
00067   LONG              width;
00068   LONG              height;
00069   WORD              bpp;
00070 
00071   // Private methods.
00072   void Reset(void);
00073   bool FixPadding(BYTE const * const tempPixelData, DWORD size);
00074 };
00075 
00076 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines