GUI_BMPfile.h 3.7 KB

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