fix(img): fix getting the image type on big endian systems (#4215)

This commit is contained in:
jadergn
2023-05-09 15:27:54 -03:00
committed by GitHub
parent ee95e7dc25
commit 630da9c6ca

View File

@@ -198,11 +198,19 @@ lv_img_src_t lv_img_src_get_type(const void * src)
if(src == NULL) return img_src_type; if(src == NULL) return img_src_type;
const uint8_t * u8_p = src; const uint8_t * u8_p = src;
/*The first byte shows the type of the image source*/ /*The first or fourth byte depending on platform endianess shows the type of the image source*/
#if LV_BIG_ENDIAN_SYSTEM
if(u8_p[3] >= 0x20 && u8_p[3] <= 0x7F) {
#else
if(u8_p[0] >= 0x20 && u8_p[0] <= 0x7F) { if(u8_p[0] >= 0x20 && u8_p[0] <= 0x7F) {
#endif
img_src_type = LV_IMG_SRC_FILE; /*If it's an ASCII character then it's file name*/ img_src_type = LV_IMG_SRC_FILE; /*If it's an ASCII character then it's file name*/
} }
#if LV_BIG_ENDIAN_SYSTEM
else if(u8_p[3] >= 0x80) {
#else
else if(u8_p[0] >= 0x80) { else if(u8_p[0] >= 0x80) {
#endif
img_src_type = LV_IMG_SRC_SYMBOL; /*Symbols begins after 0x7F*/ img_src_type = LV_IMG_SRC_SYMBOL; /*Symbols begins after 0x7F*/
} }
else { else {