This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf_gfx_bmp565_draw

Hi,

I would display a picture on my lcd screen. I use the driver st7735, with PCA10040 and my IDE is segger embedded. I find the documentation of nrf_gfx_bmp565_draw

ret_code_t nrf_gfx_bmp565_draw ( nrf_lcd_t const *  p_instance,
nrf_gfx_rect_t const *  p_rect,
uint16_t const *  img_buf 
)

I don't find example with it.

I don't understand the last parameter: [in]img_buf Pointer to data from the .bmp file, because I don't know how can I have a pointer to data. 

In my code, I opened a picture with fopen, and I read this file with fread. I thought img_buf  was the result of fread, but no, it doesn't work or it displays anything. Here is my code

char * img_file ="../../../../../../couleurs.bmp";
char buff_img[100];
uint16_t img_size;
FILE * img = fopen(img_file, "r");
img_size = fread(buff_img, sizeof(buff_img), 1, img);
APP_ERROR_CHECK(nrf_gfx_bmp565_draw(p_lcd, &rect_img, img_size));

So i would like to have more information about nrf_gfx_bmp565_draw to understand how to use it.

Thanks!

Parents
  • Hi  

    I don't understand the last parameter: [in]img_buf Pointer to data from the .bmp file, because I don't know how can I have a pointer to data. 

    Do you mean you don't know how pointers work on a conceptual level, or that you don't know how to transfer the image data into a buffer?

    In my code, I opened a picture with fopen, and I read this file with fread. I thought img_buf  was the result of fread, but no, it doesn't work or it displays anything. Here is my code

    You mean buff_img and not img_buf I assume?

    What I don't understand is where you have stored the couleurs.bmp file?

    In order to access a file directly from your code you have to embed the file into the code flash, unless you have some external memory device connected to the nRF52 that you can use for file storage. 

    The easiest way to store an image in the internal flash is to find some tool to convert the bmp file into a const C array, that you can then declare in your code to store the image. Then you simply refer to this array whenever you want to display the image. 

    There are various tools available online to convert a bmp file into a C array, but not all of them support the 16-bit 565 format. 
    You could give this one a try: https://www.displaymodule.com/pages/copy-of-displaymodules-image-converter-free-download

    Please be aware that you might have to do some small changes to the generated file to integrate it into your code, in case the array uses a type not supported by the Segger compiler etc. 

    Best regards
    Torbjørn

  • Hi,

    I didn't know how to transfer the image data into a buffer. I try DisplayModule but I can't use it because it converts image into two hexadecimal number. When I try to convert an image which is green, it converts 0x07E0 into  0x7, 0xE0 so the display is wrong because the third parameter is expected to be stored in 2-byte samples. I can't find a converter that works.

    Thanks for your answer.

    Lydie

  • Hi Lydie

    Did you find a solution to this?

    I have been on vacation for the last two weeks, which is why I was unable to get back to you. 

    How the image data is defined in the source code is not critical, as long as the data in memory is correct. You can cast the buffer to a uint16_t buffer before sending it to the display to have the system treat the samples as 2-byte rather than 1-byte.

    Best regards
    Torbjørn

Reply
  • Hi Lydie

    Did you find a solution to this?

    I have been on vacation for the last two weeks, which is why I was unable to get back to you. 

    How the image data is defined in the source code is not critical, as long as the data in memory is correct. You can cast the buffer to a uint16_t buffer before sending it to the display to have the system treat the samples as 2-byte rather than 1-byte.

    Best regards
    Torbjørn

Children
Related