GUI_BMPfile.h 4.5 KB

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