GUI_BMPfile.h 4.0 KB

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