cancel
Showing results for 
Search instead for 
Did you mean: 

Displaying icon on TFT ?

antonius
Senior
Posted on April 14, 2014 at 10:18

Guys,

Does anyone of you know on how to display array of bitmap to TFT LCD ? I tried :


void LCD_DrawBMPFromFile()

{ 

char temp_buffer[100],line[512];

int count,bmpData,bmpAddr;


const int icon[220] =

{

0x42,0x4D,0xC6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x76,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x0A,

0x00,0x00,0x00,0x0A,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x50,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x80,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x80,0x00,0x00,0x00,0x80,0x00,

0x80,0x00,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0xC0,0xC0,0xC0,0x00,0x00,0x00,0xFF,0x00,0x00,

0xFF,0x00,0x00,0x00,0xFF,0xFF,0x00,0xFF,0x00,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0x00,0x00,

0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,

0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x99,0x99,0x99,0x9F,0xFF,0x00,0x00,0x00,0x99,0x99,

0x99,0x9F,0xFF,0x00,0x00,0x00,0x99,0x99,0x99,0x9F,0xFF,0x00,0x00,0x00,0x99,0x99,0x99,0x9F,0xFF,

0x00,0x00,0x00,0x99,0x99,0x99,0x9F,0xFF,0x00,0x00,0x00,0x99,0x99,0x99,0x9F,0xFF,0x00,0x00,0x00,

0x99,0x99,0x99,0x9F,0xFF,0x00,0x00,0x00};



//write LCD RAM here

LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */

LCD_Clear(Yellow);

for (bmpAddr; bmpAddr < 100; bmpAddr += 2)

{

bmpData = (uint16_t)(*(icon + bmpAddr)) + (uint16_t)((*(icon + bmpAddr + 1)) << 8);

LCD_WriteRAM( bmpData );

}



__inline void LCD_WriteRAM(uint16_t RGB_Code) 


{

/* Write 16-bit GRAM Reg */

LCD_RAM = RGB_Code;

}

but got no response, any clues ? thanks
5 REPLIES 5
Posted on April 14, 2014 at 15:19

You need to review the documentation available on BMP files.

This file uses a 4-bit colour depth, ahead of the bitmap data is a 16 entry palette table describing the colours used in the icon, after than is the line data packed two pixels per byte.

You will need to take the palette data, and use that as you decode the pixel data, and translate that into the RGB format (or whatever) data the display is taking. You will need to process the image one line at a time, advancing to the next line on the display for each short line of data you have for the icon. Repeat for at the lines in the icon.
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 15, 2014 at 02:23

any examples ?

I used this function and got stripe on LCD, thanks


void LCD_DrawPicture(uint16_t StartX,uint16_t StartY,uint16_t EndX,uint16_t EndY,uint16_t *pic)

{

uint16_t i;

LCD_SetCursor(StartX,StartY); 

LCD_WriteRAM_Prepare();

for (i=0;i<(EndX*EndY);i++)

{

LCD_WriteRAM(*pic++);

}

}

================


uint16_t icon[220] =

{

0x42,0x4D,0xC6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x76,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x0A,

0x00,0x00,0x00,0x0A,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x50,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x80,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x80,0x00,0x00,0x00,0x80,0x00,

0x80,0x00,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0xC0,0xC0,0xC0,0x00,0x00,0x00,0xFF,0x00,0x00,

0xFF,0x00,0x00,0x00,0xFF,0xFF,0x00,0xFF,0x00,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0x00,0x00,

0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,

0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x99,0x99,0x99,0x9F,0xFF,0x00,0x00,0x00,0x99,0x99,

0x99,0x9F,0xFF,0x00,0x00,0x00,0x99,0x99,0x99,0x9F,0xFF,0x00,0x00,0x00,0x99,0x99,0x99,0x9F,0xFF,

0x00,0x00,0x00,0x99,0x99,0x99,0x9F,0xFF,0x00,0x00,0x00,0x99,0x99,0x99,0x9F,0xFF,0x00,0x00,0x00,

0x99,0x99,0x99,0x9F,0xFF,0x00,0x00,0x00};


LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */

LCD_Clear(Yellow);


LCD_SetCursor(0,319);

LCD_DrawPicture(0,0,320,240,icon);

antonius
Senior
Posted on April 15, 2014 at 06:54

this is the result for the code0690X00000602t2QAA.jpg

john9871j
Associate
Posted on August 03, 2016 at 17:16

i'm having Driver Power State Failure

Posted on August 03, 2016 at 18:29

i'm having Driver Power State Failure

May be you can formulate that into some kind of question with some context, and in a new thread. That would be great..

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..