4343#endif
4444
4545#ifndef REF_IMG_TOLERANCE
46- #define REF_IMG_TOLERANCE 0
46+ #define REF_IMG_TOLERANCE 5
4747#endif
4848
4949#define ERR_FILE_NOT_FOUND -1
@@ -103,7 +103,7 @@ static bool screenshot_compare(const char * fn_ref, uint8_t tolerance)
103103 char fn_ref_full [256 ];
104104 lv_snprintf (fn_ref_full , sizeof (fn_ref_full ), "%s%s" , REF_IMGS_PATH , fn_ref );
105105
106- create_folders_if_needed (fn_ref_full );
106+ // create_folders_if_needed(fn_ref_full);
107107
108108 lv_draw_buf_t * draw_buf = lv_display_get_buf_active (NULL );
109109
@@ -115,10 +115,10 @@ static bool screenshot_compare(const char * fn_ref, uint8_t tolerance)
115115 unsigned ref_img_height = 0 ;
116116 unsigned res = read_png_file (& ref_draw_buf , & ref_img_width , & ref_img_height , fn_ref_full );
117117 if (res ) {
118- LV_LOG_WARN ("%s%s" , fn_ref_full , " was not found, creating it now from the rendered screen " );
119- write_png_file (screen_buf_xrgb8888 , draw_buf -> header .w , draw_buf -> header .h , fn_ref_full );
120- lv_free (screen_buf_xrgb8888 );
121- return true ;
118+ LV_LOG_WARN ("%s%s" , fn_ref_full , " was not found" );
119+ // write_png_file(screen_buf_xrgb8888, draw_buf->header.w, draw_buf->header.h, fn_ref_full);
120+ // lv_free(screen_buf_xrgb8888);
121+ return false ;
122122 }
123123
124124 if (ref_img_width != draw_buf -> header .w || ref_img_height != draw_buf -> header .h ) {
@@ -136,6 +136,11 @@ static bool screenshot_compare(const char * fn_ref, uint8_t tolerance)
136136 uint8_t * ptr_ref = & (ref_row [x * 4 ]);
137137 uint8_t * ptr_act = & screen_buf_tmp [x * 4 ];
138138
139+ // skip transparent pixels
140+ if (ptr_ref [3 ] == 0 ) {
141+ continue ;
142+ }
143+
139144 if (LV_ABS ((int32_t ) ptr_act [0 ] - (int32_t ) ptr_ref [0 ]) > tolerance ||
140145 LV_ABS ((int32_t ) ptr_act [1 ] - (int32_t ) ptr_ref [1 ]) > tolerance ||
141146 LV_ABS ((int32_t ) ptr_act [2 ] - (int32_t ) ptr_ref [2 ]) > tolerance ) {
@@ -164,7 +169,7 @@ static bool screenshot_compare(const char * fn_ref, uint8_t tolerance)
164169 char fn_err_full [256 ];
165170 lv_snprintf (fn_err_full , sizeof (fn_err_full ), "%s%s_err.png" , REF_IMGS_PATH , fn_ref_no_ext );
166171
167- write_png_file (screen_buf_xrgb8888 , draw_buf -> header .w , draw_buf -> header .h , fn_err_full );
172+ // write_png_file(screen_buf_xrgb8888, draw_buf->header.w, draw_buf->header.h, fn_err_full);
168173 }
169174
170175 fflush (stdout );
0 commit comments