mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-29 18:48:09 +08:00
change rgb565 to bgr565 and format code
This commit is contained in:
parent
492462be52
commit
b611e64159
@ -268,17 +268,17 @@
|
||||
#include "assets/inc/images/3.data"
|
||||
#include "assets/inc/images/arrow_left_n.data"
|
||||
#include "assets/inc/images/edit_clear_p.data"
|
||||
#endif/*WITH_STB_IMAGE*/
|
||||
#endif /*WITH_STB_IMAGE*/
|
||||
#ifdef WITH_STB_FONT
|
||||
#ifdef WITH_MINI_FONT
|
||||
#include "assets/inc/fonts/default.mini.res"
|
||||
#else/*WITH_MINI_FONT*/
|
||||
#else /*WITH_MINI_FONT*/
|
||||
#include "assets/inc/fonts/default.res"
|
||||
#endif/*WITH_MINI_FONT*/
|
||||
#else/*WITH_STB_FONT*/
|
||||
#endif /*WITH_MINI_FONT*/
|
||||
#else /*WITH_STB_FONT*/
|
||||
#include "assets/inc/fonts/default.data"
|
||||
#endif/*WITH_STB_FONT*/
|
||||
#endif/*WITH_FS_RES*/
|
||||
#endif /*WITH_STB_FONT*/
|
||||
#endif /*WITH_FS_RES*/
|
||||
|
||||
ret_t assets_init(void) {
|
||||
assets_manager_t* rm = assets_manager();
|
||||
|
@ -65,9 +65,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* 如果定义本宏,将不透明的PNG图片解码成RGB565格式,建议定义。
|
||||
* 如果定义本宏,将不透明的PNG图片解码成BGR565格式,建议定义。
|
||||
*
|
||||
* #define WITH_BITMAP_RGB565 1
|
||||
* #define WITH_BITMAP_BGR565 1
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -57,7 +57,7 @@ ret_t bitmap_destroy(bitmap_t* bitmap) {
|
||||
|
||||
#include "base/pixel_pack_unpack.h"
|
||||
|
||||
ret_t bitmap_rgba_to_rgb565(bitmap_t* image, uint16_t* output) {
|
||||
ret_t bitmap_rgba_to_bgr565(bitmap_t* image, uint16_t* output) {
|
||||
uint32_t i = 0;
|
||||
uint16_t* d = output;
|
||||
uint32_t nr = image->w * image->h;
|
||||
|
@ -298,7 +298,7 @@ typedef enum _image_draw_type_t {
|
||||
|
||||
uint32_t bitmap_get_bpp(bitmap_t* bitmap);
|
||||
ret_t bitmap_rgba_to_bgra(bitmap_t* image);
|
||||
ret_t bitmap_rgba_to_rgb565(bitmap_t* image, uint16_t* output);
|
||||
ret_t bitmap_rgba_to_bgr565(bitmap_t* image, uint16_t* output);
|
||||
bitmap_t* bitmap_create_ex(uint32_t w, uint32_t h, bitmap_format_t format);
|
||||
ret_t bitmap_get_pixel(bitmap_t* bitmap, uint32_t x, uint32_t y, rgba_t* rgba);
|
||||
|
||||
|
@ -8,4 +8,3 @@
|
||||
|
||||
#define rgb_to_bgr565(r, g, b) ((((r) >> 3) << 11) | (((g) >> 2) << 5) | ((b) >> 3))
|
||||
#define rgb_to_image8888(r, g, b) rgba_to_image8888(r, g, b, (uint8_t)0xff)
|
||||
|
||||
|
@ -41,8 +41,8 @@
|
||||
DMA2D->IFCR = DMA2D_IFSR_CTCIF; \
|
||||
} while (0);
|
||||
|
||||
#define PIXEL_FORMAT_ARGB8888 0X00
|
||||
#define PIXEL_FORMAT_RGB565 0X02
|
||||
#define PIXEL_FORMAT_BGRA8888 0X00
|
||||
#define PIXEL_FORMAT_BGR565 0X02
|
||||
|
||||
ret_t g2d_fill_rect(bitmap_t* fb, rect_t* dst, color_t c) {
|
||||
uint16_t x = 0;
|
||||
@ -56,7 +56,7 @@ ret_t g2d_fill_rect(bitmap_t* fb, rect_t* dst, color_t c) {
|
||||
uint16_t o_pixsize = 0;
|
||||
|
||||
return_value_if_fail(fb != NULL && fb->data != NULL && dst != NULL, RET_BAD_PARAMS);
|
||||
return_value_if_fail(fb->format == BITMAP_FMT_RGB565 || fb->format == BITMAP_FMT_BGRA8888,
|
||||
return_value_if_fail(fb->format == BITMAP_FMT_BGR565 || fb->format == BITMAP_FMT_BGRA8888,
|
||||
RET_BAD_PARAMS);
|
||||
|
||||
x = dst->x;
|
||||
@ -64,13 +64,13 @@ ret_t g2d_fill_rect(bitmap_t* fb, rect_t* dst, color_t c) {
|
||||
w = dst->w;
|
||||
h = dst->h;
|
||||
|
||||
if (fb->format == BITMAP_FMT_RGB565) {
|
||||
if (fb->format == BITMAP_FMT_BGR565) {
|
||||
o_pixsize = 2;
|
||||
o_format = PIXEL_FORMAT_RGB565;
|
||||
o_format = PIXEL_FORMAT_BGR565;
|
||||
color = ((((c.rgba.r) >> 3) << 11) | (((c.rgba.g) >> 2) << 5) | ((c.rgba.b) >> 3));
|
||||
} else {
|
||||
o_pixsize = 4;
|
||||
o_format = PIXEL_FORMAT_ARGB8888;
|
||||
o_format = PIXEL_FORMAT_BGRA8888;
|
||||
color = c.color;
|
||||
}
|
||||
|
||||
@ -112,9 +112,9 @@ ret_t g2d_copy_image(bitmap_t* fb, bitmap_t* img, rect_t* src, xy_t x, xy_t y) {
|
||||
|
||||
return_value_if_fail(fb != NULL && fb->data != NULL, RET_BAD_PARAMS);
|
||||
return_value_if_fail(img != NULL && img->data != NULL && src != NULL, RET_BAD_PARAMS);
|
||||
return_value_if_fail(fb->format == BITMAP_FMT_RGB565 || fb->format == BITMAP_FMT_BGRA8888,
|
||||
return_value_if_fail(fb->format == BITMAP_FMT_BGR565 || fb->format == BITMAP_FMT_BGRA8888,
|
||||
RET_BAD_PARAMS);
|
||||
return_value_if_fail(img->format == BITMAP_FMT_RGB565 || img->format == BITMAP_FMT_BGRA8888,
|
||||
return_value_if_fail(img->format == BITMAP_FMT_BGR565 || img->format == BITMAP_FMT_BGRA8888,
|
||||
RET_BAD_PARAMS);
|
||||
|
||||
sx = src->x;
|
||||
@ -123,20 +123,20 @@ ret_t g2d_copy_image(bitmap_t* fb, bitmap_t* img, rect_t* src, xy_t x, xy_t y) {
|
||||
h = src->h;
|
||||
iw = img->w;
|
||||
|
||||
if (fb->format == BITMAP_FMT_RGB565) {
|
||||
if (fb->format == BITMAP_FMT_BGR565) {
|
||||
o_pixsize = 2;
|
||||
o_format = PIXEL_FORMAT_RGB565;
|
||||
o_format = PIXEL_FORMAT_BGR565;
|
||||
} else {
|
||||
o_pixsize = 4;
|
||||
o_format = PIXEL_FORMAT_ARGB8888;
|
||||
o_format = PIXEL_FORMAT_BGRA8888;
|
||||
}
|
||||
|
||||
if (img->format == BITMAP_FMT_RGB565) {
|
||||
if (img->format == BITMAP_FMT_BGR565) {
|
||||
fg_pixsize = 2;
|
||||
fg_format = PIXEL_FORMAT_RGB565;
|
||||
fg_format = PIXEL_FORMAT_BGR565;
|
||||
} else {
|
||||
fg_pixsize = 4;
|
||||
fg_format = PIXEL_FORMAT_ARGB8888;
|
||||
fg_format = PIXEL_FORMAT_BGRA8888;
|
||||
}
|
||||
|
||||
o_offline = fb->w - w;
|
||||
@ -201,9 +201,9 @@ ret_t g2d_blend_image(bitmap_t* fb, bitmap_t* img, rect_t* dst, rect_t* src, uin
|
||||
return_value_if_fail(fb != NULL && fb->data != NULL, RET_BAD_PARAMS);
|
||||
return_value_if_fail(img != NULL && img->data != NULL && src != NULL && dst != NULL,
|
||||
RET_BAD_PARAMS);
|
||||
return_value_if_fail(fb->format == BITMAP_FMT_RGB565 || fb->format == BITMAP_FMT_BGRA8888,
|
||||
return_value_if_fail(fb->format == BITMAP_FMT_BGR565 || fb->format == BITMAP_FMT_BGRA8888,
|
||||
RET_BAD_PARAMS);
|
||||
return_value_if_fail(img->format == BITMAP_FMT_RGB565 || img->format == BITMAP_FMT_BGRA8888,
|
||||
return_value_if_fail(img->format == BITMAP_FMT_BGR565 || img->format == BITMAP_FMT_BGRA8888,
|
||||
RET_BAD_PARAMS);
|
||||
return_value_if_fail(src->w == dst->w && src->h == dst->h, RET_NOT_IMPL); /*not support scale*/
|
||||
|
||||
@ -215,20 +215,20 @@ ret_t g2d_blend_image(bitmap_t* fb, bitmap_t* img, rect_t* dst, rect_t* src, uin
|
||||
h = src->h;
|
||||
iw = img->w;
|
||||
|
||||
if (fb->format == BITMAP_FMT_RGB565) {
|
||||
if (fb->format == BITMAP_FMT_BGR565) {
|
||||
o_pixsize = 2;
|
||||
o_format = PIXEL_FORMAT_RGB565;
|
||||
o_format = PIXEL_FORMAT_BGR565;
|
||||
} else {
|
||||
o_pixsize = 4;
|
||||
o_format = PIXEL_FORMAT_ARGB8888;
|
||||
o_format = PIXEL_FORMAT_BGRA8888;
|
||||
}
|
||||
|
||||
if (img->format == BITMAP_FMT_RGB565) {
|
||||
if (img->format == BITMAP_FMT_BGR565) {
|
||||
fg_pixsize = 2;
|
||||
fg_format = PIXEL_FORMAT_RGB565;
|
||||
fg_format = PIXEL_FORMAT_BGR565;
|
||||
} else {
|
||||
fg_pixsize = 4;
|
||||
fg_format = PIXEL_FORMAT_ARGB8888;
|
||||
fg_format = PIXEL_FORMAT_BGRA8888;
|
||||
}
|
||||
|
||||
o_offline = fb->w - w;
|
||||
|
@ -45,23 +45,23 @@ static ret_t image_stb_destroy(bitmap_t* image) {
|
||||
}
|
||||
|
||||
static ret_t normalize_image(bitmap_t* image) {
|
||||
#ifdef WITH_BITMAP_RGB565
|
||||
#ifdef WITH_BITMAP_BGR565
|
||||
if (image->flags & BITMAP_FLAG_OPAQUE) {
|
||||
uint32_t size = image->w * image->h * 2;
|
||||
uint16_t* data = (uint16_t*)TKMEM_ALLOC(size);
|
||||
if (data != NULL) {
|
||||
bitmap_rgba_to_rgb565(image, data);
|
||||
bitmap_rgba_to_bgr565(image, data);
|
||||
stbi_image_free((uint8_t*)(image->data));
|
||||
image->data = (uint8_t*)data;
|
||||
image->destroy = image_stb_destroy_free;
|
||||
} else {
|
||||
bitmap_rgba_to_rgb565(image, (uint16_t*)(image->data));
|
||||
bitmap_rgba_to_bgr565(image, (uint16_t*)(image->data));
|
||||
}
|
||||
image->format = BITMAP_FMT_RGB565;
|
||||
image->format = BITMAP_FMT_BGR565;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
#endif /*WITH_BITMAP_RGB565*/
|
||||
#endif /*WITH_BITMAP_BGR565*/
|
||||
|
||||
#ifdef WITH_BITMAP_BGRA
|
||||
bitmap_rgba_to_bgra(image);
|
||||
|
File diff suppressed because it is too large
Load Diff
10699
tests/suggest_test.inc
10699
tests/suggest_test.inc
File diff suppressed because it is too large
Load Diff
@ -57,13 +57,13 @@ uint32_t image_gen_buff(bitmap_t* image, uint8_t* output_buff, uint32_t buff_siz
|
||||
|
||||
if (image->flags & BITMAP_FLAG_OPAQUE) {
|
||||
if (image->format == BITMAP_FMT_RGBA8888) {
|
||||
if (bitmap_rgba_to_rgb565(image, (uint16_t*)(header->data)) == RET_OK) {
|
||||
header->format = BITMAP_FMT_RGB565;
|
||||
if (bitmap_rgba_to_bgr565(image, (uint16_t*)(header->data)) == RET_OK) {
|
||||
header->format = BITMAP_FMT_BGR565;
|
||||
size = sizeof(uint16_t) * image->w * image->h;
|
||||
} else {
|
||||
assert(!"bitmap_rgba_to_rgb565 fail.");
|
||||
assert(!"bitmap_rgba_to_bgr565 fail.");
|
||||
}
|
||||
} else if (image->format == BITMAP_FMT_RGB565) {
|
||||
} else if (image->format == BITMAP_FMT_BGR565) {
|
||||
size = sizeof(uint16_t) * image->w * image->h;
|
||||
memcpy(header->data, image->data, size);
|
||||
} else {
|
||||
|
@ -126,9 +126,9 @@ static void qt_to_xml_on_start(XmlBuilder* thiz, const char* tag, const char** a
|
||||
b->root = b->widget;
|
||||
}
|
||||
|
||||
if(string(widget_class) == string("QDoubleSpinBox")) {
|
||||
if (string(widget_class) == string("QDoubleSpinBox")) {
|
||||
b->widget->properties = "input_type=\"float\" ";
|
||||
}else if(string(widget_class) == string("QSpinBox")) {
|
||||
} else if (string(widget_class) == string("QSpinBox")) {
|
||||
b->widget->properties = "input_type=\"int\" ";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user