Upload
This commit is contained in:
94
c/libs/GUI/GUI_BMPfile.h
Normal file
94
c/libs/GUI/GUI_BMPfile.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/*****************************************************************************
|
||||
* | File : GUI_BMPfile.h
|
||||
* | Author : Waveshare team
|
||||
* | Function : Hardware underlying interface
|
||||
* | Info :
|
||||
* Used to shield the underlying layers of each master
|
||||
* and enhance portability
|
||||
*----------------
|
||||
* | This version: V2.3
|
||||
* | Date : 2020-07-27
|
||||
* | Info :
|
||||
* -----------------------------------------------------------------------------
|
||||
* V2.3(2022-07-27):
|
||||
* 1.Add GUI_ReadBmp_RGB_4Color()
|
||||
* V2.2(2020-07-08):
|
||||
* 1.Add GUI_ReadBmp_RGB_7Color()
|
||||
* V2.1(2019-10-10):
|
||||
* 1.Add GUI_ReadBmp_4Gray()
|
||||
* V2.0(2018-11-12):
|
||||
* 1.Change file name: GUI_BMP.h -> GUI_BMPfile.h
|
||||
* 2.fix: GUI_ReadBmp()
|
||||
* Now Xstart and Xstart can control the position of the picture normally,
|
||||
* and support the display of images of any size. If it is larger than
|
||||
* the actual display range, it will not be displayed.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documnetation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
#
|
||||
******************************************************************************/
|
||||
#ifndef __GUI_BMPFILE_H
|
||||
#define __GUI_BMPFILE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../Config/DEV_Config.h"
|
||||
|
||||
/*Bitmap file header 14bit*/
|
||||
typedef struct BMP_FILE_HEADER {
|
||||
UWORD bType; //File identifier
|
||||
UDOUBLE bSize; //The size of the file
|
||||
UWORD bReserved1; //Reserved value, must be set to 0
|
||||
UWORD bReserved2; //Reserved value, must be set to 0
|
||||
UDOUBLE bOffset; //The offset from the beginning of the file header to the beginning of the image data bit
|
||||
} __attribute__ ((packed)) BMPFILEHEADER; // 14bit
|
||||
|
||||
/*Bitmap information header 40bit*/
|
||||
typedef struct BMP_INFO {
|
||||
UDOUBLE biInfoSize; //The size of the header
|
||||
UDOUBLE biWidth; //The width of the image
|
||||
UDOUBLE biHeight; //The height of the image
|
||||
UWORD biPlanes; //The number of planes in the image
|
||||
UWORD biBitCount; //The number of bits per pixel
|
||||
UDOUBLE biCompression; //Compression type
|
||||
UDOUBLE bimpImageSize; //The size of the image, in bytes
|
||||
UDOUBLE biXPelsPerMeter; //Horizontal resolution
|
||||
UDOUBLE biYPelsPerMeter; //Vertical resolution
|
||||
UDOUBLE biClrUsed; //The number of colors used
|
||||
UDOUBLE biClrImportant; //The number of important colors
|
||||
} __attribute__ ((packed)) BMPINFOHEADER;
|
||||
|
||||
/*Color table: palette */
|
||||
typedef struct RGB_QUAD {
|
||||
UBYTE rgbBlue; //Blue intensity
|
||||
UBYTE rgbGreen; //Green strength
|
||||
UBYTE rgbRed; //Red intensity
|
||||
UBYTE rgbReversed; //Reserved value
|
||||
} __attribute__ ((packed)) BMPRGBQUAD;
|
||||
/**************************************** end ***********************************************/
|
||||
|
||||
UBYTE GUI_ReadBmp(const char *path, UWORD Xstart, UWORD Ystart);
|
||||
UBYTE GUI_ReadBmp_4Gray(const char *path, UWORD Xstart, UWORD Ystart);
|
||||
UBYTE GUI_ReadBmp_16Gray(const char *path, UWORD Xstart, UWORD Ystart);
|
||||
UBYTE GUI_ReadBmp_RGB_4Color(const char *path, UWORD Xstart, UWORD Ystart);
|
||||
UBYTE GUI_ReadBmp_RGB_6Color(const char *path, UWORD Xstart, UWORD Ystart);
|
||||
UBYTE GUI_ReadBmp_RGB_7Color(const char *path, UWORD Xstart, UWORD Ystart);
|
||||
#endif
|
||||
212
c/libs/GUI/GUI_Paint.h
Normal file
212
c/libs/GUI/GUI_Paint.h
Normal file
@@ -0,0 +1,212 @@
|
||||
/******************************************************************************
|
||||
* | File : GUI_Paint.h
|
||||
* | Author : Waveshare electronics
|
||||
* | Function : Achieve drawing: draw points, lines, boxes, circles and
|
||||
* their size, solid dotted line, solid rectangle hollow
|
||||
* rectangle, solid circle hollow circle.
|
||||
* | Info :
|
||||
* Achieve display characters: Display a single character, string, number
|
||||
* Achieve time display: adaptive size display time minutes and seconds
|
||||
*----------------
|
||||
* | This version: V3.1
|
||||
* | Date : 2019-10-10
|
||||
* | Info :
|
||||
* -----------------------------------------------------------------------------
|
||||
* V3.1(2019-10-10):
|
||||
* 1. Add gray level
|
||||
* PAINT Add Scale
|
||||
* 2. Add void Paint_SetScale(UBYTE scale);
|
||||
*
|
||||
* V3.0(2019-04-18):
|
||||
* 1.Change:
|
||||
* Paint_DrawPoint(..., DOT_STYLE DOT_STYLE)
|
||||
* => Paint_DrawPoint(..., DOT_STYLE Dot_Style)
|
||||
* Paint_DrawLine(..., LINE_STYLE Line_Style, DOT_PIXEL Dot_Pixel)
|
||||
* => Paint_DrawLine(..., DOT_PIXEL Line_width, LINE_STYLE Line_Style)
|
||||
* Paint_DrawRectangle(..., DRAW_FILL Filled, DOT_PIXEL Dot_Pixel)
|
||||
* => Paint_DrawRectangle(..., DOT_PIXEL Line_width, DRAW_FILL Draw_Fill)
|
||||
* Paint_DrawCircle(..., DRAW_FILL Draw_Fill, DOT_PIXEL Dot_Pixel)
|
||||
* => Paint_DrawCircle(..., DOT_PIXEL Line_width, DRAW_FILL Draw_Filll)
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
* V2.0(2018-11-15):
|
||||
* 1.add: Paint_NewImage()
|
||||
* Create an image's properties
|
||||
* 2.add: Paint_SelectImage()
|
||||
* Select the picture to be drawn
|
||||
* 3.add: Paint_SetRotate()
|
||||
* Set the direction of the cache
|
||||
* 4.add: Paint_RotateImage()
|
||||
* Can flip the picture, Support 0-360 degrees,
|
||||
* but only 90.180.270 rotation is better
|
||||
* 4.add: Paint_SetMirroring()
|
||||
* Can Mirroring the picture, horizontal, vertical, origin
|
||||
* 5.add: Paint_DrawString_CN()
|
||||
* Can display Chinese(GB1312)
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
* V1.0(2018-07-17):
|
||||
* Create library
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documnetation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef __GUI_PAINT_H
|
||||
#define __GUI_PAINT_H
|
||||
|
||||
#include "../Config/DEV_Config.h"
|
||||
#include "../Fonts/fonts.h"
|
||||
|
||||
/**
|
||||
* Image attributes
|
||||
**/
|
||||
typedef struct {
|
||||
UBYTE *Image;
|
||||
UWORD Width;
|
||||
UWORD Height;
|
||||
UWORD WidthMemory;
|
||||
UWORD HeightMemory;
|
||||
UWORD Color;
|
||||
UWORD Rotate;
|
||||
UWORD Mirror;
|
||||
UWORD WidthByte;
|
||||
UWORD HeightByte;
|
||||
UWORD Scale;
|
||||
} PAINT;
|
||||
extern PAINT Paint;
|
||||
|
||||
/**
|
||||
* Display rotate
|
||||
**/
|
||||
#define ROTATE_0 0
|
||||
#define ROTATE_90 90
|
||||
#define ROTATE_180 180
|
||||
#define ROTATE_270 270
|
||||
|
||||
/**
|
||||
* Display Flip
|
||||
**/
|
||||
typedef enum {
|
||||
MIRROR_NONE = 0x00,
|
||||
MIRROR_HORIZONTAL = 0x01,
|
||||
MIRROR_VERTICAL = 0x02,
|
||||
MIRROR_ORIGIN = 0x03,
|
||||
} MIRROR_IMAGE;
|
||||
#define MIRROR_IMAGE_DFT MIRROR_NONE
|
||||
|
||||
/**
|
||||
* image color
|
||||
**/
|
||||
#define WHITE 0xFF
|
||||
#define BLACK 0x00
|
||||
#define RED BLACK
|
||||
|
||||
#define IMAGE_BACKGROUND WHITE
|
||||
#define FONT_FOREGROUND BLACK
|
||||
#define FONT_BACKGROUND WHITE
|
||||
|
||||
//4 Gray level
|
||||
#define GRAY1 0x03 //Blackest
|
||||
#define GRAY2 0x02
|
||||
#define GRAY3 0x01 //gray
|
||||
#define GRAY4 0x00 //white
|
||||
|
||||
/**
|
||||
* The size of the point
|
||||
**/
|
||||
typedef enum {
|
||||
DOT_PIXEL_1X1 = 1, // 1 x 1
|
||||
DOT_PIXEL_2X2 , // 2 X 2
|
||||
DOT_PIXEL_3X3 , // 3 X 3
|
||||
DOT_PIXEL_4X4 , // 4 X 4
|
||||
DOT_PIXEL_5X5 , // 5 X 5
|
||||
DOT_PIXEL_6X6 , // 6 X 6
|
||||
DOT_PIXEL_7X7 , // 7 X 7
|
||||
DOT_PIXEL_8X8 , // 8 X 8
|
||||
} DOT_PIXEL;
|
||||
#define DOT_PIXEL_DFT DOT_PIXEL_1X1 //Default dot pilex
|
||||
|
||||
/**
|
||||
* Point size fill style
|
||||
**/
|
||||
typedef enum {
|
||||
DOT_FILL_AROUND = 1, // dot pixel 1 x 1
|
||||
DOT_FILL_RIGHTUP , // dot pixel 2 X 2
|
||||
} DOT_STYLE;
|
||||
#define DOT_STYLE_DFT DOT_FILL_AROUND //Default dot pilex
|
||||
|
||||
/**
|
||||
* Line style, solid or dashed
|
||||
**/
|
||||
typedef enum {
|
||||
LINE_STYLE_SOLID = 0,
|
||||
LINE_STYLE_DOTTED,
|
||||
} LINE_STYLE;
|
||||
|
||||
/**
|
||||
* Whether the graphic is filled
|
||||
**/
|
||||
typedef enum {
|
||||
DRAW_FILL_EMPTY = 0,
|
||||
DRAW_FILL_FULL,
|
||||
} DRAW_FILL;
|
||||
|
||||
/**
|
||||
* Custom structure of a time attribute
|
||||
**/
|
||||
typedef struct {
|
||||
UWORD Year; //0000
|
||||
UBYTE Month; //1 - 12
|
||||
UBYTE Day; //1 - 30
|
||||
UBYTE Hour; //0 - 23
|
||||
UBYTE Min; //0 - 59
|
||||
UBYTE Sec; //0 - 59
|
||||
} PAINT_TIME;
|
||||
extern PAINT_TIME sPaint_time;
|
||||
|
||||
//init and Clear
|
||||
void Paint_NewImage(UBYTE *image, UWORD Width, UWORD Height, UWORD Rotate, UWORD Color);
|
||||
void Paint_SelectImage(UBYTE *image);
|
||||
void Paint_SetRotate(UWORD Rotate);
|
||||
void Paint_SetMirroring(UBYTE mirror);
|
||||
void Paint_SetPixel(UWORD Xpoint, UWORD Ypoint, UWORD Color);
|
||||
void Paint_SetScale(UBYTE scale);
|
||||
|
||||
void Paint_Clear(UWORD Color);
|
||||
void Paint_ClearWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color);
|
||||
|
||||
//Drawing
|
||||
void Paint_DrawPoint(UWORD Xpoint, UWORD Ypoint, UWORD Color, DOT_PIXEL Dot_Pixel, DOT_STYLE Dot_FillWay);
|
||||
void Paint_DrawLine(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color, DOT_PIXEL Line_width, LINE_STYLE Line_Style);
|
||||
void Paint_DrawRectangle(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill);
|
||||
void Paint_DrawCircle(UWORD X_Center, UWORD Y_Center, UWORD Radius, UWORD Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill);
|
||||
|
||||
//Display string
|
||||
void Paint_DrawChar(UWORD Xstart, UWORD Ystart, const char Acsii_Char, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background);
|
||||
void Paint_DrawString_EN(UWORD Xstart, UWORD Ystart, const char * pString, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background);
|
||||
void Paint_DrawString_CN(UWORD Xstart, UWORD Ystart, const char * pString, cFONT* font, UWORD Color_Foreground, UWORD Color_Background);
|
||||
void Paint_DrawNum(UWORD Xpoint, UWORD Ypoint, int32_t Nummber, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background);
|
||||
void Paint_DrawNumDecimals(UWORD Xpoint, UWORD Ypoint, double Nummber, sFONT* Font, UWORD Digit, UWORD Color_Foreground, UWORD Color_Background); // Able to display decimals
|
||||
void Paint_DrawTime(UWORD Xstart, UWORD Ystart, PAINT_TIME *pTime, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background);
|
||||
|
||||
//pic
|
||||
void Paint_DrawBitMap(const unsigned char* image_buffer);
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user