arch(img_decoder): replace read_liine_c with get_area_cb

also remove sjpeg support as get_area_cb can de quite same (some optimization is still needed to not decode the out of bounds chunks)
This commit is contained in:
Gabor Kiss-Vamosi
2023-09-18 21:19:00 +02:00
parent 6fdd585549
commit ca55b2ed8d
58 changed files with 1182 additions and 1448 deletions

View File

@@ -8,10 +8,14 @@ void lv_example_sjpg_1(void)
{
lv_obj_t * wp;
LV_IMAGE_DECLARE(codeblocks)
wp = lv_image_create(lv_scr_act());
/* Assuming a File system is attached to letter 'A'
* E.g. set LV_USE_FS_STDIO 'A' in lv_conf.h */
lv_image_set_src(wp, "A:lvgl/examples/libs/sjpg/small_image.sjpg");
lv_image_set_src(wp, "A:codeblocks.jpg");
// lv_image_set_src(wp, &codeblocks);
lv_obj_center(wp);
}
#endif

2
lvgl.h
View File

@@ -95,7 +95,7 @@ extern "C" {
#include "src/libs/png/lv_png.h"
#include "src/libs/gif/lv_gif.h"
#include "src/libs/qrcode/lv_qrcode.h"
#include "src/libs/sjpg/lv_sjpg.h"
#include "src/libs/jpg/lv_jpg.h"
#include "src/libs/freetype/lv_freetype.h"
#include "src/libs/rlottie/lv_rlottie.h"
#include "src/libs/ffmpeg/lv_ffmpeg.h"

View File

@@ -88,7 +88,6 @@ typedef lv_res_t (*lv_image_decoder_get_area_cb_t)(struct _lv_image_decoder_t *
*/
typedef void (*lv_image_decoder_close_f_t)(struct _lv_image_decoder_t * decoder, struct _lv_image_decoder_dsc_t * dsc);
typedef struct _lv_image_decoder_t {
lv_image_decoder_info_f_t info_cb;
lv_image_decoder_open_f_t open_cb;
@@ -242,6 +241,9 @@ lv_res_t lv_image_decoder_built_in_info(lv_image_decoder_t * decoder, const void
lv_res_t lv_image_decoder_built_in_get_area(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc,
const lv_area_t * full_area, lv_area_t * decoded_area);
lv_res_t lv_img_decoder_built_in_get_area(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc,
const lv_area_t * full_area, lv_area_t * decoded_area);
/**
* Open a built in image
* @param decoder the decoder where this function belongs

View File

@@ -215,6 +215,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_image(lv_draw_unit_t * draw_unit, const lv
lv_image_decoder_close(&decoder_dsc);
}
static void img_draw_core(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc, const lv_area_t * draw_area,
const lv_image_decoder_dsc_t * src, lv_draw_image_sup_t * sup, const lv_area_t * img_coords)
{

290
src/libs/jpg/lv_jpg.c Normal file
View File

@@ -0,0 +1,290 @@
/**
* @file lv_sjpg.c
*
*/
/*----------------------------------------------------------------------------------------------------------------------------------
/ Added normal JPG support [7/10/2020]
/ ----------
/ SJPEG is a custom created modified JPEG file format for small embedded platforms.
/ It will contain multiple JPEG fragments all embedded into a single file with a custom header.
/ This makes JPEG decoding easier using any JPEG library. Overall file size will be almost
/ similar to the parent jpeg file. We can generate sjpeg from any jpeg using a python script
/ provided along with this project.
/ (by vinodstanur | 2020 )
/ SJPEG FILE STRUCTURE
/ --------------------------------------------------------------------------------------------------------------------------------
/ Bytes | Value |
/ --------------------------------------------------------------------------------------------------------------------------------
/
/ 0 - 7 | "_SJPG__" followed by '\0'
/
/ 8 - 13 | "V1.00" followed by '\0' [VERSION OF SJPG FILE for future compatibiliby]
/
/ 14 - 15 | X_RESOLUTION (width) [little endian]
/
/ 16 - 17 | Y_RESOLUTION (height) [little endian]
/
/ 18 - 19 | TOTAL_FRAMES inside sjpeg [little endian]
/
/ 20 - 21 | JPEG BLOCK WIDTH (16 normally) [little endian]
/
/ 22 - [(TOTAL_FRAMES*2 )] | SIZE OF EACH JPEG SPLIT FRAGMENTS (FRAME_INFO_ARRAY)
/
/ SJPEG data | Each JPEG frame can be extracted from SJPEG data by parsing the FRAME_INFO_ARRAY one time.
/
/----------------------------------------------------------------------------------------------------------------------------------
/ JPEG DECODER
/ ------------
/ We are using TJpgDec - Tiny JPEG Decompressor library from ELM-CHAN for decoding each split-jpeg fragments.
/ The tjpgd.c and tjpgd.h is not modified and those are used as it is. So if any update comes for the tiny-jpeg,
/ just replace those files with updated files.
/---------------------------------------------------------------------------------------------------------------------------------*/
/*********************
* INCLUDES
*********************/
#include "../../../lvgl.h"
#if LV_USE_SJPG
#include "tjpgd.h"
#include "lv_jpg.h"
#include "../../misc/lv_fs.h"
/*********************
* DEFINES
*********************/
#define TJPGD_WORKBUFF_SIZE 4096 //Recommended by TJPGD library
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static lv_res_t decoder_info(lv_image_decoder_t * decoder, const void * src, lv_image_header_t * header);
static lv_res_t decoder_open(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc);
static lv_res_t decoder_get_area(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc,
const lv_area_t * full_area, lv_area_t * decoded_area);
static void decoder_close(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc);
static size_t input_func(JDEC * jd, uint8_t * buff, size_t ndata);
static int is_jpg(const uint8_t * raw_data, size_t len);
/**********************
* STATIC VARIABLES
**********************/
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
void lv_jpeg_init(void)
{
lv_image_decoder_t * dec = lv_image_decoder_create();
lv_image_decoder_set_info_cb(dec, decoder_info);
lv_image_decoder_set_open_cb(dec, decoder_open);
lv_image_decoder_set_get_area_cb(dec, decoder_get_area);
lv_image_decoder_set_close_cb(dec, decoder_close);
}
/**********************
* STATIC FUNCTIONS
**********************/
static lv_res_t decoder_info(lv_image_decoder_t * decoder, const void * src, lv_image_header_t * header)
{
LV_UNUSED(decoder);
lv_image_src_t src_type = lv_image_src_get_type(src);
if(src_type == LV_IMAGE_SRC_VARIABLE) {
const lv_image_dsc_t * img_dsc = src;
uint8_t * raw_data = (uint8_t *)img_dsc->data;
const uint32_t raw_sjpeg_data_size = img_dsc->data_size;
if(is_jpg(raw_data, raw_sjpeg_data_size) == true) {
header->always_zero = 0;
header->cf = LV_COLOR_FORMAT_RAW;
header->w = img_dsc->header.w;
header->h = img_dsc->header.h;
header->stride = img_dsc->header.w * 3;
return LV_RES_OK;
}
}
else if(src_type == LV_IMAGE_SRC_FILE) {
const char * fn = src;
if((strcmp(lv_fs_get_ext(fn), "jpg") == 0) || (strcmp(lv_fs_get_ext(fn), "jpeg") == 0)) {
lv_fs_file_t f;
lv_fs_res_t res;
res = lv_fs_open(&f, fn, LV_FS_MODE_RD);
if(res != LV_FS_RES_OK) return LV_RES_INV;
uint8_t workb[TJPGD_WORKBUFF_SIZE];
JDEC jd;
JRESULT rc = jd_prepare(&jd, input_func, workb, TJPGD_WORKBUFF_SIZE, &f);
if(rc) {
LV_LOG_WARN("jd_prepare error: %d", rc);
lv_fs_close(&f);
return LV_RES_INV;
}
header->always_zero = 0;
header->cf = LV_COLOR_FORMAT_RAW;
header->w = jd.width;
header->h = jd.height;
header->stride = jd.width * 3;
lv_fs_close(&f);
return LV_RES_OK;
}
}
return LV_RES_INV;
}
static size_t input_func(JDEC * jd, uint8_t * buff, size_t ndata)
{
lv_fs_file_t * f = jd->device;
if(!f) return 0;
if(buff) {
uint32_t rn = 0;
lv_fs_read(f, buff, (uint32_t)ndata, &rn);
return rn;
}
else {
uint32_t pos;
lv_fs_tell(f, &pos);
lv_fs_seek(f, (uint32_t)(ndata + pos), LV_FS_SEEK_SET);
return ndata;
}
return 0;
}
static lv_res_t decoder_open(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc)
{
LV_UNUSED(decoder);
lv_fs_file_t * f = lv_malloc(sizeof(lv_fs_file_t));
if(dsc->src_type == LV_IMAGE_SRC_VARIABLE) {
const lv_image_dsc_t * img_dsc = dsc->src;
if(is_jpg(img_dsc->data, img_dsc->data_size) == true) {
lv_fs_path_ex_t path;
lv_fs_make_path_from_buffer(&path, LV_FS_MEMFS_LETTER, img_dsc->data, img_dsc->data_size);
lv_fs_res_t res;
res = lv_fs_open(f, (const char *)&path, LV_FS_MODE_RD);
if(res != LV_FS_RES_OK) {
lv_free(f);
return LV_RES_INV;
}
}
}
else if(dsc->src_type == LV_IMAGE_SRC_FILE) {
const char * fn = dsc->src;
if((strcmp(lv_fs_get_ext(fn), "jpg") == 0) || (strcmp(lv_fs_get_ext(fn), "jpeg") == 0)) {
lv_fs_res_t res;
res = lv_fs_open(f, fn, LV_FS_MODE_RD);
if(res != LV_FS_RES_OK) {
lv_free(f);
return LV_RES_INV;
}
}
}
uint8_t * workb_temp = lv_malloc(TJPGD_WORKBUFF_SIZE);
JDEC * jd = lv_malloc(sizeof(JDEC));
dsc->user_data = jd;
JRESULT rc = jd_prepare(jd, input_func, workb_temp, (size_t)TJPGD_WORKBUFF_SIZE, f);
if(rc) return rc;
dsc->header.always_zero = 0;
dsc->header.cf = LV_COLOR_FORMAT_RGB888;
dsc->header.w = jd->width;
dsc->header.h = jd->height;
dsc->header.stride = jd->width * 3;
if(rc != JDR_OK) {
lv_free(workb_temp);
lv_free(jd);
return LV_RES_INV;
}
return LV_RES_OK;
}
static lv_res_t decoder_get_area(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc,
const lv_area_t * full_area, lv_area_t * decoded_area)
{
LV_UNUSED(decoder);
LV_UNUSED(full_area);
JDEC * jd = dsc->user_data;
uint32_t mx, my;
mx = jd->msx * 8;
my = jd->msy * 8; /* Size of the MCU (pixel) */
if(decoded_area->y1 == LV_COORD_MIN) {
decoded_area->y1 = 0;
decoded_area->y2 = 7;
decoded_area->x1 = 0 - mx;
decoded_area->x2 = 7 - mx;
jd->scale = 0;
jd->dcv[2] = jd->dcv[1] = jd->dcv[0] = 0; /* Initialize DC values */
dsc->img_data = jd->workbuf;
jd->rst = 0;
jd->rsc = 0;
dsc->header.stride = mx * 3;
}
decoded_area->x1 += mx;
decoded_area->x2 += mx;
if(decoded_area->x1 >= jd->width) {
decoded_area->x1 = 0;
decoded_area->x2 = 7;
decoded_area->y1 += my;
decoded_area->y2 += my;
}
JRESULT rc;
if (jd->nrst && jd->rst++ == jd->nrst) { /* Process restart interval if enabled */
rc = jd_restart(jd, jd->rsc++);
if (rc != JDR_OK) return rc;
jd->rst = 1;
}
rc = jd_mcu_load(jd); /* Load an MCU (decompress huffman coded stream, dequantize and apply IDCT) */
if (rc != JDR_OK) return rc;
rc = jd_mcu_output(jd, NULL, decoded_area->x1, decoded_area->y1); /* Output the MCU (YCbCr to RGB, scaling and output) */
if (rc != JDR_OK) return rc;
return LV_RES_OK;
}
/**
* Free the allocated resources
* @param decoder pointer to the decoder where this function belongs
* @param dsc pointer to a descriptor which describes this decoding session
*/
static void decoder_close(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc)
{
LV_UNUSED(decoder);
JDEC * jd = dsc->user_data;
lv_fs_close(jd->device);
lv_free(jd->device);
lv_free(jd->pool_original);
lv_free(jd);
}
static int is_jpg(const uint8_t * raw_data, size_t len)
{
const uint8_t jpg_signature[] = {0xFF, 0xD8, 0xFF, 0xE0, 0x00, 0x10, 0x4A, 0x46, 0x49, 0x46};
if(len < sizeof(jpg_signature)) return false;
return memcmp(jpg_signature, raw_data, sizeof(jpg_signature)) == 0;
}
#endif /*LV_USE_SJPG*/

View File

@@ -28,7 +28,7 @@ extern "C" {
* GLOBAL PROTOTYPES
**********************/
void lv_split_jpeg_init(void);
void lv_jpeg_init(void);
/**********************
* MACROS

File diff suppressed because it is too large Load Diff

View File

@@ -8,12 +8,18 @@
extern "C" {
#endif
#include "../../lv_conf_internal.h"
#if LV_USE_SJPG
#include "tjpgdcnf.h"
#include <string.h>
#if defined(_WIN32) /* VC++ or some compiler without stdint.h */
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef short int16_t;
typedef unsigned long uint32_t;
typedef long int32_t;
#else /* Embedded platform */
#include <stdint.h>
#endif
#if JD_FASTDECODE >= 1
typedef int16_t jd_yuv_t;
@@ -35,6 +41,8 @@ typedef enum {
JDR_FMT3 /* 8: Not supported JPEG standard */
} JRESULT;
/* Rectangular region in the output image */
typedef struct {
uint16_t left; /* Left end */
@@ -43,48 +51,59 @@ typedef struct {
uint16_t bottom; /* Bottom end */
} JRECT;
/* Decompressor object structure */
typedef struct _JDEC JDEC;
struct _JDEC {
typedef struct JDEC JDEC;
struct JDEC {
size_t dctr; /* Number of bytes available in the input buffer */
uint8_t * dptr; /* Current data read ptr */
uint8_t * inbuf; /* Bit stream input buffer */
uint8_t dbit; /* Number of bits available in wreg or reading bit mask */
uint8_t* dptr; /* Current data read ptr */
uint8_t* inbuf; /* Bit stream input buffer */
uint8_t dbit; /* Number of bits availavble in wreg or reading bit mask */
uint8_t scale; /* Output scaling ratio */
uint8_t msx, msy; /* MCU size in unit of block (width, height) */
uint8_t qtid[3]; /* Quantization table ID of each component, Y, Cb, Cr */
uint8_t ncomp; /* Number of color components 1:grayscale, 3:color */
int16_t dcv[3]; /* Previous DC element of each component */
uint16_t nrst; /* Restart interval */
uint16_t nrst; /* Restart inverval */
uint16_t rst; /* Restart count*/
uint16_t rsc; /* Expected restart sequence ID*/
uint16_t width, height; /* Size of the input image (pixel) */
uint8_t * huffbits[2][2]; /* Huffman bit distribution tables [id][dcac] */
uint16_t * huffcode[2][2]; /* Huffman code word tables [id][dcac] */
uint8_t * huffdata[2][2]; /* Huffman decoded data tables [id][dcac] */
int32_t * qttbl[4]; /* Dequantizer tables [id] */
uint8_t* huffbits[2][2]; /* Huffman bit distribution tables [id][dcac] */
uint16_t* huffcode[2][2]; /* Huffman code word tables [id][dcac] */
uint8_t* huffdata[2][2]; /* Huffman decoded data tables [id][dcac] */
int32_t* qttbl[4]; /* Dequantizer tables [id] */
#if JD_FASTDECODE >= 1
uint32_t wreg; /* Working shift register */
uint8_t marker; /* Detected marker (0:None) */
#if JD_FASTDECODE == 2
uint8_t longofs[2][2]; /* Table offset of long code [id][dcac] */
uint16_t * hufflut_ac[2]; /* Fast huffman decode tables for AC short code [id] */
uint8_t * hufflut_dc[2]; /* Fast huffman decode tables for DC short code [id] */
uint16_t* hufflut_ac[2]; /* Fast huffman decode tables for AC short code [id] */
uint8_t* hufflut_dc[2]; /* Fast huffman decode tables for DC short code [id] */
#endif
#endif
void * workbuf; /* Working buffer for IDCT and RGB output */
jd_yuv_t * mcubuf; /* Working buffer for the MCU */
void * pool; /* Pointer to available memory pool */
size_t sz_pool; /* Size of memory pool (bytes available) */
size_t (*infunc)(JDEC *, uint8_t *, size_t); /* Pointer to jpeg stream input function */
void * device; /* Pointer to I/O device identifier for the session */
void* workbuf; /* Working buffer for IDCT and RGB output */
jd_yuv_t* mcubuf; /* Working buffer for the MCU */
void* pool; /* Pointer to available memory pool */
void* pool_original; /* Pointer to original pool */
size_t sz_pool; /* Size of momory pool (bytes available) */
size_t (*infunc)(JDEC*, uint8_t*, size_t); /* Pointer to jpeg stream input function */
void* device; /* Pointer to I/O device identifiler for the session */
};
/* TJpgDec API functions */
JRESULT jd_prepare(JDEC * jd, size_t (*infunc)(JDEC *, uint8_t *, size_t), void * pool, size_t sz_pool, void * dev);
JRESULT jd_decomp(JDEC * jd, int (*outfunc)(JDEC *, void *, JRECT *), uint8_t scale);
JRESULT jd_prepare (JDEC* jd, size_t (*infunc)(JDEC*,uint8_t*,size_t), void* pool, size_t sz_pool, void* dev);
JRESULT jd_decomp (JDEC* jd, int (*outfunc)(JDEC*,void*,JRECT*), uint8_t scale);
JRESULT jd_mcu_load (JDEC* jd);
JRESULT jd_mcu_output(JDEC* jd, int (*outfunc)(JDEC*, void*, JRECT*), unsigned int x, unsigned int y);
JRESULT jd_restart(JDEC* jd, uint16_t rstn);
#endif /*LV_USE_SJPG*/
#ifdef __cplusplus
}

View File

@@ -12,7 +12,7 @@
/ 2: Grayscale (8-bit/pix)
*/
#define JD_USE_SCALE 1
#define JD_USE_SCALE 0
/* Switches output descaling feature.
/ 0: Disable
/ 1: Enable
@@ -24,7 +24,7 @@
/ 1: Enable
*/
#define JD_FASTDECODE 0
#define JD_FASTDECODE 1
/* Optimization level
/ 0: Basic optimization. Suitable for 8/16-bit MCUs.
/ 1: + 32-bit barrel shifter. Suitable for 32-bit MCUs.

View File

@@ -1,931 +0,0 @@
/**
* @file lv_sjpg.c
*
*/
/*----------------------------------------------------------------------------------------------------------------------------------
/ Added normal JPG support [7/10/2020]
/ ----------
/ SJPEG is a custom created modified JPEG file format for small embedded platforms.
/ It will contain multiple JPEG fragments all embedded into a single file with a custom header.
/ This makes JPEG decoding easier using any JPEG library. Overall file size will be almost
/ similar to the parent jpeg file. We can generate sjpeg from any jpeg using a python script
/ provided along with this project.
/ (by vinodstanur | 2020 )
/ SJPEG FILE STRUCTURE
/ --------------------------------------------------------------------------------------------------------------------------------
/ Bytes | Value |
/ --------------------------------------------------------------------------------------------------------------------------------
/
/ 0 - 7 | "_SJPG__" followed by '\0'
/
/ 8 - 13 | "V1.00" followed by '\0' [VERSION OF SJPG FILE for future compatibiliby]
/
/ 14 - 15 | X_RESOLUTION (width) [little endian]
/
/ 16 - 17 | Y_RESOLUTION (height) [little endian]
/
/ 18 - 19 | TOTAL_FRAMES inside sjpeg [little endian]
/
/ 20 - 21 | JPEG BLOCK WIDTH (16 normally) [little endian]
/
/ 22 - [(TOTAL_FRAMES*2 )] | SIZE OF EACH JPEG SPLIT FRAGMENTS (FRAME_INFO_ARRAY)
/
/ SJPEG data | Each JPEG frame can be extracted from SJPEG data by parsing the FRAME_INFO_ARRAY one time.
/
/----------------------------------------------------------------------------------------------------------------------------------
/ JPEG DECODER
/ ------------
/ We are using TJpgDec - Tiny JPEG Decompressor library from ELM-CHAN for decoding each split-jpeg fragments.
/ The tjpgd.c and tjpgd.h is not modified and those are used as it is. So if any update comes for the tiny-jpeg,
/ just replace those files with updated files.
/---------------------------------------------------------------------------------------------------------------------------------*/
/*********************
* INCLUDES
*********************/
#include "../../../lvgl.h"
#if LV_USE_SJPG
#include "tjpgd.h"
#include "lv_sjpg.h"
#include "../../misc/lv_fs.h"
/*********************
* DEFINES
*********************/
#define TJPGD_WORKBUFF_SIZE 4096 //Recommended by TJPGD library
//NEVER EDIT THESE OFFSET VALUES
#define SJPEG_VERSION_OFFSET 8
#define SJPEG_X_RES_OFFSET 14
#define SJPEG_y_RES_OFFSET 16
#define SJPEG_TOTAL_FRAMES_OFFSET 18
#define SJPEG_BLOCK_WIDTH_OFFSET 20
#define SJPEG_FRAME_INFO_ARRAY_OFFSET 22
/**********************
* TYPEDEFS
**********************/
enum io_source_type {
SJPEG_IO_SOURCE_C_ARRAY,
SJPEG_IO_SOURCE_DISK,
};
typedef struct {
enum io_source_type type;
lv_fs_file_t lv_file;
uint8_t * img_cache_buff;
int img_cache_x_res;
int img_cache_y_res;
uint8_t * raw_sjpg_data; //Used when type==SJPEG_IO_SOURCE_C_ARRAY.
uint32_t raw_sjpg_data_size; //Num bytes pointed to by raw_sjpg_data.
uint32_t raw_sjpg_data_next_read_pos; //Used for all types.
} io_source_t;
typedef struct {
uint8_t * sjpeg_data;
uint32_t sjpeg_data_size;
int sjpeg_x_res;
int sjpeg_y_res;
int sjpeg_total_frames;
int sjpeg_single_frame_height;
int sjpeg_cache_frame_index;
uint8_t ** frame_base_array; //to save base address of each split frames upto sjpeg_total_frames.
int * frame_base_offset; //to save base offset for fseek
uint8_t * frame_cache;
uint8_t * workb; //JPG work buffer for jpeg library
JDEC * tjpeg_jd;
io_source_t io;
} SJPEG;
/**********************
* STATIC PROTOTYPES
**********************/
static lv_res_t decoder_info(lv_image_decoder_t * decoder, const void * src, lv_image_header_t * header);
static lv_res_t decoder_open(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc);
static lv_res_t decoder_read_line(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc, lv_coord_t x,
lv_coord_t y,
lv_coord_t len, uint8_t * buf);
static void decoder_close(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc);
static size_t input_func(JDEC * jd, uint8_t * buff, size_t ndata);
static int is_jpg(const uint8_t * raw_data, size_t len);
static void lv_sjpg_cleanup(SJPEG * sjpeg);
static void lv_sjpg_free(SJPEG * sjpeg);
/**********************
* STATIC VARIABLES
**********************/
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
void lv_split_jpeg_init(void)
{
lv_image_decoder_t * dec = lv_image_decoder_create();
lv_image_decoder_set_info_cb(dec, decoder_info);
lv_image_decoder_set_open_cb(dec, decoder_open);
lv_image_decoder_set_close_cb(dec, decoder_close);
/*
Disabled for now
lv_image_decoder_set_read_line_cb(dec, decoder_read_line);
*/
LV_UNUSED(decoder_read_line);
}
/**********************
* STATIC FUNCTIONS
**********************/
/**
* Get info about an SJPG / JPG image
* @param decoder pointer to the decoder where this function belongs
* @param src can be file name or pointer to a C array
* @param header store the info here
* @return LV_RES_OK: no error; LV_RES_INV: can't get the info
*/
static lv_res_t decoder_info(lv_image_decoder_t * decoder, const void * src, lv_image_header_t * header)
{
LV_UNUSED(decoder);
/*Check whether the type `src` is known by the decoder*/
/* Read the SJPG/JPG header and find `width` and `height` */
lv_image_src_t src_type = lv_image_src_get_type(src); /*Get the source type*/
lv_res_t ret = LV_RES_OK;
if(src_type == LV_IMAGE_SRC_VARIABLE) {
const lv_image_dsc_t * img_dsc = src;
uint8_t * raw_sjpeg_data = (uint8_t *)img_dsc->data;
const uint32_t raw_sjpeg_data_size = img_dsc->data_size;
if(!strncmp((char *)raw_sjpeg_data, "_SJPG__", strlen("_SJPG__"))) {
raw_sjpeg_data += 14; //seek to res info ... refer sjpeg format
header->always_zero = 0;
header->cf = LV_COLOR_FORMAT_RAW;
header->w = *raw_sjpeg_data++;
header->w |= *raw_sjpeg_data++ << 8;
header->h = *raw_sjpeg_data++;
header->h |= *raw_sjpeg_data++ << 8;
return ret;
}
else if(is_jpg(raw_sjpeg_data, raw_sjpeg_data_size) == true) {
header->always_zero = 0;
header->cf = LV_COLOR_FORMAT_RAW;
uint8_t * workb_temp = lv_malloc(TJPGD_WORKBUFF_SIZE);
if(!workb_temp) return LV_RES_INV;
io_source_t io_source_temp;
io_source_temp.type = SJPEG_IO_SOURCE_C_ARRAY;
io_source_temp.raw_sjpg_data = raw_sjpeg_data;
io_source_temp.raw_sjpg_data_size = raw_sjpeg_data_size;
io_source_temp.raw_sjpg_data_next_read_pos = 0;
JDEC jd_tmp;
JRESULT rc = jd_prepare(&jd_tmp, input_func, workb_temp, (size_t)TJPGD_WORKBUFF_SIZE, &io_source_temp);
if(rc == JDR_OK) {
header->w = jd_tmp.width;
header->h = jd_tmp.height;
}
else {
ret = LV_RES_INV;
goto end;
}
end:
lv_free(workb_temp);
return ret;
}
}
else if(src_type == LV_IMAGE_SRC_FILE) {
const char * fn = src;
if(strcmp(lv_fs_get_ext(fn), "sjpg") == 0) {
uint8_t buff[22];
memset(buff, 0, sizeof(buff));
lv_fs_file_t file;
lv_fs_res_t res = lv_fs_open(&file, fn, LV_FS_MODE_RD);
if(res != LV_FS_RES_OK) return 78;
uint32_t rn;
res = lv_fs_read(&file, buff, 8, &rn);
if(res != LV_FS_RES_OK || rn != 8) {
lv_fs_close(&file);
return LV_RES_INV;
}
if(strcmp((char *)buff, "_SJPG__") == 0) {
lv_fs_seek(&file, 14, LV_FS_SEEK_SET);
res = lv_fs_read(&file, buff, 4, &rn);
if(res != LV_FS_RES_OK || rn != 4) {
lv_fs_close(&file);
return LV_RES_INV;
}
header->always_zero = 0;
header->cf = LV_COLOR_FORMAT_RAW;
uint8_t * raw_sjpeg_data = buff;
header->w = *raw_sjpeg_data++;
header->w |= *raw_sjpeg_data++ << 8;
header->h = *raw_sjpeg_data++;
header->h |= *raw_sjpeg_data++ << 8;
lv_fs_close(&file);
return LV_RES_OK;
}
}
else if(strcmp(lv_fs_get_ext(fn), "jpg") == 0) {
lv_fs_file_t file;
lv_fs_res_t res = lv_fs_open(&file, fn, LV_FS_MODE_RD);
if(res != LV_FS_RES_OK) return 78;
uint8_t * workb_temp = lv_malloc(TJPGD_WORKBUFF_SIZE);
if(!workb_temp) {
lv_fs_close(&file);
return LV_RES_INV;
}
io_source_t io_source_temp;
io_source_temp.type = SJPEG_IO_SOURCE_DISK;
io_source_temp.raw_sjpg_data_next_read_pos = 0;
io_source_temp.img_cache_buff = NULL;
io_source_temp.lv_file = file;
JDEC jd_tmp;
JRESULT rc = jd_prepare(&jd_tmp, input_func, workb_temp, (size_t)TJPGD_WORKBUFF_SIZE, &io_source_temp);
lv_free(workb_temp);
lv_fs_close(&file);
if(rc == JDR_OK) {
header->always_zero = 0;
header->cf = LV_COLOR_FORMAT_RAW;
header->w = jd_tmp.width;
header->h = jd_tmp.height;
return LV_RES_OK;
}
}
}
return LV_RES_INV;
}
static int img_data_cb(JDEC * jd, void * data, JRECT * rect)
{
io_source_t * io = jd->device;
uint8_t * cache = io->img_cache_buff;
const int xres = io->img_cache_x_res;
uint8_t * buf = data;
const int INPUT_PIXEL_SIZE = 3;
const int row_width = rect->right - rect->left + 1; // Row width in pixels.
const int row_size = row_width * INPUT_PIXEL_SIZE; // Row size (bytes).
for(int y = rect->top; y <= rect->bottom; y++) {
int row_offset = y * xres * INPUT_PIXEL_SIZE + rect->left * INPUT_PIXEL_SIZE;
memcpy(cache + row_offset, buf, row_size);
buf += row_size;
}
return 1;
}
static size_t input_func(JDEC * jd, uint8_t * buff, size_t ndata)
{
io_source_t * io = jd->device;
if(!io) return 0;
if(io->type == SJPEG_IO_SOURCE_C_ARRAY) {
const uint32_t bytes_left = io->raw_sjpg_data_size - io->raw_sjpg_data_next_read_pos;
const uint32_t to_read = ndata <= bytes_left ? (uint32_t)ndata : bytes_left;
if(to_read == 0)
return 0;
if(buff) {
memcpy(buff, io->raw_sjpg_data + io->raw_sjpg_data_next_read_pos, to_read);
}
io->raw_sjpg_data_next_read_pos += to_read;
return to_read;
}
else if(io->type == SJPEG_IO_SOURCE_DISK) {
lv_fs_file_t * lv_file_p = &(io->lv_file);
if(buff) {
uint32_t rn = 0;
lv_fs_read(lv_file_p, buff, (uint32_t)ndata, &rn);
return rn;
}
else {
uint32_t pos;
lv_fs_tell(lv_file_p, &pos);
lv_fs_seek(lv_file_p, (uint32_t)(ndata + pos), LV_FS_SEEK_SET);
return ndata;
}
}
return 0;
}
/**
* Open SJPG image and return the decided image
* @param decoder pointer to the decoder where this function belongs
* @param dsc pointer to a descriptor which describes this decoding session
* @return LV_RES_OK: no error; LV_RES_INV: can't get the info
*/
static lv_res_t decoder_open(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc)
{
LV_UNUSED(decoder);
lv_res_t lv_ret = LV_RES_OK;
if(dsc->src_type == LV_IMAGE_SRC_VARIABLE) {
uint8_t * data;
SJPEG * sjpeg = (SJPEG *) dsc->user_data;
const uint32_t raw_sjpeg_data_size = ((lv_image_dsc_t *)dsc->src)->data_size;
if(sjpeg == NULL) {
sjpeg = lv_malloc(sizeof(SJPEG));
if(!sjpeg) return LV_RES_INV;
memset(sjpeg, 0, sizeof(SJPEG));
dsc->user_data = sjpeg;
sjpeg->sjpeg_data = (uint8_t *)((lv_image_dsc_t *)(dsc->src))->data;
sjpeg->sjpeg_data_size = ((lv_image_dsc_t *)(dsc->src))->data_size;
}
if(!strncmp((char *) sjpeg->sjpeg_data, "_SJPG__", strlen("_SJPG__"))) {
data = sjpeg->sjpeg_data;
data += 14;
sjpeg->sjpeg_x_res = *data++;
sjpeg->sjpeg_x_res |= *data++ << 8;
sjpeg->sjpeg_y_res = *data++;
sjpeg->sjpeg_y_res |= *data++ << 8;
sjpeg->sjpeg_total_frames = *data++;
sjpeg->sjpeg_total_frames |= *data++ << 8;
sjpeg->sjpeg_single_frame_height = *data++;
sjpeg->sjpeg_single_frame_height |= *data++ << 8;
sjpeg->frame_base_array = lv_malloc(sizeof(uint8_t *) * sjpeg->sjpeg_total_frames);
if(! sjpeg->frame_base_array) {
lv_sjpg_cleanup(sjpeg);
sjpeg = NULL;
return LV_RES_INV;
}
sjpeg->frame_base_offset = NULL;
uint8_t * img_frame_base = data + sjpeg->sjpeg_total_frames * 2;
sjpeg->frame_base_array[0] = img_frame_base;
for(int i = 1; i < sjpeg->sjpeg_total_frames; i++) {
int offset = *data++;
offset |= *data++ << 8;
sjpeg->frame_base_array[i] = sjpeg->frame_base_array[i - 1] + offset;
}
sjpeg->sjpeg_cache_frame_index = -1;
sjpeg->frame_cache = (void *)lv_malloc(sjpeg->sjpeg_x_res * sjpeg->sjpeg_single_frame_height * 3/*2*/);
if(! sjpeg->frame_cache) {
lv_sjpg_cleanup(sjpeg);
sjpeg = NULL;
return LV_RES_INV;
}
sjpeg->io.img_cache_buff = sjpeg->frame_cache;
sjpeg->io.img_cache_x_res = sjpeg->sjpeg_x_res;
sjpeg->workb = lv_malloc(TJPGD_WORKBUFF_SIZE);
if(! sjpeg->workb) {
lv_sjpg_cleanup(sjpeg);
sjpeg = NULL;
return LV_RES_INV;
}
sjpeg->tjpeg_jd = lv_malloc(sizeof(JDEC));
if(! sjpeg->tjpeg_jd) {
lv_sjpg_cleanup(sjpeg);
sjpeg = NULL;
return LV_RES_INV;
}
sjpeg->io.type = SJPEG_IO_SOURCE_C_ARRAY;
sjpeg->io.lv_file.file_d = NULL;
dsc->img_data = NULL;
return lv_ret;
}
else if(is_jpg(sjpeg->sjpeg_data, raw_sjpeg_data_size) == true) {
uint8_t * workb_temp = lv_malloc(TJPGD_WORKBUFF_SIZE);
if(! workb_temp) {
lv_sjpg_cleanup(sjpeg);
sjpeg = NULL;
return LV_RES_INV;
}
io_source_t io_source_temp;
io_source_temp.type = SJPEG_IO_SOURCE_C_ARRAY;
io_source_temp.raw_sjpg_data = sjpeg->sjpeg_data;
io_source_temp.raw_sjpg_data_size = sjpeg->sjpeg_data_size;
io_source_temp.raw_sjpg_data_next_read_pos = 0;
JDEC jd_tmp;
JRESULT rc = jd_prepare(&jd_tmp, input_func, workb_temp, (size_t)TJPGD_WORKBUFF_SIZE, &io_source_temp);
lv_free(workb_temp);
if(rc == JDR_OK) {
sjpeg->sjpeg_x_res = jd_tmp.width;
sjpeg->sjpeg_y_res = jd_tmp.height;
sjpeg->sjpeg_total_frames = 1;
sjpeg->sjpeg_single_frame_height = jd_tmp.height;
sjpeg->frame_base_array = lv_malloc(sizeof(uint8_t *) * sjpeg->sjpeg_total_frames);
if(! sjpeg->frame_base_array) {
lv_sjpg_cleanup(sjpeg);
sjpeg = NULL;
return LV_RES_INV;
}
sjpeg->frame_base_offset = NULL;
uint8_t * img_frame_base = sjpeg->sjpeg_data;
sjpeg->frame_base_array[0] = img_frame_base;
sjpeg->sjpeg_cache_frame_index = -1;
sjpeg->frame_cache = (void *)lv_malloc(sjpeg->sjpeg_x_res * sjpeg->sjpeg_single_frame_height * 3);
if(! sjpeg->frame_cache) {
lv_sjpg_cleanup(sjpeg);
sjpeg = NULL;
return LV_RES_INV;
}
sjpeg->io.img_cache_buff = sjpeg->frame_cache;
sjpeg->io.img_cache_x_res = sjpeg->sjpeg_x_res;
sjpeg->workb = lv_malloc(TJPGD_WORKBUFF_SIZE);
if(! sjpeg->workb) {
lv_sjpg_cleanup(sjpeg);
sjpeg = NULL;
return LV_RES_INV;
}
sjpeg->tjpeg_jd = lv_malloc(sizeof(JDEC));
if(! sjpeg->tjpeg_jd) {
lv_sjpg_cleanup(sjpeg);
sjpeg = NULL;
return LV_RES_INV;
}
sjpeg->io.type = SJPEG_IO_SOURCE_C_ARRAY;
sjpeg->io.lv_file.file_d = NULL;
dsc->img_data = NULL;
return lv_ret;
}
else {
lv_ret = LV_RES_INV;
goto end;
}
end:
lv_free(workb_temp);
return lv_ret;
}
}
else if(dsc->src_type == LV_IMAGE_SRC_FILE) {
/* If all fine, then the file will be kept open */
const char * fn = dsc->src;
uint8_t * data;
if(strcmp(lv_fs_get_ext(fn), "sjpg") == 0) {
uint8_t buff[22];
memset(buff, 0, sizeof(buff));
lv_fs_file_t lv_file;
lv_fs_res_t res = lv_fs_open(&lv_file, fn, LV_FS_MODE_RD);
if(res != LV_FS_RES_OK) {
return 78;
}
uint32_t rn;
res = lv_fs_read(&lv_file, buff, 22, &rn);
if(res != LV_FS_RES_OK || rn != 22) {
lv_fs_close(&lv_file);
return LV_RES_INV;
}
if(strcmp((char *)buff, "_SJPG__") == 0) {
SJPEG * sjpeg = (SJPEG *) dsc->user_data;
if(sjpeg == NULL) {
sjpeg = lv_malloc(sizeof(SJPEG));
if(! sjpeg) {
lv_fs_close(&lv_file);
return LV_RES_INV;
}
memset(sjpeg, 0, sizeof(SJPEG));
dsc->user_data = sjpeg;
sjpeg->sjpeg_data = (uint8_t *)((lv_image_dsc_t *)(dsc->src))->data;
sjpeg->sjpeg_data_size = ((lv_image_dsc_t *)(dsc->src))->data_size;
}
data = buff;
data += 14;
sjpeg->sjpeg_x_res = *data++;
sjpeg->sjpeg_x_res |= *data++ << 8;
sjpeg->sjpeg_y_res = *data++;
sjpeg->sjpeg_y_res |= *data++ << 8;
sjpeg->sjpeg_total_frames = *data++;
sjpeg->sjpeg_total_frames |= *data++ << 8;
sjpeg->sjpeg_single_frame_height = *data++;
sjpeg->sjpeg_single_frame_height |= *data++ << 8;
sjpeg->frame_base_array = NULL;//lv_malloc( sizeof(uint8_t *) * sjpeg->sjpeg_total_frames );
sjpeg->frame_base_offset = lv_malloc(sizeof(int) * sjpeg->sjpeg_total_frames);
if(! sjpeg->frame_base_offset) {
lv_fs_close(&lv_file);
lv_sjpg_cleanup(sjpeg);
return LV_RES_INV;
}
int img_frame_start_offset = (SJPEG_FRAME_INFO_ARRAY_OFFSET + sjpeg->sjpeg_total_frames * 2);
sjpeg->frame_base_offset[0] = img_frame_start_offset; //pointer used to save integer for now...
for(int i = 1; i < sjpeg->sjpeg_total_frames; i++) {
res = lv_fs_read(&lv_file, buff, 2, &rn);
if(res != LV_FS_RES_OK || rn != 2) {
lv_fs_close(&lv_file);
return LV_RES_INV;
}
data = buff;
int offset = *data++;
offset |= *data++ << 8;
sjpeg->frame_base_offset[i] = sjpeg->frame_base_offset[i - 1] + offset;
}
sjpeg->sjpeg_cache_frame_index = -1; //INVALID AT BEGINNING for a forced compare mismatch at first time.
sjpeg->frame_cache = (void *)lv_malloc(sjpeg->sjpeg_x_res * sjpeg->sjpeg_single_frame_height * 3);
if(! sjpeg->frame_cache) {
lv_fs_close(&lv_file);
lv_sjpg_cleanup(sjpeg);
return LV_RES_INV;
}
sjpeg->io.img_cache_buff = sjpeg->frame_cache;
sjpeg->io.img_cache_x_res = sjpeg->sjpeg_x_res;
sjpeg->workb = lv_malloc(TJPGD_WORKBUFF_SIZE);
if(! sjpeg->workb) {
lv_fs_close(&lv_file);
lv_sjpg_cleanup(sjpeg);
return LV_RES_INV;
}
sjpeg->tjpeg_jd = lv_malloc(sizeof(JDEC));
if(! sjpeg->tjpeg_jd) {
lv_fs_close(&lv_file);
lv_sjpg_cleanup(sjpeg);
return LV_RES_INV;
}
sjpeg->io.type = SJPEG_IO_SOURCE_DISK;
sjpeg->io.lv_file = lv_file;
dsc->img_data = NULL;
return LV_RES_OK;
}
}
else if(strcmp(lv_fs_get_ext(fn), "jpg") == 0) {
lv_fs_file_t lv_file;
lv_fs_res_t res = lv_fs_open(&lv_file, fn, LV_FS_MODE_RD);
if(res != LV_FS_RES_OK) {
return LV_RES_INV;
}
SJPEG * sjpeg = (SJPEG *) dsc->user_data;
if(sjpeg == NULL) {
sjpeg = lv_malloc(sizeof(SJPEG));
if(! sjpeg) {
lv_fs_close(&lv_file);
return LV_RES_INV;
}
memset(sjpeg, 0, sizeof(SJPEG));
dsc->user_data = sjpeg;
sjpeg->sjpeg_data = (uint8_t *)((lv_image_dsc_t *)(dsc->src))->data;
sjpeg->sjpeg_data_size = ((lv_image_dsc_t *)(dsc->src))->data_size;
}
uint8_t * workb_temp = lv_malloc(TJPGD_WORKBUFF_SIZE);
if(! workb_temp) {
lv_fs_close(&lv_file);
lv_sjpg_cleanup(sjpeg);
return LV_RES_INV;
}
io_source_t io_source_temp;
io_source_temp.type = SJPEG_IO_SOURCE_DISK;
io_source_temp.raw_sjpg_data_next_read_pos = 0;
io_source_temp.img_cache_buff = NULL;
io_source_temp.lv_file = lv_file;
JDEC jd_tmp;
JRESULT rc = jd_prepare(&jd_tmp, input_func, workb_temp, (size_t)TJPGD_WORKBUFF_SIZE, &io_source_temp);
lv_free(workb_temp);
if(rc == JDR_OK) {
sjpeg->sjpeg_x_res = jd_tmp.width;
sjpeg->sjpeg_y_res = jd_tmp.height;
sjpeg->sjpeg_total_frames = 1;
sjpeg->sjpeg_single_frame_height = jd_tmp.height;
sjpeg->frame_base_array = NULL;
sjpeg->frame_base_offset = lv_malloc(sizeof(uint8_t *) * sjpeg->sjpeg_total_frames);
if(! sjpeg->frame_base_offset) {
lv_fs_close(&lv_file);
lv_sjpg_cleanup(sjpeg);
return LV_RES_INV;
}
int img_frame_start_offset = 0;
sjpeg->frame_base_offset[0] = img_frame_start_offset;
sjpeg->sjpeg_cache_frame_index = -1;
sjpeg->frame_cache = (void *)lv_malloc(sjpeg->sjpeg_x_res * sjpeg->sjpeg_single_frame_height * 3);
if(! sjpeg->frame_cache) {
lv_fs_close(&lv_file);
lv_sjpg_cleanup(sjpeg);
return LV_RES_INV;
}
sjpeg->io.img_cache_buff = sjpeg->frame_cache;
sjpeg->io.img_cache_x_res = sjpeg->sjpeg_x_res;
sjpeg->workb = lv_malloc(TJPGD_WORKBUFF_SIZE);
if(! sjpeg->workb) {
lv_fs_close(&lv_file);
lv_sjpg_cleanup(sjpeg);
return LV_RES_INV;
}
sjpeg->tjpeg_jd = lv_malloc(sizeof(JDEC));
if(! sjpeg->tjpeg_jd) {
lv_fs_close(&lv_file);
lv_sjpg_cleanup(sjpeg);
return LV_RES_INV;
}
sjpeg->io.type = SJPEG_IO_SOURCE_DISK;
sjpeg->io.lv_file = lv_file;
dsc->img_data = NULL;
return LV_RES_OK;
}
else {
if(dsc->user_data) lv_free(dsc->user_data);
lv_fs_close(&lv_file);
return LV_RES_INV;
}
}
}
return LV_RES_INV;
}
/**
* Decode `len` pixels starting from the given `x`, `y` coordinates and store them in `buf`.
* Required only if the "open" function can't open the whole decoded pixel array. (dsc->img_data == NULL)
* @param decoder pointer to the decoder the function associated with
* @param dsc pointer to decoder descriptor
* @param x start x coordinate
* @param y start y coordinate
* @param len number of pixels to decode
* @param buf a buffer to store the decoded pixels
* @return LV_RES_OK: ok; LV_RES_INV: failed
*/
static lv_res_t decoder_read_line(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc, lv_coord_t x,
lv_coord_t y,
lv_coord_t len, uint8_t * buf)
{
LV_UNUSED(decoder);
if(dsc->src_type == LV_IMAGE_SRC_VARIABLE) {
SJPEG * sjpeg = (SJPEG *) dsc->user_data;
JRESULT rc;
int sjpeg_req_frame_index = y / sjpeg->sjpeg_single_frame_height;
/*If line not from cache, refresh cache */
if(sjpeg_req_frame_index != sjpeg->sjpeg_cache_frame_index) {
sjpeg->io.raw_sjpg_data = sjpeg->frame_base_array[ sjpeg_req_frame_index ];
if(sjpeg_req_frame_index == (sjpeg->sjpeg_total_frames - 1)) {
/*This is the last frame. */
const uint32_t frame_offset = (uint32_t)(sjpeg->io.raw_sjpg_data - sjpeg->sjpeg_data);
sjpeg->io.raw_sjpg_data_size = sjpeg->sjpeg_data_size - frame_offset;
}
else {
sjpeg->io.raw_sjpg_data_size =
(uint32_t)(sjpeg->frame_base_array[sjpeg_req_frame_index + 1] - sjpeg->io.raw_sjpg_data);
}
sjpeg->io.raw_sjpg_data_next_read_pos = 0;
rc = jd_prepare(sjpeg->tjpeg_jd, input_func, sjpeg->workb, (size_t)TJPGD_WORKBUFF_SIZE, &(sjpeg->io));
if(rc != JDR_OK) return LV_RES_INV;
rc = jd_decomp(sjpeg->tjpeg_jd, img_data_cb, 0);
if(rc != JDR_OK) return LV_RES_INV;
sjpeg->sjpeg_cache_frame_index = sjpeg_req_frame_index;
}
int offset = 0;
uint8_t * cache = (uint8_t *)sjpeg->frame_cache + x * 3 + (y % sjpeg->sjpeg_single_frame_height) * sjpeg->sjpeg_x_res *
3;
#if LV_COLOR_DEPTH == 32
for(int i = 0; i < len; i++) {
buf[offset + 3] = 0xff;
buf[offset + 2] = *cache++;
buf[offset + 1] = *cache++;
buf[offset + 0] = *cache++;
offset += 4;
}
#elif LV_COLOR_DEPTH == 24
for(int i = 0; i < len; i++) {
buf[offset + 2] = *cache++;
buf[offset + 1] = *cache++;
buf[offset + 0] = *cache++;
offset += 3;
}
#elif LV_COLOR_DEPTH == 16
for(int i = 0; i < len; i++) {
uint16_t col_16bit = (*cache++ & 0xf8) << 8;
col_16bit |= (*cache++ & 0xFC) << 3;
col_16bit |= (*cache++ >> 3);
#if LV_BIG_ENDIAN_SYSTEM == 1
buf[offset++] = col_16bit >> 8;
buf[offset++] = col_16bit & 0xff;
#else
buf[offset++] = col_16bit & 0xff;
buf[offset++] = col_16bit >> 8;
#endif // LV_BIG_ENDIAN_SYSTEM
}
#elif LV_COLOR_DEPTH == 8
for(int i = 0; i < len; i++) {
uint8_t col_8bit = (*cache++ & 0xC0);
col_8bit |= (*cache++ & 0xe0) >> 2;
col_8bit |= (*cache++ & 0xe0) >> 5;
buf[offset++] = col_8bit;
}
#else
#error Unsupported LV_COLOR_DEPTH
#endif // LV_COLOR_DEPTH
return LV_RES_OK;
}
else if(dsc->src_type == LV_IMAGE_SRC_FILE) {
SJPEG * sjpeg = (SJPEG *) dsc->user_data;
JRESULT rc;
int sjpeg_req_frame_index = y / sjpeg->sjpeg_single_frame_height;
lv_fs_file_t * lv_file_p = &(sjpeg->io.lv_file);
if(!lv_file_p) goto end;
/*If line not from cache, refresh cache */
if(sjpeg_req_frame_index != sjpeg->sjpeg_cache_frame_index) {
sjpeg->io.raw_sjpg_data_next_read_pos = (int)(sjpeg->frame_base_offset [ sjpeg_req_frame_index ]);
lv_fs_seek(&(sjpeg->io.lv_file), sjpeg->io.raw_sjpg_data_next_read_pos, LV_FS_SEEK_SET);
rc = jd_prepare(sjpeg->tjpeg_jd, input_func, sjpeg->workb, (size_t)TJPGD_WORKBUFF_SIZE, &(sjpeg->io));
if(rc != JDR_OK) return LV_RES_INV;
rc = jd_decomp(sjpeg->tjpeg_jd, img_data_cb, 0);
if(rc != JDR_OK) return LV_RES_INV;
sjpeg->sjpeg_cache_frame_index = sjpeg_req_frame_index;
}
int offset = 0;
uint8_t * cache = (uint8_t *)sjpeg->frame_cache + x * 3 + (y % sjpeg->sjpeg_single_frame_height) * sjpeg->sjpeg_x_res *
3;
#if LV_COLOR_DEPTH == 32
for(int i = 0; i < len; i++) {
buf[offset + 3] = 0xff;
buf[offset + 2] = *cache++;
buf[offset + 1] = *cache++;
buf[offset + 0] = *cache++;
offset += 4;
}
#elif LV_COLOR_DEPTH == 24
for(int i = 0; i < len; i++) {
buf[offset + 2] = *cache++;
buf[offset + 1] = *cache++;
buf[offset + 0] = *cache++;
offset += 3;
}
#elif LV_COLOR_DEPTH == 16
for(int i = 0; i < len; i++) {
uint16_t col_8bit = (*cache++ & 0xf8) << 8;
col_8bit |= (*cache++ & 0xFC) << 3;
col_8bit |= (*cache++ >> 3);
#if LV_BIG_ENDIAN_SYSTEM == 1
buf[offset++] = col_8bit >> 8;
buf[offset++] = col_8bit & 0xff;
#else
buf[offset++] = col_8bit & 0xff;
buf[offset++] = col_8bit >> 8;
#endif // LV_BIG_ENDIAN_SYSTEM
}
#elif LV_COLOR_DEPTH == 8
for(int i = 0; i < len; i++) {
uint8_t col_8bit = (*cache++ & 0xC0);
col_8bit |= (*cache++ & 0xe0) >> 2;
col_8bit |= (*cache++ & 0xe0) >> 5;
buf[offset++] = col_8bit;
}
#else
#error Unsupported LV_COLOR_DEPTH
#endif // LV_COLOR_DEPTH
return LV_RES_OK;
}
end:
return LV_RES_INV;
}
/**
* Free the allocated resources
* @param decoder pointer to the decoder where this function belongs
* @param dsc pointer to a descriptor which describes this decoding session
*/
static void decoder_close(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc)
{
LV_UNUSED(decoder);
/*Free all allocated data*/
SJPEG * sjpeg = (SJPEG *) dsc->user_data;
if(!sjpeg) return;
switch(dsc->src_type) {
case LV_IMAGE_SRC_FILE:
if(sjpeg->io.lv_file.file_d) {
lv_fs_close(&(sjpeg->io.lv_file));
}
lv_sjpg_cleanup(sjpeg);
break;
case LV_IMAGE_SRC_VARIABLE:
lv_sjpg_cleanup(sjpeg);
break;
default:
;
}
}
static int is_jpg(const uint8_t * raw_data, size_t len)
{
const uint8_t jpg_signature[] = {0xFF, 0xD8, 0xFF, 0xE0, 0x00, 0x10, 0x4A, 0x46, 0x49, 0x46};
if(len < sizeof(jpg_signature)) return false;
return memcmp(jpg_signature, raw_data, sizeof(jpg_signature)) == 0;
}
static void lv_sjpg_free(SJPEG * sjpeg)
{
if(sjpeg->frame_cache) lv_free(sjpeg->frame_cache);
if(sjpeg->frame_base_array) lv_free(sjpeg->frame_base_array);
if(sjpeg->frame_base_offset) lv_free(sjpeg->frame_base_offset);
if(sjpeg->tjpeg_jd) lv_free(sjpeg->tjpeg_jd);
if(sjpeg->workb) lv_free(sjpeg->workb);
}
static void lv_sjpg_cleanup(SJPEG * sjpeg)
{
if(! sjpeg) return;
lv_sjpg_free(sjpeg);
lv_free(sjpeg);
}
#endif /*LV_USE_SJPG*/

View File

@@ -17,7 +17,7 @@
#include "libs/fsdrv/lv_fsdrv.h"
#include "libs/gif/lv_gif.h"
#include "libs/png/lv_png.h"
#include "libs/sjpg/lv_sjpg.h"
#include "libs/jpg/lv_jpg.h"
#include "draw/lv_draw.h"
#include "misc/lv_cache.h"
#include "misc/lv_cache_builtin.h"
@@ -220,7 +220,7 @@ void lv_init(void)
#endif
#if LV_USE_SJPG
lv_split_jpeg_init();
lv_jpeg_init();
#endif
#if LV_USE_BMP

View File

@@ -167,14 +167,14 @@ typedef uint8_t lv_color_format_t;
/**
* Get the pixel size of a color format in bytes
* @param src_cf a color format (`LV_IMAGE_CF_...`)
* @param src_cf a color format (`LV_COLOR_FORMAT_...`)
* @return the pixel size in bytes
*/
uint8_t lv_color_format_get_size(lv_color_format_t src_cf);
/**
* Get the pixel size of a color format in bits, bpp
* @param src_cf a color format (`LV_IMAGE_CF_...`)
* @param src_cf a color format (`LV_COLOR_FORMAT_...`)
* @return the pixel size in bits
*/
uint8_t lv_color_format_get_bpp(lv_color_format_t cf);

View File

@@ -106,7 +106,7 @@ lv_fs_res_t lv_fs_open(lv_fs_file_t * file_p, const char * path, lv_fs_mode_t mo
/* If this is a memory-mapped file, then set "cache" to the memory buffer */
if(drv->cache_size == LV_FS_CACHE_FROM_BUFFER) {
lv_fs_path_ex_t * path_ex = (lv_fs_path_ex_t *)path;
file_p->cache->buffer = path_ex->buffer;
file_p->cache->buffer = (void *)path_ex->buffer;
file_p->cache->start = 0;
file_p->cache->file_position = 0;
file_p->cache->end = path_ex->size;
@@ -121,7 +121,7 @@ lv_fs_res_t lv_fs_open(lv_fs_file_t * file_p, const char * path, lv_fs_mode_t mo
return LV_FS_RES_OK;
}
void lv_fs_make_path_from_buffer(lv_fs_path_ex_t * path, char letter, void * buf, uint32_t size)
void lv_fs_make_path_from_buffer(lv_fs_path_ex_t * path, char letter, const void * buf, uint32_t size)
{
path->path[0] = letter;
path->path[1] = ':';
@@ -175,7 +175,7 @@ static lv_fs_res_t lv_fs_read_cached(lv_fs_file_t * file_p, char * buf, uint32_t
/* Do not allow reading beyond the actual memory block for memory-mapped files */
if(file_p->drv->cache_size == LV_FS_CACHE_FROM_BUFFER) {
if(btr > buffer_remaining_length)
btr = buffer_remaining_length;
btr = buffer_remaining_length - 1;
}
if(btr <= buffer_remaining_length) {

View File

@@ -115,7 +115,7 @@ typedef struct {
/* Extended path object to specify the buffer for memory-mapped files */
typedef struct {
char path[4]; /* This is needed to make it compatible with a normal path */
void * buffer;
const void * buffer;
uint32_t size;
} lv_fs_path_ex_t;
@@ -180,7 +180,7 @@ lv_fs_res_t lv_fs_open(lv_fs_file_t * file_p, const char * path, lv_fs_mode_t mo
* @param buf address of the memory buffer
* @param size size of the memory buffer in bytes
*/
void lv_fs_make_path_from_buffer(lv_fs_path_ex_t * path, char letter, void * buf, uint32_t size);
void lv_fs_make_path_from_buffer(lv_fs_path_ex_t * path, char letter, const void * buf, uint32_t size);
/**
* Close an already opened file

View File

@@ -159,6 +159,8 @@ add_library(test_common
src/test_assets/font_3_bin.c
src/test_assets/test_img_caret_down.c
src/test_assets/test_arc_bg.c
src/test_assets/test_img_lvgl_logo_png.c
src/test_assets/test_img_lvgl_logo_jpg.c
src/test_assets/ubuntu_font.c
unity/unity_support.c
unity/unity.c
@@ -176,7 +178,7 @@ set(generate_test_runner_config ${CMAKE_CURRENT_SOURCE_DIR}/config.yml)
# disable test targets for build only tests
if (ENABLE_TESTS)
file( GLOB TEST_CASE_FILES src/test_cases/*.c )
file( GLOB_RECURSE TEST_CASE_FILES src/test_cases/*.c )
else()
set(TEST_CASE_FILES)
endif()

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -0,0 +1,174 @@
#include "../../../lvgl.h"
#ifndef LV_ATTRIBUTE_MEM_ALIGN
#define LV_ATTRIBUTE_MEM_ALIGN
#endif
#ifndef LV_ATTRIBUTE_IMG_TEST_IMG_LVGL_LOGO_JPG
#define LV_ATTRIBUTE_IMG_TEST_IMG_LVGL_LOGO_JPG
#endif
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_TEST_IMG_LVGL_LOGO_JPG uint8_t
test_img_lvgl_logo_jpg_map[] = {
0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01,
0x01, 0x01, 0x2c, 0x01, 0x2c, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x13, 0x43, 0x72,
0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49,
0x4d, 0x50, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x08, 0x06, 0x06, 0x07, 0x06, 0x05,
0x08, 0x07, 0x07, 0x07, 0x09, 0x09, 0x08, 0x0a, 0x0c, 0x15, 0x0e, 0x0c, 0x0b,
0x0b, 0x0c, 0x19, 0x12, 0x13, 0x0f, 0x15, 0x1e, 0x1b, 0x20, 0x1f, 0x1e, 0x1b,
0x1d, 0x1d, 0x21, 0x25, 0x30, 0x29, 0x21, 0x23, 0x2d, 0x24, 0x1d, 0x1d, 0x2a,
0x39, 0x2a, 0x2d, 0x31, 0x33, 0x36, 0x36, 0x36, 0x20, 0x28, 0x3b, 0x3f, 0x3a,
0x34, 0x3e, 0x30, 0x35, 0x36, 0x33, 0xff, 0xdb, 0x00, 0x43, 0x01, 0x09, 0x09,
0x09, 0x0c, 0x0b, 0x0c, 0x18, 0x0e, 0x0e, 0x18, 0x33, 0x22, 0x1d, 0x22, 0x33,
0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0xff, 0xc0, 0x00,
0x11, 0x08, 0x00, 0x21, 0x00, 0x69, 0x03, 0x01, 0x11, 0x00, 0x02, 0x11, 0x01,
0x03, 0x11, 0x01, 0xff, 0xc4, 0x00, 0x1f, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0xff, 0xc4, 0x00,
0xb5, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x03, 0x05, 0x05, 0x04,
0x04, 0x00, 0x00, 0x01, 0x7d, 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81,
0x91, 0xa1, 0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, 0x24, 0x33,
0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27,
0x28, 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45,
0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a,
0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77,
0x78, 0x79, 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93,
0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2,
0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6,
0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xff, 0xc4,
0x00, 0x1f, 0x01, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
0x07, 0x08, 0x09, 0x0a, 0x0b, 0xff, 0xc4, 0x00, 0xb5, 0x11, 0x00, 0x02, 0x01,
0x02, 0x04, 0x04, 0x03, 0x04, 0x07, 0x05, 0x04, 0x04, 0x00, 0x01, 0x02, 0x77,
0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51,
0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xa1, 0xb1,
0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24,
0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, 0x27, 0x28, 0x29, 0x2a,
0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66,
0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x82,
0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96,
0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa,
0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5,
0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9,
0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4,
0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00,
0x02, 0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 0x05, 0x00, 0x14, 0x00, 0x50, 0x01, 0x40,
0x05, 0x00, 0x14, 0x00, 0x50, 0x01, 0x40, 0x1f, 0xff, 0xd9
};
const lv_img_dsc_t test_img_lvgl_logo_jpg = {
.header.cf = LV_COLOR_FORMAT_RAW,
.header.always_zero = 0,
.header.reserved = 0,
.header.w = 105,
.header.h = 33,
.data_size = 1947,
.data = test_img_lvgl_logo_jpg_map,
};

View File

@@ -0,0 +1,169 @@
#include "../../..//lvgl.h"
#ifndef LV_ATTRIBUTE_MEM_ALIGN
#define LV_ATTRIBUTE_MEM_ALIGN
#endif
#ifndef LV_ATTRIBUTE_IMG_TEST_IMG_LVGL_LOGO_PNG
#define LV_ATTRIBUTE_IMG_TEST_IMG_LVGL_LOGO_PNG
#endif
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_TEST_IMG_LVGL_LOGO_PNG uint8_t
test_img_lvgl_logo_png_map[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49,
0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x21, 0x08, 0x06,
0x00, 0x00, 0x00, 0xda, 0x89, 0x85, 0x3b, 0x00, 0x00, 0x00, 0x06, 0x62, 0x4b,
0x47, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x43, 0xbb, 0x7f, 0x00,
0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x2e, 0x23, 0x00, 0x00,
0x2e, 0x23, 0x01, 0x78, 0xa5, 0x3f, 0x76, 0x00, 0x00, 0x00, 0x07, 0x74, 0x49,
0x4d, 0x45, 0x07, 0xe7, 0x09, 0x12, 0x12, 0x25, 0x07, 0x59, 0xa0, 0x4e, 0xa5,
0x00, 0x00, 0x00, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43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, 0xfd, 0x44, 0x7b, 0x80,
0x3d, 0x53, 0xdd, 0x93, 0x4a, 0xf5, 0xd2, 0x63, 0x0a, 0xf5, 0xdc, 0x45, 0x89,
0x52, 0xa9, 0x04, 0x0c, 0x55, 0x39, 0x6f, 0x1d, 0x05, 0xee, 0x3e, 0xd7, 0x33,
0x1b, 0x87, 0x0f, 0xcf, 0xce, 0x1d, 0x93, 0x1c, 0x84, 0xce, 0xb4, 0xbc, 0xc9,
0x76, 0x56, 0x39, 0x03, 0xed, 0x50, 0xf8, 0x97, 0xc0, 0x72, 0xca, 0x77, 0x31,
0x95, 0xb0, 0xfb, 0x52, 0x70, 0xc6, 0xe4, 0x7b, 0x09, 0x64, 0xc1, 0x84, 0x1e,
0x4e, 0x29, 0xec, 0x2a, 0xba, 0xe8, 0x55, 0xda, 0x68, 0xa3, 0x8d, 0x36, 0xda,
0x68, 0xa3, 0x8d, 0x73, 0x1a, 0xff, 0x01, 0xc1, 0xba, 0x4f, 0x53, 0x6b, 0xda,
0x6f, 0x58, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60,
0x82
};
const lv_img_dsc_t test_img_lvgl_logo_png = {
.header.cf = LV_COLOR_FORMAT_RAW_ALPHA,
.header.always_zero = 0,
.header.reserved = 0,
.header.w = 105,
.header.h = 33,
.data_size = 1873,
.data = test_img_lvgl_logo_png_map,
};

View File

@@ -128,7 +128,7 @@ static void canvas_draw(const char * name, lv_color_format_t large_render_cf)
lv_canvas_set_buffer(canvas2, canvas2_buf, 770, 390, large_render_cf);
lv_canvas_fill_bg(canvas2, lv_palette_lighten(LV_PALETTE_BLUE_GREY, 2), LV_OPA_COVER);
lv_image_dsc_t img = { 0 };
lv_img_dsc_t img = { 0 };
img.header.w = 180;
img.header.h = 180;
img.header.stride = 0;

View File

@@ -118,6 +118,7 @@ void test_image_built_in_decode_recolor(void)
img_create("binXRGB8888", "A:src/test_files/binimages/cogwheel.XRGB8888.bin", false, true);
img_create("binARGB8888", "A:src/test_files/binimages/cogwheel.ARGB8888.bin", false, true);
TEST_ASSERT_EQUAL_SCREENSHOT("draw/image_format_recolor.png");
}

View File

@@ -0,0 +1,63 @@
#if LV_BUILD_TEST
#include "../lvgl.h"
#include "unity/unity.h"
#include "lv_test_helpers.h"
void setUp(void)
{
/* Function run before every test */
}
void tearDown(void)
{
/* Function run after every test */
}
static void create_images(void)
{
lv_obj_clean(lv_scr_act());
lv_obj_t * img;
lv_obj_t * label;
LV_IMG_DECLARE(test_img_lvgl_logo_jpg);
img = lv_img_create(lv_scr_act());
lv_img_set_src(img, &test_img_lvgl_logo_jpg);
lv_obj_align(img, LV_ALIGN_CENTER, -100, -20);
label = lv_label_create(lv_scr_act());
lv_label_set_text(label, "Array");
lv_obj_align(label, LV_ALIGN_CENTER, -100, 20);
img = lv_img_create(lv_scr_act());
lv_img_set_src(img, "A:src/test_assets/test_img_lvgl_logo.jpg");
lv_obj_align(img, LV_ALIGN_CENTER, 100, -20);
label = lv_label_create(lv_scr_act());
lv_label_set_text(label, "File");
lv_obj_align(label, LV_ALIGN_CENTER, 100, 20);
}
void test_jpg_1(void)
{
create_images();
TEST_ASSERT_EQUAL_SCREENSHOT("libs/jpg_1.png");
uint32_t mem_before = lv_test_get_free_mem();
for(uint32_t i = 0; i < 20; i++) {
create_images();
lv_obj_invalidate(lv_scr_act());
lv_refr_now(NULL);
}
TEST_ASSERT_EQUAL_SCREENSHOT("libs/jpg_1.png");
TEST_ASSERT_EQUAL(mem_before, lv_test_get_free_mem());
}
#endif

View File

@@ -0,0 +1,63 @@
#if LV_BUILD_TEST
#include "../lvgl.h"
#include "unity/unity.h"
#include "lv_test_helpers.h"
void setUp(void)
{
/* Function run before every test */
}
void tearDown(void)
{
/* Function run after every test */
}
static void create_images(void)
{
lv_obj_clean(lv_scr_act());
lv_obj_t * img;
lv_obj_t * label;
LV_IMG_DECLARE(test_img_lvgl_logo_png);
img = lv_img_create(lv_scr_act());
lv_img_set_src(img, &test_img_lvgl_logo_png);
lv_obj_align(img, LV_ALIGN_CENTER, -100, -20);
label = lv_label_create(lv_scr_act());
lv_label_set_text(label, "Array");
lv_obj_align(label, LV_ALIGN_CENTER, -100, 20);
img = lv_img_create(lv_scr_act());
lv_img_set_src(img, "A:src/test_assets/test_img_lvgl_logo.png");
lv_obj_align(img, LV_ALIGN_CENTER, 100, -20);
label = lv_label_create(lv_scr_act());
lv_label_set_text(label, "File");
lv_obj_align(label, LV_ALIGN_CENTER, 100, 20);
}
void test_png_1(void)
{
create_images();
TEST_ASSERT_EQUAL_SCREENSHOT("libs/png_1.png");
uint32_t mem_before = lv_test_get_free_mem();
for(uint32_t i = 0; i < 20; i++) {
create_images();
lv_obj_invalidate(lv_scr_act());
lv_refr_now(NULL);
}
TEST_ASSERT_EQUAL_SCREENSHOT("libs/png_1.png");
TEST_ASSERT_EQUAL(mem_before, lv_test_get_free_mem());
}
#endif