MXC-A36-Demo/Demo/lv_user_code/basic/user_read_img_function.c

79 lines
1.4 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* @Description:
* @version: acbd
* @Author: joe
* @Date: 2022-01-21 21:22:45
* @LastEditTime: 2022-08-03 10:18:17
*/
#include "lvgl/lvgl.h"
#include <stdio.h>
#include <string.h>
uint8_t read_img_data[10*1024*1024] = {0};
uint8_t my_font_data[2*1024*1024];
lv_font_t *my_font_name;
void user_read_img_init(void)
{
FILE * fp;
uint32_t lSize;
fp = fopen ("lv_user_code/resource/img.hex", "rb");
if(fp != NULL)
{
fseek(fp,0,SEEK_END);
lSize = ftell(fp);
printf("lSize:%x\r\n",lSize);
rewind(fp);
fread(read_img_data,1,lSize,fp);
}
else
{
printf("open img file fail!!\r\n");
}
fclose(fp);
}
/**
* @description: 读取字体数据放至read_font_data全局变量中
* @param {*}
* @return {*}
*/
void user_read_font_init(void)
{
FILE * fp;
uint32_t lSize;
fp = fopen ("lv_user_code/UI_app_I7L/fr5080_font_bin_xip.bin", "rb");
if(fp != NULL)
{
fseek(fp,0,SEEK_END);
lSize = ftell(fp);
printf("lSize:%x\r\n",lSize);
rewind(fp);
fread(my_font_data,1,lSize,fp);
my_font_name->get_glyph_dsc = lv_font_get_glyph_dsc_fmt_txt;
my_font_name->get_glyph_bitmap = lv_font_get_bitmap_fmt_txt;
my_font_name->line_height = 16;
my_font_name->base_line = 3;
my_font_name->subpx = LV_FONT_SUBPX_NONE,
my_font_name->user_data = my_font_data;
}
else
{
printf("open font file fail!!\r\n");
}
fclose(fp);
}