mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-26 02:37:01 +08:00
fix(refr): reshape using draw_buf stride (#6567)
Signed-off-by: liujp <liujp@xiaomi.com> Co-authored-by: liujp <liujp@xiaomi.com> Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
This commit is contained in:
+22
-25
@@ -23,11 +23,11 @@
|
||||
#include <png.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <direct.h>
|
||||
#define mkdir(pathname, mode) _mkdir(pathname)
|
||||
#define strtok_r strtok_s
|
||||
#include <direct.h>
|
||||
#define mkdir(pathname, mode) _mkdir(pathname)
|
||||
#define strtok_r strtok_s
|
||||
#else
|
||||
#include <sys/stat.h>
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
@@ -35,11 +35,11 @@
|
||||
*********************/
|
||||
|
||||
#ifndef REF_IMGS_PATH
|
||||
#define REF_IMGS_PATH "ref_imgs/"
|
||||
#define REF_IMGS_PATH "ref_imgs/"
|
||||
#endif
|
||||
|
||||
#ifndef REF_IMG_TOLERANCE
|
||||
#define REF_IMG_TOLERANCE 0
|
||||
#define REF_IMG_TOLERANCE 0
|
||||
#endif
|
||||
|
||||
#define ERR_FILE_NOT_FOUND -1
|
||||
@@ -66,7 +66,7 @@ static bool screenshot_compare(const char * fn_ref, const char * mode, uint8_t t
|
||||
static int read_png_file(png_image_t * p, const char * file_name);
|
||||
static int write_png_file(void * raw_img, uint32_t width, uint32_t height, char * file_name);
|
||||
static void png_release(png_image_t * p);
|
||||
static void buf_to_xrgb8888(const uint8_t * buf_in, uint8_t * buf_out, lv_color_format_t cf_in);
|
||||
static void buf_to_xrgb8888(const lv_draw_buf_t * draw_buf, uint8_t * buf_out);
|
||||
static void create_folders_if_needed(const char * path) ;
|
||||
|
||||
/**********************
|
||||
@@ -151,11 +151,8 @@ static bool screenshot_compare(const char * fn_ref, const char * mode, uint8_t t
|
||||
|
||||
lv_refr_now(NULL);
|
||||
|
||||
extern uint8_t * last_flushed_buf;
|
||||
|
||||
lv_color_format_t cf = lv_display_get_color_format(NULL);
|
||||
uint8_t * screen_buf = lv_draw_buf_align(last_flushed_buf, cf);
|
||||
buf_to_xrgb8888(screen_buf, screen_buf_xrgb8888, cf);
|
||||
lv_draw_buf_t * draw_buf = lv_display_get_buf_active(NULL);
|
||||
buf_to_xrgb8888(draw_buf, screen_buf_xrgb8888);
|
||||
|
||||
png_image_t p;
|
||||
int res = read_png_file(&p, fn_ref_full);
|
||||
@@ -380,9 +377,12 @@ static void png_release(png_image_t * p)
|
||||
png_destroy_read_struct(&p->png_ptr, &p->info_ptr, NULL);
|
||||
}
|
||||
|
||||
static void buf_to_xrgb8888(const uint8_t * buf_in, uint8_t * buf_out, lv_color_format_t cf_in)
|
||||
static void buf_to_xrgb8888(const lv_draw_buf_t * draw_buf, uint8_t * buf_out)
|
||||
{
|
||||
uint32_t stride = lv_draw_buf_width_to_stride(800, cf_in);
|
||||
uint32_t stride = draw_buf->header.stride;
|
||||
lv_color_format_t cf_in = draw_buf->header.cf;
|
||||
const uint8_t * buf_in = draw_buf->data;
|
||||
|
||||
if(cf_in == LV_COLOR_FORMAT_RGB565) {
|
||||
uint32_t y;
|
||||
for(y = 0; y < 480; y++) {
|
||||
@@ -446,11 +446,11 @@ static void buf_to_xrgb8888(const uint8_t * buf_in, uint8_t * buf_out, lv_color_
|
||||
buf_out += 800 * 4;
|
||||
}
|
||||
}
|
||||
else if (cf_in == LV_COLOR_FORMAT_AL88) {
|
||||
else if(cf_in == LV_COLOR_FORMAT_AL88) {
|
||||
uint32_t y;
|
||||
for (y = 0; y < 480; y++) {
|
||||
for(y = 0; y < 480; y++) {
|
||||
uint32_t x;
|
||||
for (x = 0; x < 800; x++) {
|
||||
for(x = 0; x < 800; x++) {
|
||||
buf_out[x * 4 + 3] = buf_in[x * 2 + 1];
|
||||
buf_out[x * 4 + 2] = buf_in[x * 2 + 0];
|
||||
buf_out[x * 4 + 1] = buf_in[x * 2 + 0];
|
||||
@@ -461,14 +461,11 @@ static void buf_to_xrgb8888(const uint8_t * buf_in, uint8_t * buf_out, lv_color_
|
||||
buf_out += 800 * 4;
|
||||
}
|
||||
}
|
||||
else if (cf_in == LV_COLOR_FORMAT_I1)
|
||||
{
|
||||
else if(cf_in == LV_COLOR_FORMAT_I1) {
|
||||
uint32_t y;
|
||||
for (y = 0; y < 480; y++)
|
||||
{
|
||||
for(y = 0; y < 480; y++) {
|
||||
uint32_t x;
|
||||
for (x = 0; x < 800; x++)
|
||||
{
|
||||
for(x = 0; x < 800; x++) {
|
||||
const uint8_t byte = buf_in[x / 8];
|
||||
const uint8_t bit_pos = x % 8;
|
||||
const uint8_t pixel = (byte >> (7 - bit_pos)) & 0x01;
|
||||
@@ -502,10 +499,10 @@ static void create_folders_if_needed(const char * path)
|
||||
strcat(current_path, "/");
|
||||
|
||||
int mkdir_retval = mkdir(current_path, 0777);
|
||||
if (mkdir_retval == 0) {
|
||||
if(mkdir_retval == 0) {
|
||||
printf("Created folder: %s\n", current_path);
|
||||
}
|
||||
else if (errno != EEXIST) {
|
||||
else if(errno != EEXIST) {
|
||||
perror("Error creating folder");
|
||||
free(pathCopy);
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
Reference in New Issue
Block a user