Added the function of pasting image data to buffer (STM32)

This commit is contained in:
SSYYL 2021-12-17 15:10:00 +08:00
commit 7a1e6ae4cc
11 changed files with 1387 additions and 833 deletions

View file

@ -777,6 +777,36 @@ void Paint_DrawBitMap(const unsigned char* image_buffer)
}
}
/******************************************************************************
function: paste monochrome bitmap to a frame buff
parameter:
image_buffer A picture data converted to a bitmap
xStart: The starting x coordinate
yStart: The starting y coordinate
imageWidth: Original image width
imageHeight: Original image height
flipColor: Whether the color is reversed
info:
Use this function to paste image data into a buffer
******************************************************************************/
void Paint_DrawBitMap_Paste(const unsigned char* image_buffer, UWORD xStart, UWORD yStart, UWORD imageWidth, UWORD imageHeight, UBYTE flipColor)
{
UBYTE color, srcImage;
UWORD x, y;
UWORD width = (imageWidth%8==0 ? imageWidth/8 : imageWidth/8+1);
for (y = 0; y < imageHeight; y++) {
for (x = 0; x < imageWidth; x++) {
srcImage = image_buffer[y*width + x/8];
if(flipColor)
color = (((srcImage<<(x%8) & 0x80) == 0) ? 1 : 0);
else
color = (((srcImage<<(x%8) & 0x80) == 0) ? 0 : 1);
Paint_SetPixel(x+xStart, y+yStart, color);
}
}
}
///******************************************************************************
//function: SDisplay half of monochrome bitmap
//parameter:

View file

@ -116,6 +116,9 @@ typedef enum {
#define FONT_FOREGROUND BLACK
#define FONT_BACKGROUND WHITE
#define TRUE 1
#define FALSE 0
//4 Gray level
#define GRAY1 0x03 //Blackest
#define GRAY2 0x02
@ -200,6 +203,7 @@ void Paint_DrawTime(UWORD Xstart, UWORD Ystart, PAINT_TIME *pTime, sFONT* Font,
//pic
void Paint_DrawBitMap(const unsigned char* image_buffer);
void Paint_DrawBitMap_Paste(const unsigned char* image_buffer, UWORD Xstart, UWORD Ystart, UWORD imageWidth, UWORD imageHeight, UBYTE flipColor);
//void Paint_DrawBitMap_Half(const unsigned char* image_buffer, UBYTE Region);
//void Paint_DrawBitMap_OneQuarter(const unsigned char* image_buffer, UBYTE Region);
//void Paint_DrawBitMap_OneEighth(const unsigned char* image_buffer, UBYTE Region);