It is very easy and effective to display gif animations by LT768x. This section explains how users may manipulate gif animations by a simple DMA command provided by Levetop.
Follow below steps to display a gif animation onto your LCD panel:
Step 1: Prepare the gif material, and break down the gif animation into individual pictures.
Users may utilize a convertion tool, TGif.exe, to break down the gif animation into individual pictures and convert these pictures to bin files.
Activate TGif.exe, and click on [Input Picture] to import the target gif animation. Next, click on [Single Convert] to conver the gif to a bin file.
The gif example we are using here is broken down into 44 frames with a resolution of 512x300.
(For more information about the convertion tool, please contact: Levetop Semiconductor)
Step 2: Program the bin file to the SPI flash that is connected with LT768x
Step 3: Coding
Use a DMA command to retrieve each picture from flash, and store it to LT768x SDRAM (display layer).
Codes are listed below for reference:
/*---------------------------------------------------------------------------------------*/
/* Function: Gif_Demo */
/* */
/* Parameters: None */
/* Returns: None */
/* Description: Display gif animation */
/*---------------------------------------------------------------------------------------*/
void Gif_Demo(void)
{
int i; // counter for loop operation
unsigned short gif_W = 512; // Gif width
unsigned short gif_H = 300; // Gif height
Select_Main_Window_16bpp(); // Set main window color depth
Main_Image_Start_Address(LAYER_0); // Set main window starting address - Display layer
Main_Image_Width(LCD_XSIZE_TFT); // Set main window width
Main_Window_Start_XY(0,0); // Set main window starting coordinate
Canvas_Image_Start_address(LAYER_0); // Set canvas starting address
Canvas_image_width(LCD_XSIZE_TFT); // Set canvas width
Active_Window_XY(0,0); // Set active window starting coordinate
Active_Window_WH(LCD_XSIZE_TFT,LCD_YSIZE_TFT); // Set active window width and height
// Clear display layer (SDRAM)
LT768_DrawSquare_Fill(0, 0, LCD_XSIZE_TFT, LCD_YSIZE_TFT, Black);
while(1)
{
// The example gif is broken down into 44 frames, each of them is 512*300*2 bytes
for(i = 0; i < 44; i++)
{
// Retrieve each of the picture data from Flash, and store the picture data to display layer
LT768_DMA_24bit_Block(1, 0, 256, 150, gif_W, gif_H, gif_W, gif_W*gif_H*2*i);
}
}
}
Running result is as shown below: