Wednesday, October 18th 2017, 6:28pm UTC+2

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

janos

Beginner

Date of registration: Nov 4th 2014

Posts: 13

1

Friday, March 13th 2015, 4:27pm

Read BMP file from SD card, and display it

Hello!

I have an SD-card attached to the SDIO pins of the STM43F4 board. I'm using this library for reading the files on the card which is working well. Now I want to use the GUI_BMP_DrawEx function to display the bmp. It is clear that I have to implement the _GetData function, but in the SD card library there is no function for eg. to set the file pointer. I have a ReadBlock function and that's all.
Could you help me what kind of function would i need in the _GetData func?
Or could you recommend an SD card reading library which is capable with Stemwin?

Thanks for your furher answer!

janos

Beginner

Date of registration: Nov 4th 2014

Posts: 13

2

Wednesday, March 25th 2015, 4:35pm

This was solved with the current used setup.
My getData function looks like this:

C/C++ Source code

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
34
35
36
static int _GetData(void * p, const U8 ** ppData, unsigned NumBytesReq, U32 Off)
{
  DWORD    NumBytesRead;
  FIL * phFile;
  FATFS_t readState = FATFS_DISK_FULL;
  phFile = (FIL *)p;
  static unsigned char _acBuffer[512];

  /*
  * Check buffer size
  */
  if (NumBytesReq > sizeof(_acBuffer))
  {
    NumBytesReq = sizeof(_acBuffer);
  }

  /*
  * Set file pointer to the required position
  */
  f_lseek(phFile, Off);

  /*
  * Read data into buffer
  */
  readState = UB_Fatfs_ReadBlock(phFile, _acBuffer, NumBytesReq, &NumBytesRead);

  /*
  * Set data pointer to the beginning of the buffer
  */
  *ppData = _acBuffer;

  /*
  * Return number of available bytes
  */
  return NumBytesRead;
}

SEGGER - Adrian

Super Moderator

Date of registration: May 26th 2009

Posts: 994

3

Monday, March 30th 2015, 11:59am

Hello,

Please note that emWin might stop displaying an image in case the return value does not equal NumBytesReq. I would recommend you to check the return value of the GUI_BMP_DrawEx() function.

Also I would recommend you to use the DTA format for displaying images from external memory. DTA images can be created using the Bitmap Converter. Details can be found in the chapter "Bitmap Converter" in the emWin user manual.

Best regards,
Adrian

romanp

Beginner

Date of registration: May 18th 2015

Posts: 3

4

Tuesday, May 19th 2015, 10:33am

Adrian,


could you please provide further information about the 'GetData' function and the situation when less than requested number of bytes are read. Mainly in respect to the comment "It is recommended to make sure that the ’GetData’-function is able to fetch at least one pixel line of the biggest image used by the application." and to the example provided by SEGGER with exactly the same condition:
https://www.segger.com/cms/admin/uploads…rawJPEGScaled.c



Thanks,
Roman

SEGGER - Adrian

Super Moderator

Date of registration: May 26th 2009

Posts: 994

5

Wednesday, May 20th 2015, 9:51am

Hello Roman,

This depends on the function calling the GetData() function. Usually the current drawing process is aborted once the GetData() function does not return the requested number of bytes.

Please find a detailed description of the GetData() function in the section 9.5 "Displaying bitmap files" -> "Gettind data with the ...Ex() functions" in the emWin user manual.

Best regards,
Adrian

This post has been edited 1 times, last edit by "SEGGER - Adrian" (May 20th 2015, 9:52am)