2014-04-11 02:21 AM
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-clue2014-04-11 12:39 PM
There is nothing in the BMP file format that's specific to STM32 - so just google it...
2014-04-11 12:58 PM
There are several formats, you'll need to decode the header, figure out the dimensions, figure out the colour depth or palette tables, and then convert the format into one that is suitable for your display.
As I recall some of the raster formats have the image paint from bottom-to-top, where as displays tend to be the other way round.2014-04-11 06:12 PM
could you suggest me the keywords ?
I read already the first 56 bytes is the information of the picture, so I just jump on it.... In my mind now is 320x240, so, the first line of the picture is 1x240, and repeat it until ...to complete the picture.... I'll make a test with simple black and white 320x240, (box shape) to understand the idea, am I right ? Please see the file test_lcd.bmp....I'll use it for a test...or I need simpler to understand the idea ? thanks ________________ Attachments : test_lcd.bmp : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I1Ds&d=%2Fa%2F0X0000000bkt%2Fv8EB0ALhGNn9677rz6MNSQYnLsx40lfaa3070mU2jM0&asPdf=false2014-04-11 06:26 PM
I saw hexa editor, mostly FF on test_lcd.bmp ?
2014-04-12 05:13 AM
The picture data begins are 0x3E (62)
You'd need to decode the bit stream, describing each line, into a pixel format suitable for your display. It's a monochrome image, black/white going by the RGB palette.http://www.ue.eti.pg.gda.pl/fpgalab/zadania.spartan3/zad_vga_struktura_pliku_bmp_en.html
2014-04-16 04:26 PM
Is it possible like this ?
LCD_WriteRAM_Prepare();
/* Prepare to write GRAM */
LCD_Clear(Yellow);
res = f_open( &fsrc ,
''test.bmp''
, FA_READ );
//res = f_open( &fsrc , ''Demo.TXT'' , FA_READ);
printf
(
''res value = ''
);
sprintf
(temp_buffer,
''%.2d''
,res);
printf
(temp_buffer);
printf
(
''
''
);
printf
(
''Content of the file :''
);
NEXT_LINE;
while
(f_gets(line,
sizeof
line, &fsrc))
printf
(line);
while
(y <320)
{
x = 0;
while
(x <240)
{
//LCD_SetPoint (x, y, 0x0F0F);
LCD_DrawPicture(0,0,239,319,line);
delay_ms(1);
x = x +1;
}
y = y +1;
}
f_close(&fsrc);
2014-04-16 05:34 PM
Is it possible like this?
Not so much, I think you need to familiarize yourself with C File IO (and FatFs variants) and manipulating blocks of data.http://rakanalysis.wordpress.com/2012/04/27/566/
2014-04-16 07:34 PM
This is cruder than I'd like,
// a more general solution would read dimensions from header
// and handle errors, etc.
// For the specific BMP, 1-bit per pixel, 320x240
{
int i, x, y;
res = f_open(&fsrc, ''test.bmp'', FA_READ);
f_seek(&fsrc, 0x3E, F_SEEK_SET); // Seek to the data
for(y=0; y<320; y++)
{
for(x=0; x<240; x+=8) // advance 8 pixels (one byte of bits)
{
uint8_t b;
UINT bytesread;
f_read(&fsrc, &b, 1, &bytesread); // Read byte
for(i=0; i<8; i++) // Process bits in byte, MSB first
{
if (b & 0x80) // Pixel On?
LCD_SetPoint(x + i, y, 0x0F0F); // Colour
else
LCD_SetPoint(x + i, y, 0x0000); // Black
b <<= 1;
}
} // x
} // y
f_close(&fsrc);
}
2014-04-16 09:45 PM
I modify a little bit,
f_seek(&fsrc, 0x3E, F_SEEK_SET); // Seek to the data <== I can't find SEEK_SET so I commented out, It can display bmp but smaller and 4 times, do I miss something in the loop ? suppose to be : I got :
LCD_SetCursor(0,0);
res = f_open(&fsrc, ''test1.bmp'', FA_READ);
//f_seek(&fsrc, 0x3E, F_SEEK_SET); // Seek to the data
//f_lseek(&fsrc, 0x0A);
for(y=0; y<320; y++)
{
for(x=0; x<240; x+=2) // advance 8 pixels (one byte of bits)
{
uint8_t b;
UINT bytesread;
f_read(&fsrc, &b, 1, &bytesread); // Read byte
for(i=0; i<8; i++) // Process bits in byte, MSB first
{
if (b & 0x80) // Pixel On?
LCD_SetPoint(x+1, y, 0x0000); // Colour
else
LCD_SetPoint(x+i, y, 0xF0F0); // Black
b <<= 1;
}
} // x
} // y
f_close(&fsrc);
thanks