Increased SPI frequency from 5Mhz to 10MHz
Fork of RA8875 by
Bitmap.h@31:c72e12cd5c67, 2014-01-20 (annotated)
- Committer:
- WiredHome
- Date:
- Mon Jan 20 19:19:48 2014 +0000
- Revision:
- 31:c72e12cd5c67
- Child:
- 32:0e4f2ae512e2
Support for Bitmap graphics (tested 4-bit and 8-bit formats, have not tested 1-bit or 24-bit).
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 | 31:c72e12cd5c67 | 21 | #pragma push |
WiredHome | 31:c72e12cd5c67 | 22 | #pragma pack(2) |
WiredHome | 31:c72e12cd5c67 | 23 | |
WiredHome | 31:c72e12cd5c67 | 24 | typedef struct /**** BMP file header structure ****/ |
WiredHome | 31:c72e12cd5c67 | 25 | { |
WiredHome | 31:c72e12cd5c67 | 26 | uint16_t bfType; /* Magic number for file */ |
WiredHome | 31:c72e12cd5c67 | 27 | uint32_t bfSize; /* Size of file */ |
WiredHome | 31:c72e12cd5c67 | 28 | uint16_t bfReserved1; /* Reserved */ |
WiredHome | 31:c72e12cd5c67 | 29 | uint16_t bfReserved2; /* ... */ |
WiredHome | 31:c72e12cd5c67 | 30 | uint32_t bfOffBits; /* Offset to bitmap data */ |
WiredHome | 31:c72e12cd5c67 | 31 | } BITMAPFILEHEADER; |
WiredHome | 31:c72e12cd5c67 | 32 | |
WiredHome | 31:c72e12cd5c67 | 33 | #define BF_TYPE 0x4D42 /* "MB" */ |
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 | 31:c72e12cd5c67 | 51 | /* |
WiredHome | 31:c72e12cd5c67 | 52 | * Constants for the biCompression field... |
WiredHome | 31:c72e12cd5c67 | 53 | */ |
WiredHome | 31:c72e12cd5c67 | 54 | |
WiredHome | 31:c72e12cd5c67 | 55 | # define BI_RGB 0 /* No compression - straight BGR data */ |
WiredHome | 31:c72e12cd5c67 | 56 | # define BI_RLE8 1 /* 8-bit run-length compression */ |
WiredHome | 31:c72e12cd5c67 | 57 | # define BI_RLE4 2 /* 4-bit run-length compression */ |
WiredHome | 31:c72e12cd5c67 | 58 | # define BI_BITFIELDS 3 /* RGB bitmap with RGB masks */ |
WiredHome | 31:c72e12cd5c67 | 59 | |
WiredHome | 31:c72e12cd5c67 | 60 | typedef struct /**** Colormap entry structure ****/ |
WiredHome | 31:c72e12cd5c67 | 61 | { |
WiredHome | 31:c72e12cd5c67 | 62 | uint8_t rgbBlue; /* Blue value */ |
WiredHome | 31:c72e12cd5c67 | 63 | uint8_t rgbGreen; /* Green value */ |
WiredHome | 31:c72e12cd5c67 | 64 | uint8_t rgbRed; /* Red value */ |
WiredHome | 31:c72e12cd5c67 | 65 | uint8_t rgbReserved; /* Reserved */ |
WiredHome | 31:c72e12cd5c67 | 66 | } RGBQUAD; |
WiredHome | 31:c72e12cd5c67 | 67 | |
WiredHome | 31:c72e12cd5c67 | 68 | typedef struct /**** Bitmap information structure ****/ |
WiredHome | 31:c72e12cd5c67 | 69 | { |
WiredHome | 31:c72e12cd5c67 | 70 | BITMAPINFOHEADER bmiHeader; /* Image header */ |
WiredHome | 31:c72e12cd5c67 | 71 | RGBQUAD bmiColors[256]; /* Image colormap */ |
WiredHome | 31:c72e12cd5c67 | 72 | } BITMAPINFO; |
WiredHome | 31:c72e12cd5c67 | 73 | |
WiredHome | 31:c72e12cd5c67 | 74 | |
WiredHome | 31:c72e12cd5c67 | 75 | /* |
WiredHome | 31:c72e12cd5c67 | 76 | * Prototypes... |
WiredHome | 31:c72e12cd5c67 | 77 | */ |
WiredHome | 31:c72e12cd5c67 | 78 | |
WiredHome | 31:c72e12cd5c67 | 79 | //extern GLubyte *LoadDIBitmap(const char *filename, BITMAPINFO **info); |
WiredHome | 31:c72e12cd5c67 | 80 | //extern int32_t SaveDIBitmap(const char *filename, BITMAPINFO *info, |
WiredHome | 31:c72e12cd5c67 | 81 | // GLubyte *bits); |
WiredHome | 31:c72e12cd5c67 | 82 | |
WiredHome | 31:c72e12cd5c67 | 83 | #endif // _BITMAP_H_ |