1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
void loadBitmap(lv_img_dsc_t *image, uint32_t start_addr, uint32_t file_size)
{
uint8_t *pbuf; //读取数据缓冲区
uint8_t *pbmp;
uint32_t header;
int secTime = file_size/4096;
int secOff = file_size%4096;
int i;
dbg_printf(" secTime = %d, secOff = %d\r\n", secTime, secOff);
pbuf = lv_mem_alloc(file_size);
for (i=0; i<secTime; i++) {
SPI_Flash_Read(&pbuf[i*4096], start_addr+i*4096, 4096);
}
if (secOff>0) {
SPI_Flash_Read(&pbuf[secTime*4096], start_addr+secTime*4096, secOff);
}
/* 获取图片数据流 */
pbmp = (uint8_t *)pbuf + 4;
/* 获取头 */
header = (uint32_t)pbuf[3] << 24;
header |= (uint32_t)pbuf[2] << 16;
header |= (uint32_t)pbuf[1] << 8;
header |= (uint32_t)pbuf[0];
image->header.cf = pbuf[0];
image->header.always_zero = 0;
image->header.w = (uint16_t)(header >> 10);
image->header.h = (uint16_t)(header >> 21);
image->data_size = file_size - 4;
image->data = pbmp;
}
|