?? 2dgl_drawgif.c
字號:
YPos = (GifInfo.ySize > 180) ? 60 : 150 - (GifInfo.ySize / 2);
for (i = 0; i < 2; i++) { /* Show the complete GIF 2 times ... */
for (j = 0; j < GifInfo.NumImages; j++) {
GUI_GIF_DrawEx(pFile, FileSize, XPos, YPos, j); /* Draw sub image */
GUI_GIF_GetImageInfo(pFile, FileSize, &ImageInfo, j); /* Get sub image information */
GUI_Delay(ImageInfo.Delay ? ImageInfo.Delay * 10 : 100); /* Use the Delay member of the ImageInfo structure for waiting a while */
}
GUI_Delay(2000); /* Wait a while */
}
}
/*******************************************************************
*
* _ShowSubImages
*
* Shows all sub images of a GIF file side by side
*/
static void _ShowSubImages(const char * pFile, int FileSize) {
int j, XPos, YPos;
GUI_GIF_INFO GifInfo = {0}; /* Info structure of GIF file */
GUI_GIF_IMAGE_INFO ImageInfo = {0}; /* Info structure of one particular GIF image of the GIF file */
/* Display sample information */
GUI_SetFont(&GUI_Font8x16);
GUI_ClearRect(0, 40, 319, 59);
GUI_DispStringHCenterAt("Show all sub images of a GIF file", 160, 40);
/* Show sub images */
GUI_ClearRect(0, 60, 319, 239); /* Clear the image area */
GUI_GIF_GetInfo(pFile, FileSize, &GifInfo); /* Get GIF info structure */
XPos = 160 - GifInfo.xSize * GifInfo.NumImages / 2;
YPos = (GifInfo.ySize > 180) ? 60 : 150 - (GifInfo.ySize / 2);
for (j = 0; j < GifInfo.NumImages; j++) {
char acNumber[3] = "#";
acNumber[1] = '0' + j;
GUI_DispStringHCenterAt(acNumber, XPos + GifInfo.xSize / 2, 90);
GUI_GIF_DrawEx(pFile, FileSize, XPos, YPos, j); /* Draw sub image */
XPos += GifInfo.xSize;
}
GUI_Delay(4000); /* Wait a while */
}
/*******************************************************************
*
* _ShowComments
*
* Shows all comments of a GIF file
*/
static void _ShowComments(const char * pFile, int FileSize) {
int Size, CommentCnt;
U8 acBuffer[256] = {0};
GUI_RECT Rect = {80, 100, 239, 199};
GUI_GIF_INFO GifInfo = {0}; /* Info structure of GIF file */
GUI_GIF_IMAGE_INFO ImageInfo = {0}; /* Info structure of one particular GIF image of the GIF file */
/* Display sample information */
GUI_SetFont(&GUI_Font8x16);
GUI_ClearRect(0, 40, 319, 59);
GUI_DispStringHCenterAt("Show all comments of a GIF file", 160, 40);
/* Show all comments */
GUI_ClearRect(0, 60, 319, 239); /* Clear the image area */
Size = CommentCnt = 0;
while (!GUI_GIF_GetComment(pFile, FileSize, acBuffer, sizeof(acBuffer), CommentCnt)) {
char acNumber[12] = "Comment #0:";
acNumber[9] = '0' + CommentCnt;
GUI_DispStringHCenterAt(acNumber, 160, 80);
GUI_SetBkColor(GUI_BLACK);
GUI_SetColor(GUI_WHITE);
GUI_ClearRectEx(&Rect);
GUI_DispStringInRectWrap(acBuffer, &Rect, GUI_TA_HCENTER | GUI_TA_VCENTER, GUI_WRAPMODE_WORD);
GUI_SetBkColor(GUI_WHITE);
GUI_SetColor(GUI_BLACK);
GUI_Delay(4000); /* Wait a while */
CommentCnt++;
}
}
/*******************************************************************
*
* Public code
*
********************************************************************
*/
/*******************************************************************
*
* MainTask
*/
void MainTask(void) {
GUI_Init();
GUI_SetBkColor(GUI_WHITE);
GUI_Clear();
GUI_SetColor(GUI_BLACK);
GUI_SetFont(&GUI_Font24_ASCII);
GUI_DispStringHCenterAt("DrawGIF - Sample", 160, 5);
while (1) {
_ShowMovie (_acImage0, sizeof(_acImage0));
_ShowSubImages(_acImage0, sizeof(_acImage0));
_ShowComments (_acImage0, sizeof(_acImage0));
}
}
/*************************** End of file ****************************/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -