当前位置:网站首页>Esp32 development -lvgl display picture
Esp32 development -lvgl display picture
2022-06-11 04:07:00 【z_ Curtain】
How to use pictures
LVGL There are two ways to display pictures in
1、 As internal memory (RAM or ROM) The variables in the
2、 As a document
Read pictures internally
advantage : Data is compiled into firmware along with code , Easy to use .
shortcoming : Images need to be converted into array form by tools , Too many pictures perhaps The picture resolution is too large Compilation errors may occur during ( Constant data exceeded DROM).
The method of use is similar to the external font library , Use the tool to turn the picture into a .c file , In the file, there will be a constant array and... For storing image data LVGL Picture data type structure of , At the same time, the structure variable can use the picture .
const lv_img_dsc_t test = {
.header.always_zero = 0,
.header.w = 225,
.header.h = 113,
.data_size = 25425 * LV_COLOR_SIZE / 8,
.header.cf = LV_IMG_CF_TRUE_COLOR,
.data = test_map,
};
adopt LVGL api The picture can be displayed
lv_obj_t * icon = lv_img_create(lv_scr_act(), NULL);
/*From variable*/
LV_IMG_DECLARE(test );
lv_img_set_src(icon, &test );
If the image is converted using an online or tool converter , You should use LV_IMG_DECLARE(my_icon_dsc) The image declares the bits to be used in the file
Set up .
// amount to extern
#define LV_IMG_DECLARE(var_name) extern const lv_img_dsc_t var_name;
External read picture
There are two ways to store external pictures
1、 As png、jpg Wait for the picture format
Need to use SD Memory devices such as cards store pictures , It also needs to decode the picture ,LVGL Provide picture decoding API( Only partial format decoding should be supported , for example PNG)
lv_res_t res;
lv_img_decoder_dsc_t dsc;
res = lv_img_decoder_open(&dsc, &my_img_dsc, LV_COLOR_WHITE);
if(res == LV_RES_OK) {
/*Do something with `dsc->img_data`*/
lv_img_decoder_close(&dsc);
}
2、 As bin file
When pictures are bin When the file is read , need esp32 Run the file system , For details, please refer to ESP-IDF demo Medium spiffs.
Besides , It needs to be realized lvgl File manipulation functions in the file system . Refer to the following figure for specific documents .
As a binary file ,bin The file can specify the desired color format :
RGB332 be used for 8 Metachromatic depth
RGB565 be used for 16 Metachromatic depth
RGB565 In exchange for 16 Bit color depth ( Swapped two bytes )
RGB888 be used for 32 Metachromatic depth
lv_obj_t * icon = lv_img_create(lv_scr_act(), NULL);
/*From file*/
lv_img_set_src(icon, "S:test.bin");
边栏推荐
- Linq. pdf
- Market prospect analysis and Research Report of marking laser in 2022
- 图像检测相关模型数据格式
- 零时科技 | Discover 闪电贷攻击事件分析
- 【CNN】|How much position information do convolutional neural networks encode?
- A - Eddy's AC puzzle (C language)
- MAUI 迁移指南
- How to invest in programming knowledge and reduce the impact of knowledge failure
- BP神经网络C语言实现总结
- 基于FPGA的一维卷积神经网络CNN的实现(五)数据量化(附代码)
猜你喜欢

Thoughts on the number of threads and CPU caused by the CPU load high alarm

华生·K的秘密日记

写给通信年轻人的27个忠告

【SignalR全套系列】之在.Net6中实SignalR通信

Matlab reports an error when trying to use * * * as a function problem, and tries to execute script PCA as a function:

Docker swarm installing MySQL Cluster

邪恶的CSRF

Sslstrip Ultimate - location hijacking

Eth relay interface

代码复现CSRF攻击并解决它
随机推荐
Pictures that make people feel calm and warm
Market prospect analysis and Research Report of beam combiner in 2022
Market prospect analysis and Research Report of modular lithium ion battery in 2022
Radar emitter modulation signal simulation (code)
Unity prefab scene conflict merge tool unityyamlmerge
Market prospect analysis and Research Report of welding laser in 2022
[cnn]| translation invariance
Samsung Galaxy S21 ultra and Apple iPhone 13 Pro Max: which one should you choose
基于FPGA的一维卷积神经网络CNN的实现(五)数据量化(附代码)
Large factory outsourcing or self research company? How to choose a job for a tester?
合理使用线程池以及线程变量
什么样的人才是幸福的?
Guide de migration Maui
Market prospect analysis and Research Report of engraving laser in 2022
Source Insight 4.0设置注释与反注释的快捷键
A.前缀极差(C语言)
2022-06-10:薯队长从北向南穿过一片红薯地(南北长M,东西宽N),红薯地被划分为1x1的方格, 他可以从北边的任何一个格子出发,到达南边的任何一个格子, 但每一步只能走到东南、正南、西南方向的
AI助力,释放法务势能!iTerms合同智审系统重磅发布
6. 表格标签
Market prospect analysis and Research Report of surround packing machine in 2022