| ||||||||
Technical Support Support Resources Product Information | RL-ARM: Displaying Graphic Files Using FlashFSInformation in this knowledgebase article applies to:
QUESTIONI want to display a graphic from a memory card using an emWin GUI library ...Ex() function. I know I must supply a GetData function for emWin to call which reads the data. How can I use the Flash File System to perform the GetData function? ANSWERFirst, open your Flash FS device as you normally would. For example, to load and display a BMP file on a memory card:
FILE *f;
f = fopen ("M:\\Test.bmp","r"); /* Open the BMP file. */
if (f == NULL) {
printf ("File not found!\n");
}
Then call the GUI_BMP_DrawEx() function referencing your GetData function: GUI_BMP_DrawEx(APP_GetData, f, 0, 0); Modify the APP_GetData() example function found in the emWin documentation (Section 10.5) as follows:
static char _acBuffer[0x500];
int APP_GetData(void * p, const U8 * * ppData, unsigned NumBytesReq, U32 Off) {
FILE * phFile;
DWORD NumBytesRead;
phFile = (FILE *)p;
//
// Check buffer size
//
if (NumBytesReq > sizeof(_acBuffer)) {
NumBytesReq = sizeof(_acBuffer);
}
//
// Set file pointer to the offset location
//
fseek(phFile, Off, SEEK_SET);
//
// Read data into buffer
//
NumBytesRead = fread(_acBuffer, sizeof(char), NumBytesReq, phfile);
//
// Set data pointer to the beginning of the buffer
//
*ppData = _acBuffer;
//
// Return number of available bytes
//
return NumBytesRead;
}
MORE INFORMATIONLast Reviewed: Tuesday, February 07, 2012 | |||||||
| ||||||||