⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2dgl_drawgif.c

📁 ucgui V3.98 是目前网络上相对较新的ucgui高版本源码啦。有兴趣的可以下载试试
💻 C
📖 第 1 页 / 共 2 页
字号:
  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 + -