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
No Data
Reply
  • 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

Children