Skip to main content
antonius
Associate III
April 11, 2014
Question

Decoding bmp ?

  • April 11, 2014
  • 90 replies
  • 37500 views
Posted on April 11, 2014 at 11:21

Guys,

Does anyone of you have experience on decoding bmp ?

I want to display bmp file to my LCD...

Any clues ?

thanks

#i-have-a-clue
    This topic has been closed for replies.

    90 replies

    antonius
    antoniusAuthor
    Associate III
    April 18, 2014
    Posted on April 18, 2014 at 06:31

    offset 18  size = 4 bytes,

    the bitmap width in pixels (signed integer) but in code : it's offset 12, or I'm wrong ?

     xx = *((uint32_t *)&hdr[0x12]); // X pixels (want multiple of 8)

    do you mean the LCD ? it's SSD1289, and it's RGB..

    I can see from the file the value of offset 12 until 15 are 40 01 00 00 which mean 320...that's correct but from wiki it's saying at offset 18, so it's not right....

    antonius
    antoniusAuthor
    Associate III
    April 18, 2014

    Posted on April 18, 2014 at 06:49

     

     

     

     

    my mistake, 0x12 HEX = 18 DEC....

     

    so I will base on :

     

    0690X00000602tbQAA.jpg

     

    I want to test on LCD this picture, it's 256 colors...

     

    Tesla DeLorean
    Guru
    April 18, 2014
    Posted on April 18, 2014 at 06:58

    do you mean the LCD ? it's SSD1289, and it's RGB..

    Ok, but what's the word format? How are the R,G,B colour bits distributed across the word?

    The SSD1289 is a controller chip, what's the part# of the display, cite a manual down load for the board you are using.
    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    antonius
    antoniusAuthor
    Associate III
    April 18, 2014
    Posted on April 18, 2014 at 07:14

    I send data from D0-D16....

    The RGB will be distributed at D0-D16....is that what you're asking ?

    Tesla DeLorean
    Guru
    April 18, 2014
    Posted on April 18, 2014 at 07:52

    I send data from D0-D... The RGB will be distributed at D0-D...is that what you're asking ?

    FFS I'm trying to understand where the colour bits are within the 16-bit word, is this a hard concept to grasp? I ask for the datasheet for your panel so I can figure it out. I'll make an educated guess at the 5:6:5 format

    // For the specific BMP, 8-bit per pixel, 24-bit palette
    // +0x1C = 8 sourcer32@gmail.com
    {
    int i, x, y, xx, yy;
    uint8_t hdr[0x36];
    static uint16_t w[256];
    uint32_t off;
    UINT bytesread;
    res = f_open(&fsrc, ''test.bmp'', FA_READ);
    f_read(&fsrc, hdr, sizeof(hdr), &bytesread); // Read header
    off = *((uint32_t *)&hdr[0x0A]); // offset to rasters
    xx = *((uint32_t *)&hdr[0x12]); // X pixels
    yy = *((uint32_t *)&hdr[0x16]); // Y pixels 
    for(i=0; i<
    256
    ; i++) // Build palette conversion (+0x46 count?)
    {
    uint32_t pal;
    f_read(&fsrc, &pal, 4, &bytesread); // Read palette B G R
    // RRRRRRRRGGGGGGGGBBBBBBBB 8:8:8
    // BBBBBGGGGGGRRRRR 5:6:5
    pal = ((pal & 0x00FC00) >> 5) | ((pal & 0xF80000) >> 19) | ((pal & 0x0000F8) << 8);
    w[i] = (uint16_t)pal; 
    }
    f_lseek(&fsrc, off); // Seek to the data
    for(y=0; y<yy; y++)
    {
    for(x=0; x<xx; x++)
    {
    uint8_t b;
    f_read(&fsrc, &b, 1, &bytesread); // Read byte
    LCD_SetPoint(y, x, w[b]); // Colour Map
    } // x
    } // y
    f_close(&fsrc);
    }

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    antonius
    antoniusAuthor
    Associate III
    April 18, 2014
    Posted on April 18, 2014 at 10:50

    I have 2x2 pixel 8 bit bmp,

    where is the first byte of the pixel ?

    offset 0x12 = 2 (width ) offset 0x16 = 2 (height), offset 0x1C = 8 bit ( color of 8 bit ), index color is starting from offset 0x3E = 00 ?

    0690X00000602tgQAA.jpg

    the picture (zoomed 200x) the actual size is 2x2 pixel:

    0690X00000602QFQAY.bmp

    antonius
    antoniusAuthor
    Associate III
    April 18, 2014
    Posted on April 18, 2014 at 10:53

    Ok, please have a look for the datasheet attached...thanks

    ________________

    Attachments :

    SSD1289.pdf : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I1AF&d=%2Fa%2F0X0000000bks%2FuWxfwu0qkcAquqQZOG95p3JmEiE_tLIqkOFouzUIUis&asPdf=false
    antonius
    antoniusAuthor
    Associate III
    April 18, 2014
    Posted on April 18, 2014 at 11:13

    is it the one you look after ?

    0690X00000602tlQAA.jpg

    antonius
    antoniusAuthor
    Associate III
    April 18, 2014

    Posted on April 18, 2014 at 12:17

     

     

     

     

    I tried

     

     

     

    and on LCD :

     

    0690X00000602uFQAQ.jpg

     

     

    What should I change on pal ?

     

     pal = ((pal & 0x00FC00) >> 5) | ((pal & 0xF80000) >> 19) | ((pal & 0x0000F8) << 8);

     

     

    Tesla DeLorean
    Guru
    April 18, 2014
    Posted on April 18, 2014 at 14:06

    Ok, I have the manual for the SSD part, do you have any manual/documentation/schematics for the BOARD you are using?

    Can you see and image of the flowers, but with the wrong colours? I can't make out anything through the flash glare.

    Perhaps you have some #defines for RED, GREEN or BLUE colours passed to the functions you are using? Or a cite to the library/code?
    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..