cancel
Showing results for 
Search instead for 
Did you mean: 

Decoding bmp ?

antonius
Senior
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
90 REPLIES 90
Posted on April 19, 2014 at 05:19

do you have example for it ? thanks

Like all of these I'd have to write one, do you have a sample 24-bit 320x240 image as a reference?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
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
Up vote any posts that you find helpful, it shows what's working..
antonius
Senior
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

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
Up vote any posts that you find helpful, it shows what's working..
antonius
Senior
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

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
Up vote any posts that you find helpful, it shows what's working..
antonius
Senior
Posted on April 20, 2014 at 04:38

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

antonius
Senior
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

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
Up vote any posts that you find helpful, it shows what's working..
antonius
Senior
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