GUI_BMPfile.h (3962B)
1 /***************************************************************************** 2 * | File : GUI_BMPfile.h 3 * | Author : Waveshare team 4 * | Function : Hardware underlying interface 5 * | Info : 6 * Used to shield the underlying layers of each master 7 * and enhance portability 8 *---------------- 9 * | This version: V2.2 10 * | Date : 2020-07-08 11 * | Info : 12 * ----------------------------------------------------------------------------- 13 * V2.2(2020-07-08): 14 * 1.Add GUI_ReadBmp_RGB_7Color() 15 * V2.1(2019-10-10): 16 * 1.Add GUI_ReadBmp_4Gray() 17 * V2.0(2018-11-12): 18 * 1.Change file name: GUI_BMP.h -> GUI_BMPfile.h 19 * 2.fix: GUI_ReadBmp() 20 * Now Xstart and Xstart can control the position of the picture normally, 21 * and support the display of images of any size. If it is larger than 22 * the actual display range, it will not be displayed. 23 # 24 # Permission is hereby granted, free of charge, to any person obtaining a copy 25 # of this software and associated documnetation files (the "Software"), to deal 26 # in the Software without restriction, including without limitation the rights 27 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 28 # copies of the Software, and to permit persons to whom the Software is 29 # furished to do so, subject to the following conditions: 30 # 31 # The above copyright notice and this permission notice shall be included in 32 # all copies or substantial portions of the Software. 33 # 34 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 35 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 36 # FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 37 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 38 # LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 39 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 40 # THE SOFTWARE. 41 # 42 ******************************************************************************/ 43 #ifndef __GUI_BMPFILE_H 44 #define __GUI_BMPFILE_H 45 46 #include <stdio.h> 47 #include <fcntl.h> 48 #include <unistd.h> 49 #include <stdint.h> 50 51 #include "DEV_Config.h" 52 53 /*Bitmap file header 14bit*/ 54 typedef struct BMP_FILE_HEADER { 55 UWORD bType; //File identifier 56 UDOUBLE bSize; //The size of the file 57 UWORD bReserved1; //Reserved value, must be set to 0 58 UWORD bReserved2; //Reserved value, must be set to 0 59 UDOUBLE bOffset; //The offset from the beginning of the file header to the beginning of the image data bit 60 } __attribute__ ((packed)) BMPFILEHEADER; // 14bit 61 62 /*Bitmap information header 40bit*/ 63 typedef struct BMP_INFO { 64 UDOUBLE biInfoSize; //The size of the header 65 UDOUBLE biWidth; //The width of the image 66 UDOUBLE biHeight; //The height of the image 67 UWORD biPlanes; //The number of planes in the image 68 UWORD biBitCount; //The number of bits per pixel 69 UDOUBLE biCompression; //Compression type 70 UDOUBLE bimpImageSize; //The size of the image, in bytes 71 UDOUBLE biXPelsPerMeter; //Horizontal resolution 72 UDOUBLE biYPelsPerMeter; //Vertical resolution 73 UDOUBLE biClrUsed; //The number of colors used 74 UDOUBLE biClrImportant; //The number of important colors 75 } __attribute__ ((packed)) BMPINFOHEADER; 76 77 /*Color table: palette */ 78 typedef struct RGB_QUAD { 79 UBYTE rgbBlue; //Blue intensity 80 UBYTE rgbGreen; //Green strength 81 UBYTE rgbRed; //Red intensity 82 UBYTE rgbReversed; //Reserved value 83 } __attribute__ ((packed)) BMPRGBQUAD; 84 /**************************************** end ***********************************************/ 85 86 UBYTE GUI_ReadBmp(const char *path, UWORD Xstart, UWORD Ystart); 87 UBYTE GUI_ReadBmp_4Gray(const char *path, UWORD Xstart, UWORD Ystart); 88 UBYTE GUI_ReadBmp_RGB_7Color(const char *path, UWORD Xstart, UWORD Ystart); 89 #endif