页次: 1
问题已经解决了,贴一个自己测试可以用的demo代码:
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; //去掉4字节的头,剩余的就是图片数据流长度
image->data = pbmp;
}
页次: 1