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

Decoding bmp ?

  • April 11, 2014
  • 90 replies
  • 37501 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

    Tesla DeLorean
    Guru
    April 19, 2014
    Posted on April 19, 2014 at 05:42

    // For the specific BMP, 24-bit per pixel
    // sourcer32@gmail.com
    void bmp24(void)
    {
    int i, x, y, xx, yy;
    uint8_t hdr[0x36];
    uint32_t off;
    UINT bytesread;
    res = f_open(&fsrc, ''testbmp'', 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 
    f_lseek(&fsrc, off); // Seek to the data
    for(y=0; y<
    yy
    ; y++)
    {
    for(
    x
    =
    0
    ; x<xx; x++)
    {
    uint32_t rgb;
    f_read(&fsrc, &rgb, 3, &bytesread); // Read pixel B G R
    // RRRRRRRRGGGGGGGGBBBBBBBB 8:8:8
    // RRRRRGGGGGGBBBBB 5:6:5
    rgb = ((rgb & 0xF80000) >> 8) | ((rgb & 0x00FC00) >> 5) | ((rgb & 0x0000F8) >> 3);
    LCD_SetPoint(y, x, rgb);
    } // 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 19, 2014
    Posted on April 19, 2014 at 10:02

    Thanks for the reference, anyway who is that in the icon ?

    and if I have 1024 x 768 picture, and I want to display on 320x240, can I manipulate it from software or I can not ?

    thank you

    Tesla DeLorean
    Guru
    April 19, 2014
    Posted on April 19, 2014 at 23:11

    anyway who is that in the icon ?

    That would be Randall Duk Kim.

    and if I have 1024 x 768 picture, and I want to display on 320x240, can I manipulate it from software or I can not ?

    Sure you could display a portion of it, and move it around, You could also shrink-to-fit using either simple or complex methods of decimation, or resampling/interpolating.

    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 19, 2014
    Posted on April 20, 2014 at 01:04

    You could also shrink-to-fit using either simple methods of decimation, or resampling/interpolating.

    Do you mean by dividing 1024 x 768 into 320 x 240 ? decimation ? resampling ?

    1024 / x = 320 ?

    I can display part of 1024x768 ? how can I move it ? change the loop ?

    It seemed slower than 320x240 picture, did it mean , it was reading the complete 1024x768 but can't display it ?

    Thanks

    Tesla DeLorean
    Guru
    April 20, 2014
    Posted on April 20, 2014 at 04:09

    I think we seem to be struggling with some pretty basic concepts here.

    Yes, if you process the entire image it's going to be slower, because there's a large portion where you process the data, yet it's not going to be displayed.

    Each raster is of known length, you can constrain how many pixels are processed by shortening the loop, and then indexing the offset into the file to the next raster, or basically skipping those pixels you don't need to process.

    You can ''move'' the image by picking a starting point within the data and just displaying a 320x240 ''window'' of the larger image.

    You could reduce the image by processing every other pixel, and every other line. You could perhaps improve that by looking at the surrounding pixels and average the colour.

    You need too:

    Learn the ''structure'' of the data you want to process, and the representation of graphic data in rastered formats.

    Learn the techniques related to image processing.

    Learn how to program, and apply data processing techniques.
    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 20, 2014
    Posted on April 20, 2014 at 04:38

    Ok, thank you very much for your suggestions, it seems complicated for doing image processing....

    antonius
    antoniusAuthor
    Associate III
    April 20, 2014
    Posted on April 21, 2014 at 01:38

    For the first time I can start from :

    http://www.scratchapixel.com/lessons/3d-advanced-lessons/interpolation/bilinear-interpolation/

    http://en.wikipedia.org/wiki/Image_scaling#Algorithms

    How do you reckon ?

    thanks

    Tesla DeLorean
    Guru
    April 21, 2014
    Posted on April 21, 2014 at 03:10

    How do you reckon?

    An understanding of these, and related topics, would help you significantly.
    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 21, 2014
    Posted on April 21, 2014 at 03:54

    Thank you very much for the inspiration,

    I saw this as well,

    http://en.wikipedia.org/wiki/Bilinear_interpolation#Application_in_image_processing

    antonius
    antoniusAuthor
    Associate III
    April 21, 2014
    Posted on April 21, 2014 at 06:13

    So if I follow :

    http://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/Bilin3.png/220px-Bilin3.png

    from

    http://en.wikipedia.org/wiki/Bilinear_interpolation#Application_in_image_processing

    I will shring the picture by half ? for example 1024 x 768 becoming 512 x 384 ?