Application Note
AN_303 FT800 Image File Conversion
Version 1.1
Document Reference No.: FT_001070 Clearance No.: FTDI# 390
17
Product Page
Document Feedback Copyright © 2015 Future Technology Devices International Limited
5.4 Example Code to display ‘DXT1’ image
To check the result on the display screen, the converted raw files need to be loaded into the FT8xx
graphics RAM. This example code is based on the FTDI HAL library and shows the basic steps
needed to use the output of the png2dxt1 converter.
ft_void_t SAMAPP_GPU_DXT1()
//c0 is paris_480x272_c0.raw
//c1 is paris_480x272_c1.raw
//b0 is paris_480x272_b0.raw
//b1 is paris_480x272_b1.raw
{
//load each .raw file into graphics RAM from directory ‘test’
//RAM_G is starting address in graphics RAM, for example 00 0000h
Ft_App_LoadRawFromFile("..\\..\\..\\Test\\c0.raw", RAM_G);
Ft_App_LoadRawFromFile("..\\..\\..\\Test\\c1.raw", RAM_G + 16320);
Ft_App_LoadRawFromFile("..\\..\\..\\Test\\b0.raw", RAM_G + 16320 * 2);
Ft_App_LoadRawFromFile("..\\..\\..\\Test\\b1.raw", RAM_G + 16320 * 3);
Ft_App_WrCoCmd_Buffer(phost, CLEAR(1, 1, 1)); // clear screen
Ft_App_WrCoCmd_Buffer(phost,COLOR_RGB(255,255,255));
Ft_App_WrCoCmd_Buffer(phost,SAVE_CONTEXT());
//B0&B1 Handle
Ft_App_WrCoCmd_Buffer(phost,BITMAP_HANDLE(0));
Ft_App_WrCoCmd_Buffer(phost,BITMAP_SOURCE(RAM_G + 16320*2));
Ft_App_WrCoCmd_Buffer(phost,BITMAP_LAYOUT(L1, 60, 272));
Ft_App_WrCoCmd_Buffer(phost,BITMAP_SIZE(NEAREST, BORDER, BORDER, 480, 272));
//C0&C1 handle
Ft_App_WrCoCmd_Buffer(phost,BITMAP_HANDLE(2));
Ft_App_WrCoCmd_Buffer(phost,BITMAP_SOURCE(RAM_G));
Ft_App_WrCoCmd_Buffer(phost,BITMAP_LAYOUT(RGB565, 120*2, 68));
Ft_App_WrCoCmd_Buffer(phost,BITMAP_SIZE(NEAREST, BORDER, BORDER, 480, 272));
// start drawing bitmaps
Ft_App_WrCoCmd_Buffer(phost,BEGIN(BITMAPS));
Ft_App_WrCoCmd_Buffer(phost,BLEND_FUNC(ONE,ZERO));
Ft_App_WrCoCmd_Buffer(phost,COLOR_A(0x55));
Ft_App_WrCoCmd_Buffer(phost,VERTEX2II(0, 0, 0, 0));
Ft_App_WrCoCmd_Buffer(phost,BLEND_FUNC(ONE,ONE));
Ft_App_WrCoCmd_Buffer(phost,COLOR_A(0xAA));
Ft_App_WrCoCmd_Buffer(phost,VERTEX2II(0, 0, 0, 1));
Ft_App_WrCoCmd_Buffer(phost,COLOR_MASK(1,1,1,0));
Ft_Gpu_CoCmd_Scale(phost, 4*65536,4*65536);
Ft_Gpu_CoCmd_SetMatrix(phost);
Ft_App_WrCoCmd_Buffer(phost,BLEND_FUNC(DST_ALPHA,ZERO));
Ft_App_WrCoCmd_Buffer(phost,VERTEX2II(0, 0, 2, 1));
Ft_App_WrCoCmd_Buffer(phost,BLEND_FUNC(ONE_MINUS_DST_ALPHA,ONE));
Ft_App_WrCoCmd_Buffer(phost,VERTEX2II(0, 0, 2, 0));
Ft_App_WrCoCmd_Buffer(phost, RESTORE_CONTEXT());