Levetop / LT768x Coding - Libraries & Examples (5)

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:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值