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 18, 2014 at 06:17

I would expect the palette table to be at +0x36, and the raster data at the offset described at +0x0A

What display module is this? What is the colour format?
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 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
Senior
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...0690X00000602QAQAY.bmp

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

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

is it the one you look after ?

0690X00000602tlQAA.jpg

antonius
Senior
Posted on April 18, 2014 at 12:17

I tried

0690X00000602QKQAY.bmp

and on LCD :

0690X00000602uFQAQ.jpg

What should I change on pal ?

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