Support and General Use > Plugins/Viewers

Load image and draw it

(1/1)

d3nn1as:
I want to load a couple of image files, and draw them on the screen.

Found the graphic functions:
http://www.rockbox.org/twiki/bin/view/Main/GraphicsAPI#Functions

But I still don't got a clue how to load a bitmap file?

gratt:
I just spent several hours figuring this out.
Very little documentation and it is spread all over.
here is a code snipit to read and display an image:

    /* buffer to hold bitmap data */
    static fb_data save_buffer[LCD_WIDTH*LCD_HEIGHT*sizeof(fb_data)];    
    struct bitmap bm;
    bool ret;
    /* point struct data pointer to buffer */
    bm.data = (char*)save_buffer;
    /* read the bitmap */
    ret = read_bmp_file( "/splash.bmp", &bm, LCD_WIDTH*LCD_HEIGHT*sizeof(fb_data), FORMAT_NATIVE );
    /* test if the bitmap was read */
    if((ret==false) || (bm.width > LCD_WIDTH ) || ( bm.height > LCD_HEIGHT )){
    /* display an error message */
    }else{          
    lcd_bitmap(save_buffer, 0, 0, LCD_WIDTH,LCD_HEIGHT);
    lcd_update();
    }

This works great in the sansa sim. I have not yet tried it on target.
GRaTT

Navigation

[0] Message Index

Go to full version