ARM Technical Support Knowledge Articles

Displaying Graphic Files Using FlashFS

Applies to: RealView Real-Time Library

Answer


Information in this knowledgebase article applies to:


QUESTION

I 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?

ANSWER

First, 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 INFORMATION

ATTACHED FILES

Request the files attached to this knowledgebase article.

Article last edited on: 2012-02-07 12:44:04

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential