新手入门
- 积分
- 17
- 金钱
- 17
- 注册时间
- 2016-2-25
- 在线时间
- 7 小时
|
1金钱
各位大神好,现在我使用emwin中的控件image显示图片,由于图片太多,所以放在外部的flash芯片中。程序代码如下:
[mw_shl_code=c,true]unsigned char _acBuffer[320*4*8];
int _GetData(void * p, const U8 ** ppData, unsigned NumBytesReq, U32 Off)
{
static int FileAddress = 0;
UINT NumBytesRead;
FIL *PicFile;
PicFile = (FIL *)p;
/*
* Check buffer size
*/
if (NumBytesReq > sizeof(_acBuffer)) {
NumBytesReq = sizeof(_acBuffer);
}
/*
* Set file pointer to the required position
*/
if(Off == 1) FileAddress = 0;
else FileAddress = Off;
result =f_lseek(PicFile, FileAddress);
/*
* Read data into buffer
*/
result = f_read(PicFile, _acBuffer, NumBytesReq, &NumBytesRead);
/*
* Set data pointer to the beginning of the buffer
*/
*ppData = (const U8 *)_acBuffer;
/*
* Return number of available bytes
*/
return NumBytesRead;
}[/mw_shl_code]
[mw_shl_code=c,true]void DisplayImageFromExFlash(IMAGE_Handle hObj,const TCHAR* path)
{
FRESULT res_flash;
res_flash = f_open(&fnew1, path, FA_OPEN_EXISTING | FA_READ);
IMAGE_SetBMPEx ( hObj, _GetData, &fnew1);
f_close(&fnew1);
}
[/mw_shl_code]
发现程序执行到IMAGE_SetBMPEx ( hObj, _GetData, &fnew1);并不会调到int _GetData(void * p, const U8 ** ppData, unsigned NumBytesReq, U32 Off) 中,而是直接执行f_close(&fnew1);过后再执行_GetData(),
导致显示不了图片,请问这是什么原因呢?谢谢
|
|