Forked para SNOCC
Fork of RA8875 by
Bitmap.h@118:0973c6527882, 2017-06-23 (annotated)
- Committer:
- gstedile
- Date:
- Fri Jun 23 03:58:47 2017 +0000
- Revision:
- 118:0973c6527882
- Parent:
- 42:7cbdfd2bbfc5
20170622
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
WiredHome | 31:c72e12cd5c67 | 1 | // |
WiredHome | 31:c72e12cd5c67 | 2 | // Windows BMP file definitions. |
WiredHome | 31:c72e12cd5c67 | 3 | // |
WiredHome | 31:c72e12cd5c67 | 4 | // Adapted from code written by Michael Sweet from Paul Bourke's |
WiredHome | 31:c72e12cd5c67 | 5 | // web site: http://paulbourke.net/dataformats/bmp/ |
WiredHome | 31:c72e12cd5c67 | 6 | // |
WiredHome | 31:c72e12cd5c67 | 7 | |
WiredHome | 31:c72e12cd5c67 | 8 | #ifndef _BITMAP_H_ |
WiredHome | 31:c72e12cd5c67 | 9 | #define _BITMAP_H_ |
WiredHome | 31:c72e12cd5c67 | 10 | |
WiredHome | 31:c72e12cd5c67 | 11 | #include <mbed.h> |
WiredHome | 31:c72e12cd5c67 | 12 | |
WiredHome | 31:c72e12cd5c67 | 13 | // BITMAPFILEHEADER |
WiredHome | 31:c72e12cd5c67 | 14 | // BITMAPINFOHEADER |
WiredHome | 31:c72e12cd5c67 | 15 | // Optional Palette |
WiredHome | 31:c72e12cd5c67 | 16 | // Raw Data |
WiredHome | 31:c72e12cd5c67 | 17 | |
WiredHome | 31:c72e12cd5c67 | 18 | // |
WiredHome | 31:c72e12cd5c67 | 19 | // Bitmap file data structures |
WiredHome | 31:c72e12cd5c67 | 20 | // |
WiredHome | 32:0e4f2ae512e2 | 21 | // must align to 2-byte boundaries so it doesn't alter the memory image when |
WiredHome | 32:0e4f2ae512e2 | 22 | // bytes are read from the file system into this footprint. |
WiredHome | 31:c72e12cd5c67 | 23 | #pragma push |
WiredHome | 31:c72e12cd5c67 | 24 | #pragma pack(2) |
WiredHome | 31:c72e12cd5c67 | 25 | |
WiredHome | 42:7cbdfd2bbfc5 | 26 | typedef struct /**** BMP file header structure ****/ |
WiredHome | 31:c72e12cd5c67 | 27 | { |
WiredHome | 31:c72e12cd5c67 | 28 | uint16_t bfType; /* Magic number for file */ |
WiredHome | 31:c72e12cd5c67 | 29 | uint32_t bfSize; /* Size of file */ |
WiredHome | 31:c72e12cd5c67 | 30 | uint16_t bfReserved1; /* Reserved */ |
WiredHome | 31:c72e12cd5c67 | 31 | uint16_t bfReserved2; /* ... */ |
WiredHome | 31:c72e12cd5c67 | 32 | uint32_t bfOffBits; /* Offset to bitmap data */ |
WiredHome | 31:c72e12cd5c67 | 33 | } BITMAPFILEHEADER; |
WiredHome | 31:c72e12cd5c67 | 34 | |
WiredHome | 31:c72e12cd5c67 | 35 | typedef struct /**** BMP file info structure ****/ |
WiredHome | 31:c72e12cd5c67 | 36 | { |
WiredHome | 31:c72e12cd5c67 | 37 | uint32_t biSize; /* Size of info header */ |
WiredHome | 31:c72e12cd5c67 | 38 | uint32_t biWidth; /* Width of image */ |
WiredHome | 31:c72e12cd5c67 | 39 | uint32_t biHeight; /* Height of image */ |
WiredHome | 31:c72e12cd5c67 | 40 | uint16_t biPlanes; /* Number of color planes */ |
WiredHome | 31:c72e12cd5c67 | 41 | uint16_t biBitCount; /* Number of bits per pixel */ |
WiredHome | 31:c72e12cd5c67 | 42 | uint32_t biCompression; /* Type of compression to use */ |
WiredHome | 31:c72e12cd5c67 | 43 | uint32_t biSizeImage; /* Size of image data */ |
WiredHome | 31:c72e12cd5c67 | 44 | int32_t biXPelsPerMeter; /* X pixels per meter */ |
WiredHome | 31:c72e12cd5c67 | 45 | int32_t biYPelsPerMeter; /* Y pixels per meter */ |
WiredHome | 31:c72e12cd5c67 | 46 | uint32_t biClrUsed; /* Number of colors used */ |
WiredHome | 31:c72e12cd5c67 | 47 | uint32_t biClrImportant; /* Number of important colors */ |
WiredHome | 31:c72e12cd5c67 | 48 | } BITMAPINFOHEADER; |
WiredHome | 31:c72e12cd5c67 | 49 | #pragma pop |
WiredHome | 31:c72e12cd5c67 | 50 | |
WiredHome | 32:0e4f2ae512e2 | 51 | #define BF_TYPE 0x4D42 /* "MB" */ |
WiredHome | 32:0e4f2ae512e2 | 52 | |
WiredHome | 31:c72e12cd5c67 | 53 | /* |
WiredHome | 31:c72e12cd5c67 | 54 | * Constants for the biCompression field... |
WiredHome | 31:c72e12cd5c67 | 55 | */ |
WiredHome | 31:c72e12cd5c67 | 56 | |
WiredHome | 31:c72e12cd5c67 | 57 | # define BI_RGB 0 /* No compression - straight BGR data */ |
WiredHome | 31:c72e12cd5c67 | 58 | # define BI_RLE8 1 /* 8-bit run-length compression */ |
WiredHome | 31:c72e12cd5c67 | 59 | # define BI_RLE4 2 /* 4-bit run-length compression */ |
WiredHome | 31:c72e12cd5c67 | 60 | # define BI_BITFIELDS 3 /* RGB bitmap with RGB masks */ |
WiredHome | 31:c72e12cd5c67 | 61 | |
WiredHome | 31:c72e12cd5c67 | 62 | typedef struct /**** Colormap entry structure ****/ |
WiredHome | 31:c72e12cd5c67 | 63 | { |
WiredHome | 31:c72e12cd5c67 | 64 | uint8_t rgbBlue; /* Blue value */ |
WiredHome | 31:c72e12cd5c67 | 65 | uint8_t rgbGreen; /* Green value */ |
WiredHome | 31:c72e12cd5c67 | 66 | uint8_t rgbRed; /* Red value */ |
WiredHome | 31:c72e12cd5c67 | 67 | uint8_t rgbReserved; /* Reserved */ |
WiredHome | 31:c72e12cd5c67 | 68 | } RGBQUAD; |
WiredHome | 31:c72e12cd5c67 | 69 | |
WiredHome | 32:0e4f2ae512e2 | 70 | //typedef struct /**** Bitmap information structure ****/ |
WiredHome | 32:0e4f2ae512e2 | 71 | // { |
WiredHome | 32:0e4f2ae512e2 | 72 | // BITMAPINFOHEADER bmiHeader; /* Image header */ |
WiredHome | 32:0e4f2ae512e2 | 73 | // RGBQUAD bmiColors[256]; /* Image colormap */ |
WiredHome | 32:0e4f2ae512e2 | 74 | // } BITMAPINFO; |
WiredHome | 31:c72e12cd5c67 | 75 | |
WiredHome | 42:7cbdfd2bbfc5 | 76 | |
WiredHome | 42:7cbdfd2bbfc5 | 77 | #pragma push |
WiredHome | 42:7cbdfd2bbfc5 | 78 | #pragma pack(2) |
WiredHome | 42:7cbdfd2bbfc5 | 79 | |
WiredHome | 42:7cbdfd2bbfc5 | 80 | typedef struct /**** ICO file header structure ****/ |
WiredHome | 42:7cbdfd2bbfc5 | 81 | { |
WiredHome | 42:7cbdfd2bbfc5 | 82 | uint16_t Reserved_zero; // Always zero |
WiredHome | 42:7cbdfd2bbfc5 | 83 | uint16_t icType; // 1 for .ico, 2 for .cur |
WiredHome | 42:7cbdfd2bbfc5 | 84 | uint16_t icImageCount; // number of images in the file |
WiredHome | 42:7cbdfd2bbfc5 | 85 | } ICOFILEHEADER; |
WiredHome | 42:7cbdfd2bbfc5 | 86 | |
WiredHome | 42:7cbdfd2bbfc5 | 87 | typedef struct /**** ICO file Directory Entry structure (1 or more) ****/ |
WiredHome | 42:7cbdfd2bbfc5 | 88 | { |
WiredHome | 42:7cbdfd2bbfc5 | 89 | uint8_t biWidth; /* Width of image */ |
WiredHome | 42:7cbdfd2bbfc5 | 90 | uint8_t biHeight; /* Height of image */ |
WiredHome | 42:7cbdfd2bbfc5 | 91 | uint8_t biClrUsed; /* Number of colors used */ |
WiredHome | 42:7cbdfd2bbfc5 | 92 | uint8_t Reserved_zero; |
WiredHome | 42:7cbdfd2bbfc5 | 93 | uint16_t biPlanes; /* Number of color planes (ICO should be 0 or 1, CUR horz hotspot */ |
WiredHome | 42:7cbdfd2bbfc5 | 94 | uint16_t biBitCount; /* Number of bits per pixel (ICO bits per pixel, CUR vert hotspot */ |
WiredHome | 42:7cbdfd2bbfc5 | 95 | uint32_t biSizeImage; /* Size of image data */ |
WiredHome | 42:7cbdfd2bbfc5 | 96 | uint32_t bfOffBits; /* Offset into file for the bitmap data */ |
WiredHome | 42:7cbdfd2bbfc5 | 97 | } ICODIRENTRY; |
WiredHome | 42:7cbdfd2bbfc5 | 98 | #pragma pop |
WiredHome | 42:7cbdfd2bbfc5 | 99 | |
WiredHome | 42:7cbdfd2bbfc5 | 100 | #define IC_TYPE 0x0001 /* 1 = ICO (icon), 2 = CUR (cursor) */ |
WiredHome | 42:7cbdfd2bbfc5 | 101 | |
WiredHome | 31:c72e12cd5c67 | 102 | #endif // _BITMAP_H_ |