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

📄 gifconvert.cpp.svn-base

📁 gif to bmp conversion
💻 SVN-BASE
字号:
#include "stdafx.h"
#include "ddl.h"
#include "jcal.h"
#include "giftobmp.h"
#include "gif.h"

#define BUF_SIZE (2 * 1024)

static JC_RETCODE Test_GifDecoder();

JC_INT32 _tmain(JC_INT32 argc, _TCHAR* argv[])
{
    JC_RETCODE		rCode = JC_OK ;

	rCode = Test_GifDecoder();	

	return rCode;
}

JC_RETCODE Test_GifDecoder()
{
	JC_HANDLE       vGif;
	JC_HANDLE       vBufBmp;
	JC_UINT8*       pucBuf;
	JC_UINT8*       pucBuftype;
	JC_INT32	    iRead;
	JDD_FILE		vFilePointer ;
	JDD_FILE		vFilePointerc ;
	JC_INT32		iFrameCount;
	JC_INT32		iI;
	JC_CHAR *       String;
	JC_INT32		i = 0;
    JC_CHAR*       Signature;
    JC_RETCODE     rCode; 
	E_IMGFORMAT	   eFormat = E_UNKNOWN ;
   	ST_GIF_INFO    stGifInfo ;

	const TCHAR* pszFilename = TEXT("prob1.gif"); /*source file name */
    const TCHAR*  psFileBufCheck = TEXT("buftofile.bmp");/* to check the buffer thif file is filled with buffer data */
	const JC_CHAR amSzOut[][MAX_PATH]	= 
	{
		TEXT("out1.bmp"),
		TEXT("out2.bmp"),
		TEXT("out3.bmp"),
		TEXT("out4.bmp"),
		TEXT("out5.bmp"),
		TEXT("out6.bmp"),
		TEXT("out7.bmp"),
		TEXT("out8.bmp"),
		TEXT("out9.bmp"),
		TEXT("out10.bmp"),
		TEXT("out11.bmp"),
		TEXT("out12.bmp"),
		TEXT("out13.bmp"),
		TEXT("out14.bmp"),
		TEXT("out15.bmp"),
		TEXT("out16.bmp"),
		TEXT("out17.bmp"),
		TEXT("out18.bmp"),
		TEXT("out19.bmp"),
		TEXT("out20.bmp")
	};
    
	/* to get the format of the source image */
     vFilePointer = jdd_FSOpen(NULL, pszFilename, E_OPEN_READ_MODE) ;
     pucBuftype = (JC_UINT8*) jdd_MemAlloc(sizeof(JC_UINT8), 10) ;
	 jdd_FSRead(pucBuftype, 1, 10, vFilePointer) ;
	 jdd_FSSeek(vFilePointer, 0, E_FILE_SEEK_SET);
     rCode =  jdi_GifToBmpGetImageFormat(&eFormat,pucBuftype) ;

     if(eFormat == E_GIF)
	 {
		/*jdi_GifToBmpInit() function initialises the ST_GIF_DATA structure
		 * and returns the pointer to this structure in vGif 
		 * second parameter is the limit of the buffer to hold the bmp image 
		 */
   		jdi_GifToBmpInit(&vGif, 1024 * 4);
		/*this buffer pucBuf reads the chunk from the source file  */
		pucBuf = (JC_UINT8*) jdd_MemAlloc(sizeof(JC_UINT8), BUF_SIZE);

		while (!feof((FILE*)vFilePointer))
		{
			  iRead = (JC_INT32)jdd_FSRead(pucBuf, 1, BUF_SIZE, vFilePointer);

		/* jdi_GifToBmpSetContent sets the content from source file to the 
		 *  filein the structure  ST_GIF_DATA name 
		 */
			  jdi_GifToBmpSetContent(vGif, pucBuf, iRead, (iRead == BUF_SIZE)?E_FALSE: E_TRUE);
		} 

		jdd_MemFree(pucBuf);
		 
		/* jdi_GifToBmpGetFrameCount function counts the no 
		 * of frames in the gif image(source)passing the pointer of ST_GIF_DATA structure
		 */
		jdi_GifToBmpGetFrameCount(vGif, &iFrameCount);

		/* jdi_GetInfo() gives the attributes of the gif image(source)
		 * depending upon the value of pGifInfo->bFileOutput will take the bmp 
		 * file in a buffer or a file 
		*/
	    jdi_GetInfo(vGif,&stGifInfo);

	   /* if (stGifInfo.bFileOutput)
	    {
			 vFilePointerc = jdd_FSOpen(NULL, psFileBufCheck,  E_CREATE_WRITE_READ_MODE);
			 jdi_GifToBmpGetBmpBuffer( vGif,(JC_UINT8**)&vBufBmp, 0);
   			 jdd_FSWrite(vBufBmp, 1024 * 120, 1, vFilePointerc);
			 jdd_FSClose(vFilePointerc);


	    }
	    else 
	    {
		  for (iI = 0; iI < iFrameCount; iI++)
		  {
			 jdi_GifToBmpGetBmpFile(vGif, (JC_CHAR**)amSzOut[iI], iI);
		  }
		} */

	 }
   	 else 
	 {
		 return JC_ERR_IMG_FORMAT;
	 }
	
		  
	   /* set the attributes of JC_RECT structure to get the part of any frame */

	  	JC_RECT   stRect;
		stRect.iLeft   =   25 ;
		stRect.iTop    =   25 ;
		stRect.uiWidth =   stRect.uiHeight = 70 ;

		for(iI = 0; iI < iFrameCount; iI++)
			jdi_GifToBmpGetPartialFrameBmpFile(vGif, (JC_CHAR**)&amSzOut[iI], iI, &stRect);
	 
	
    	 
	jdi_GifToBmpDeInit(vGif);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -