KSM edits to RA8875

Dependents:   Liz_Test_Code

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Bitmap.h Source File

Bitmap.h

00001 //
00002 // Windows BMP file definitions.
00003 //
00004 // Adapted from code written by Michael Sweet from Paul Bourke's
00005 // web site: http://paulbourke.net/dataformats/bmp/
00006 //
00007 
00008 #ifndef _BITMAP_H_
00009 #define _BITMAP_H_
00010 
00011 #include <mbed.h>
00012 
00013 // BITMAPFILEHEADER
00014 // BITMAPINFOHEADER
00015 // Optional Palette
00016 // Raw Data
00017 
00018 //
00019 // Bitmap file data structures
00020 //
00021 // must align to 2-byte boundaries so it doesn't alter the memory image when 
00022 // bytes are read from the file system into this footprint.
00023 #pragma push
00024 #pragma pack(2)
00025 
00026 /// Bitmap file header
00027 typedef struct                    /**** BMP file header structure ****/
00028     {
00029     uint16_t    bfType;           ///< Magic number for file 
00030     uint32_t    bfSize;           ///< Size of file 
00031     uint16_t    bfReserved1;      ///< reserved placeholder for the structure footprint
00032     uint16_t    bfReserved2;      ///< reserved placeholder for the structure footprint
00033     uint32_t    bfOffBits;        ///< Offset to bitmap data 
00034     } BITMAPFILEHEADER;           // Size: 14B
00035 
00036 /// Bitmap information header
00037 typedef struct                    /**** BMP file info structure ****/
00038     {
00039     uint32_t    biSize;           ///< Size of info header 
00040     uint32_t    biWidth;          ///< Width of image 
00041     uint32_t    biHeight;         ///< Height of image 
00042     uint16_t    biPlanes;         ///< Number of color planes 
00043     uint16_t    biBitCount;       ///< Number of bits per pixel 
00044     uint32_t    biCompression;    ///< Type of compression to use 
00045     uint32_t    biSizeImage;      ///< Size of image data 
00046     int32_t     biXPelsPerMeter;  ///< X pixels per meter 
00047     int32_t     biYPelsPerMeter;  ///< Y pixels per meter 
00048     uint32_t    biClrUsed;        ///< Number of colors used 
00049     uint32_t    biClrImportant;   ///< Number of important colors 
00050     } BITMAPINFOHEADER;           // Size: 40B
00051 #pragma pop
00052 
00053 #define BF_TYPE 0x4D42            /* "MB" */
00054 
00055 /*
00056  * Constants for the biCompression field...
00057  */
00058 
00059 #  define BI_RGB       0             /* No compression - straight BGR data */
00060 #  define BI_RLE8      1             /* 8-bit run-length compression */
00061 #  define BI_RLE4      2             /* 4-bit run-length compression */
00062 #  define BI_BITFIELDS 3             /* RGB bitmap with RGB masks */
00063 
00064 /// An RGB Quad data type used by the bitmap driver.
00065 typedef struct                       /**** Colormap entry structure ****/
00066     {
00067     uint8_t  rgbBlue;          ///< Blue value 
00068     uint8_t  rgbGreen;         ///< Green value 
00069     uint8_t  rgbRed;           ///< Red value 
00070     uint8_t  rgbReserved;      ///< Reserved 
00071     } RGBQUAD;
00072 
00073 //typedef struct                       /**** Bitmap information structure ****/
00074 //    {
00075 //    BITMAPINFOHEADER bmiHeader;      /* Image header */
00076 //    RGBQUAD          bmiColors[256]; /* Image colormap */
00077 //    } BITMAPINFO;
00078 
00079 
00080 #pragma push
00081 #pragma pack(2)
00082 
00083 /// Icon file type file header.
00084 typedef struct                  /**** ICO file header structure ****/
00085     {
00086     uint16_t    Reserved_zero;  ///< Always zero
00087     uint16_t    icType;         ///< 1 for .ico, 2 for .cur
00088     uint16_t    icImageCount;   ///< number of images in the file    
00089     } ICOFILEHEADER;
00090 
00091 /// Icon file type directory entry structure
00092 typedef struct                  /**** ICO file Directory Entry structure (1 or more) ****/
00093     {
00094     uint8_t     biWidth;        ///< Width of image 
00095     uint8_t     biHeight;       ///< Height of image 
00096     uint8_t     biClrUsed;      ///< Number of colors used 
00097     uint8_t     Reserved_zero;  ///< reserved placeholder for the structure footprint
00098     uint16_t    biPlanes;       ///< Number of color planes (ICO should be 0 or 1, CUR horz hotspot 
00099     uint16_t    biBitCount;     ///< Number of bits per pixel (ICO bits per pixel, CUR vert hotspot 
00100     uint32_t    biSizeImage;    ///< Size of image data 
00101     uint32_t    bfOffBits;      ///< Offset into file for the bitmap data 
00102     } ICODIRENTRY;
00103 #pragma pop
00104 
00105 #define IC_TYPE 0x0001            /* 1 = ICO (icon), 2 = CUR (cursor) */
00106 
00107 #endif // _BITMAP_H_