2
0

GUI_BMPfile.h 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. #include <stdio.h>
  46. #include <fcntl.h>
  47. #include <unistd.h>
  48. #include <stdint.h>
  49. #include "DEV_Config.h"
  50. /*Bitmap file header 14bit*/
  51. typedef struct BMP_FILE_HEADER {
  52. UWORD bType; //File identifier
  53. UDOUBLE bSize; //The size of the file
  54. UWORD bReserved1; //Reserved value, must be set to 0
  55. UWORD bReserved2; //Reserved value, must be set to 0
  56. UDOUBLE bOffset; //The offset from the beginning of the file header to the beginning of the image data bit
  57. } __attribute__ ((packed)) BMPFILEHEADER; // 14bit
  58. /*Bitmap information header 40bit*/
  59. typedef struct BMP_INFO {
  60. UDOUBLE biInfoSize; //The size of the header
  61. UDOUBLE biWidth; //The width of the image
  62. UDOUBLE biHeight; //The height of the image
  63. UWORD biPlanes; //The number of planes in the image
  64. UWORD biBitCount; //The number of bits per pixel
  65. UDOUBLE biCompression; //Compression type
  66. UDOUBLE bimpImageSize; //The size of the image, in bytes
  67. UDOUBLE biXPelsPerMeter; //Horizontal resolution
  68. UDOUBLE biYPelsPerMeter; //Vertical resolution
  69. UDOUBLE biClrUsed; //The number of colors used
  70. UDOUBLE biClrImportant; //The number of important colors
  71. } __attribute__ ((packed)) BMPINFOHEADER;
  72. /*Color table: palette */
  73. typedef struct RGB_QUAD {
  74. UBYTE rgbBlue; //Blue intensity
  75. UBYTE rgbGreen; //Green strength
  76. UBYTE rgbRed; //Red intensity
  77. UBYTE rgbReversed; //Reserved value
  78. } __attribute__ ((packed)) BMPRGBQUAD;
  79. /**************************************** end ***********************************************/
  80. UBYTE GUI_ReadBmp(const char *path, UWORD Xstart, UWORD Ystart);
  81. UBYTE GUI_ReadBmp_4Gray(const char *path, UWORD Xstart, UWORD Ystart);
  82. UBYTE GUI_ReadBmp_RGB_7Color(const char *path, UWORD Xstart, UWORD Ystart);
  83. #endif