UP
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
#define GET_BIT(x, bit) ((x & (1 << bit)) >> bit)
|
||||
|
||||
uint32_t RGB565_to_RGB888(uint16_t rgb565, bool isBGR) {
|
||||
uint32_t RGB565_to_ARGB8888(uint16_t rgb565, bool isBGR) {
|
||||
uint8_t r5 = (rgb565 >> 11) & 0x1F;
|
||||
uint8_t g6 = (rgb565 >> 5) & 0x3F;
|
||||
uint8_t b5 = rgb565 & 0x1F;
|
||||
@@ -14,12 +14,11 @@ uint32_t RGB565_to_RGB888(uint16_t rgb565, bool isBGR) {
|
||||
uint8_t b8 = (b5 * 527 + 23) >> 6;
|
||||
|
||||
if (isBGR) {
|
||||
return (b8 << 16) | (g8 << 8) | r8;
|
||||
return 0xFF000000 | (b8 << 16) | (g8 << 8) | r8;
|
||||
} else {
|
||||
return (r8 << 16) | (g8 << 8) | b8;
|
||||
return 0xFF000000 | (r8 << 16) | (g8 << 8) | b8;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef USER_SDL3
|
||||
static uint32_t pixelColor, backgroundColor;
|
||||
static int scaleFactor, w, h;
|
||||
@@ -211,8 +210,8 @@ void SIM_Color_ImgFromBuffer(SIM_Display_t *display, uint32_t *buf, uint16_t x,
|
||||
void
|
||||
SIM_Color_FillFromBuffer(SIM_Display_t *display, uint32_t *buf, uint16_t xs, uint16_t ys, uint16_t xe, uint16_t ye) {
|
||||
SIM_Color_t color;
|
||||
for (int y_i = ys; y_i < ye; y_i++) {
|
||||
for (int x_i = xs; x_i < xe; x_i++) {
|
||||
for (int y_i = ys; y_i <= ye; y_i++) {
|
||||
for (int x_i = xs; x_i <= xe; x_i++) {
|
||||
color.full = *buf;
|
||||
SIM_Color_DrawPiexl(display, color, x_i, y_i);
|
||||
buf++;
|
||||
@@ -221,6 +220,9 @@ SIM_Color_FillFromBuffer(SIM_Display_t *display, uint32_t *buf, uint16_t xs, uin
|
||||
SDL_RenderPresent(display->renderer);
|
||||
}
|
||||
|
||||
void SIM_Display_Refresh(SIM_Display_t *display) {
|
||||
SDL_RenderPresent(display->renderer);
|
||||
}
|
||||
|
||||
void SIM_Display_STOP(SIM_Display_t *display) {
|
||||
SDL_DestroyRenderer(display->renderer);
|
||||
|
@@ -153,7 +153,6 @@ typedef struct {
|
||||
bool SIM_Display_Init(char *name, int width, int height, uint32_t pixcolor, uint32_t backcolor, int scale,
|
||||
SIM_Display_t *display);
|
||||
|
||||
|
||||
/**
|
||||
* @brief 在指定的坐标位置绘制一个像素点
|
||||
* @param display: [输入] 输入窗口实例
|
||||
@@ -163,6 +162,13 @@ bool SIM_Display_Init(char *name, int width, int height, uint32_t pixcolor, uint
|
||||
*/
|
||||
void SIM_Color_DrawPiexl(SIM_Display_t *display, SIM_Color_t color, uint16_t x, uint16_t y);
|
||||
|
||||
/**
|
||||
* @brief 从颜色缓冲区绘制单色图像到模拟显示器
|
||||
* @param display 模拟显示器指针
|
||||
* @param buf 颜色缓冲区指针
|
||||
* @param width 绘制区域宽度
|
||||
* @param height 绘制区域高度
|
||||
*/
|
||||
void SIM_OneColor_DrawFromBuffer(SIM_Display_t *display, uint8_t *buf, uint16_t width, uint16_t height);
|
||||
|
||||
/**
|
||||
@@ -176,8 +182,8 @@ void SIM_OneColor_DrawFromBuffer(SIM_Display_t *display, uint8_t *buf, uint16_t
|
||||
* @return void
|
||||
* @example SIM_Color_ImgFromBuffer(buf, 100, 50, 320, 240);
|
||||
**/
|
||||
void
|
||||
SIM_Color_ImgFromBuffer(SIM_Display_t *display, uint32_t *buf, uint16_t x, uint16_t y, uint16_t width, uint16_t height);
|
||||
void SIM_Color_ImgFromBuffer(SIM_Display_t *display, uint32_t *buf, uint16_t x, uint16_t y,
|
||||
uint16_t width, uint16_t height);
|
||||
|
||||
/**
|
||||
* @brief 从缓冲区中填充颜色
|
||||
@@ -193,6 +199,12 @@ SIM_Color_ImgFromBuffer(SIM_Display_t *display, uint32_t *buf, uint16_t x, uint1
|
||||
void
|
||||
SIM_Color_FillFromBuffer(SIM_Display_t *display, uint32_t *buf, uint16_t xs, uint16_t ys, uint16_t xe, uint16_t ye);
|
||||
|
||||
/**
|
||||
* @brief 刷新模拟显示器
|
||||
*
|
||||
* @param display 模拟显示器指针
|
||||
*/
|
||||
void SIM_Display_Refresh(SIM_Display_t *display);
|
||||
|
||||
/**
|
||||
* @brief 停止模拟 显示
|
||||
@@ -204,7 +216,7 @@ void SIM_Display_STOP(SIM_Display_t *display);
|
||||
#endif
|
||||
|
||||
|
||||
uint32_t RGB565_to_RGB888(uint16_t rgb565, bool isBGR);
|
||||
uint32_t RGB565_to_ARGB8888(uint16_t rgb565, bool isBGR);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Reference in New Issue
Block a user