This is the David Smart RA8875 Library with mods for working with FRDM-K64F

Committer:
lamell
Date:
Tue Mar 10 21:28:18 2020 -0400
Revision:
199:08eb9e55567b
Parent:
197:853d08e2fb53
Subtle changes in the way the library behaves.

Who changed what in which revision?

UserRevisionLine numberNew 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 197:853d08e2fb53 21 // must align to 2-byte boundaries so it doesn't alter the memory image when
WiredHome 197:853d08e2fb53 22
WiredHome 32:0e4f2ae512e2 23 // bytes are read from the file system into this footprint.
WiredHome 190:3132b7dfad82 24 #ifdef __GNUC__
WiredHome 190:3132b7dfad82 25 #pragma pack(push, 1)
WiredHome 190:3132b7dfad82 26 #define ALIGNMENT
WiredHome 190:3132b7dfad82 27 #else
WiredHome 190:3132b7dfad82 28 #define ALIGNMENT
WiredHome 31:c72e12cd5c67 29 #pragma push
WiredHome 31:c72e12cd5c67 30 #pragma pack(2)
WiredHome 190:3132b7dfad82 31 #endif
WiredHome 31:c72e12cd5c67 32
WiredHome 125:7a0b70f56550 33 /// Bitmap file header
WiredHome 42:7cbdfd2bbfc5 34 typedef struct /**** BMP file header structure ****/
WiredHome 31:c72e12cd5c67 35 {
WiredHome 197:853d08e2fb53 36 uint16_t bfType; ///< Magic number for file
WiredHome 197:853d08e2fb53 37 uint32_t bfSize; ///< Size of file
WiredHome 125:7a0b70f56550 38 uint16_t bfReserved1; ///< reserved placeholder for the structure footprint
WiredHome 125:7a0b70f56550 39 uint16_t bfReserved2; ///< reserved placeholder for the structure footprint
WiredHome 197:853d08e2fb53 40 uint32_t bfOffBits; ///< Offset to bitmap data
WiredHome 197:853d08e2fb53 41
WiredHome 190:3132b7dfad82 42 } BITMAPFILEHEADER ALIGNMENT; // Size: 14B
WiredHome 197:853d08e2fb53 43 #if (defined(WIN32))
WiredHome 190:3132b7dfad82 44 static_assert(sizeof(BITMAPFILEHEADER) == 14, "Alignment Error");
WiredHome 190:3132b7dfad82 45 #endif
WiredHome 31:c72e12cd5c67 46
WiredHome 125:7a0b70f56550 47 /// Bitmap information header
WiredHome 31:c72e12cd5c67 48 typedef struct /**** BMP file info structure ****/
WiredHome 31:c72e12cd5c67 49 {
WiredHome 197:853d08e2fb53 50 uint32_t biSize; ///< Size of info header
WiredHome 197:853d08e2fb53 51 uint32_t biWidth; ///< Width of image
WiredHome 197:853d08e2fb53 52 uint32_t biHeight; ///< Height of image
WiredHome 197:853d08e2fb53 53 uint16_t biPlanes; ///< Number of color planes
WiredHome 197:853d08e2fb53 54 uint16_t biBitCount; ///< Number of bits per pixel
WiredHome 197:853d08e2fb53 55 uint32_t biCompression; ///< Type of compression to use
WiredHome 197:853d08e2fb53 56 uint32_t biSizeImage; ///< Size of image data
WiredHome 197:853d08e2fb53 57 int32_t biXPelsPerMeter; ///< X pixels per meter
WiredHome 197:853d08e2fb53 58 int32_t biYPelsPerMeter; ///< Y pixels per meter
WiredHome 197:853d08e2fb53 59 uint32_t biClrUsed; ///< Number of colors used
WiredHome 197:853d08e2fb53 60 uint32_t biClrImportant; ///< Number of important colors
WiredHome 190:3132b7dfad82 61 } BITMAPINFOHEADER ALIGNMENT; // Size: 40B
WiredHome 190:3132b7dfad82 62 #ifdef __GNUC__
WiredHome 190:3132b7dfad82 63 #pragma pack(pop)
WiredHome 190:3132b7dfad82 64 #undef ALIGNMENT
WiredHome 190:3132b7dfad82 65 #else
WiredHome 31:c72e12cd5c67 66 #pragma pop
WiredHome 190:3132b7dfad82 67 #endif
WiredHome 31:c72e12cd5c67 68
WiredHome 32:0e4f2ae512e2 69 #define BF_TYPE 0x4D42 /* "MB" */
WiredHome 32:0e4f2ae512e2 70
WiredHome 31:c72e12cd5c67 71 /*
WiredHome 31:c72e12cd5c67 72 * Constants for the biCompression field...
WiredHome 31:c72e12cd5c67 73 */
WiredHome 31:c72e12cd5c67 74
WiredHome 31:c72e12cd5c67 75 # define BI_RGB 0 /* No compression - straight BGR data */
WiredHome 31:c72e12cd5c67 76 # define BI_RLE8 1 /* 8-bit run-length compression */
WiredHome 31:c72e12cd5c67 77 # define BI_RLE4 2 /* 4-bit run-length compression */
WiredHome 31:c72e12cd5c67 78 # define BI_BITFIELDS 3 /* RGB bitmap with RGB masks */
WiredHome 31:c72e12cd5c67 79
WiredHome 125:7a0b70f56550 80 /// An RGB Quad data type used by the bitmap driver.
WiredHome 31:c72e12cd5c67 81 typedef struct /**** Colormap entry structure ****/
WiredHome 31:c72e12cd5c67 82 {
WiredHome 197:853d08e2fb53 83 uint8_t rgbBlue; ///< Blue value
WiredHome 197:853d08e2fb53 84 uint8_t rgbGreen; ///< Green value
WiredHome 197:853d08e2fb53 85 uint8_t rgbRed; ///< Red value
WiredHome 197:853d08e2fb53 86 uint8_t rgbReserved; ///< Reserved
WiredHome 31:c72e12cd5c67 87 } RGBQUAD;
WiredHome 31:c72e12cd5c67 88
WiredHome 32:0e4f2ae512e2 89 //typedef struct /**** Bitmap information structure ****/
WiredHome 32:0e4f2ae512e2 90 // {
WiredHome 32:0e4f2ae512e2 91 // BITMAPINFOHEADER bmiHeader; /* Image header */
WiredHome 32:0e4f2ae512e2 92 // RGBQUAD bmiColors[256]; /* Image colormap */
WiredHome 32:0e4f2ae512e2 93 // } BITMAPINFO;
WiredHome 31:c72e12cd5c67 94
WiredHome 190:3132b7dfad82 95 #ifdef __GNUC__
WiredHome 190:3132b7dfad82 96 #pragma pack(push, 1)
WiredHome 190:3132b7dfad82 97 #define ALIGNMENT
WiredHome 190:3132b7dfad82 98 #else
WiredHome 42:7cbdfd2bbfc5 99 #pragma push
WiredHome 42:7cbdfd2bbfc5 100 #pragma pack(2)
WiredHome 190:3132b7dfad82 101 #endif
WiredHome 42:7cbdfd2bbfc5 102
WiredHome 125:7a0b70f56550 103 /// Icon file type file header.
WiredHome 42:7cbdfd2bbfc5 104 typedef struct /**** ICO file header structure ****/
WiredHome 42:7cbdfd2bbfc5 105 {
WiredHome 125:7a0b70f56550 106 uint16_t Reserved_zero; ///< Always zero
WiredHome 125:7a0b70f56550 107 uint16_t icType; ///< 1 for .ico, 2 for .cur
WiredHome 197:853d08e2fb53 108 uint16_t icImageCount; ///< number of images in the file
WiredHome 42:7cbdfd2bbfc5 109 } ICOFILEHEADER;
WiredHome 125:7a0b70f56550 110
WiredHome 125:7a0b70f56550 111 /// Icon file type directory entry structure
WiredHome 42:7cbdfd2bbfc5 112 typedef struct /**** ICO file Directory Entry structure (1 or more) ****/
WiredHome 42:7cbdfd2bbfc5 113 {
WiredHome 125:7a0b70f56550 114 uint8_t biWidth; ///< Width of image
WiredHome 125:7a0b70f56550 115 uint8_t biHeight; ///< Height of image
WiredHome 125:7a0b70f56550 116 uint8_t biClrUsed; ///< Number of colors used
WiredHome 125:7a0b70f56550 117 uint8_t Reserved_zero; ///< reserved placeholder for the structure footprint
WiredHome 125:7a0b70f56550 118 uint16_t biPlanes; ///< Number of color planes (ICO should be 0 or 1, CUR horz hotspot
WiredHome 125:7a0b70f56550 119 uint16_t biBitCount; ///< Number of bits per pixel (ICO bits per pixel, CUR vert hotspot
WiredHome 125:7a0b70f56550 120 uint32_t biSizeImage; ///< Size of image data
WiredHome 125:7a0b70f56550 121 uint32_t bfOffBits; ///< Offset into file for the bitmap data
WiredHome 42:7cbdfd2bbfc5 122 } ICODIRENTRY;
WiredHome 190:3132b7dfad82 123 #ifdef __GNUC__
WiredHome 190:3132b7dfad82 124 #pragma pack(pop)
WiredHome 190:3132b7dfad82 125 #undef ALIGNMENT
WiredHome 190:3132b7dfad82 126 #else
WiredHome 42:7cbdfd2bbfc5 127 #pragma pop
WiredHome 190:3132b7dfad82 128 #endif
WiredHome 42:7cbdfd2bbfc5 129
WiredHome 42:7cbdfd2bbfc5 130 #define IC_TYPE 0x0001 /* 1 = ICO (icon), 2 = CUR (cursor) */
WiredHome 42:7cbdfd2bbfc5 131
WiredHome 31:c72e12cd5c67 132 #endif // _BITMAP_H_