Gif.h
上传用户:yatsl7111
上传日期:2007-01-08
资源大小:1433k
文件大小:5k
- // Gif.h: interface for the CGif class.
- //
- //////////////////////////////////////////////////////////////////////
- #if !defined(AFX_GIF_H__3F3EB142_198E_11D3_ABDA_0000E81A9AA8__INCLUDED_)
- #define AFX_GIF_H__3F3EB142_198E_11D3_ABDA_0000E81A9AA8__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- //-----------start define
- #define WIDTHBYTES(bits) (((bits) + 31) / 32 * 4)
- typedef unsigned char UCHAR;
- typedef UCHAR * LPUSTR;
- typedef unsigned short USHORT;
- class GIFINFO
- {
- public:
- USHORT FileType;//89a or 87a
- USHORT ColorType;//1,2,4,8,16,32,64,128,256
- USHORT ColorMode;//1,2,3,4,5,6,7,8
- USHORT Width;
- USHORT Height;
- USHORT FrameCount;//共有几幅图 //UINT DataOffset[100];//小於FrameCount有效 ,包括补充区及数据区
- UCHAR InitPixelBits;//压缩数据起始数据Bits位数
- };
- class MYRGB
- {
- public:
- BYTE bRed;
- BYTE bGreen;
- BYTE bBlue;
- };
- class BMPIMAGE
- {
- public:
- BMPIMAGE();
- virtual ~BMPIMAGE();
- short tColor;
- USHORT DelayTime;
- USHORT Left;
- USHORT Top;
- USHORT Width;
- USHORT Height;
- RGBQUAD Palette[256];
- LPUSTR pImageData;
- BOOL SaveMode;//1 = normal; 0 = 交叉
- };
- //------------------------------------------------------
- class GIFHEADER//GIF 文件头
- {
- public:
- UCHAR Signature[6];//图像格式,版本
- USHORT ScreenWidth;//图像宽度
- USHORT ScreenDepth;//图像高度
- UCHAR GlobalFlagByte;//全局标记 a0 -- a7 有含意
- UCHAR BackGroundColor;//背景色
- UCHAR AspectRadio;//89a版的长宽比
- };
- class IMAGEDATAINFO//图像数据区识别信息
- {
- public:
- UCHAR ImageLabel;// default 0x2c
- USHORT ImageLeft;
- USHORT ImageTop;
- USHORT ImageWidth;
- USHORT ImageHeight;
- UCHAR LocalFlagByte;
- };
- class LZWTABLE
- {
- public:
- USHORT Header;
- USHORT Tail;
- USHORT Code;
- };
- //below only for 89a
- class GRAPHCTRL
- {
- public:
- UCHAR ExtIntr;// 0x21
- UCHAR Label;//0xF9
- UCHAR BlockSize;//0x04
- UCHAR PackedField;
- USHORT DelayTime;
- UCHAR TranColorIndex;
- UCHAR blockTerminator;//0x00
- };
- class NOTEHCTRL
- {
- public:
- UCHAR ExtIntr;// 0x21
- UCHAR Label;//0xFE
- UCHAR Data[256];//变长最大256
- UCHAR blockTerminator;//0x00
- };
- class TEXTCTRL
- {
- public:
- UCHAR ExtIntr;// 0x21
- UCHAR Label;//0x01
- UCHAR BlockSize;//0x0c
- USHORT Left;
- USHORT Top;
- USHORT Width;
- USHORT Height;
- UCHAR ForeColorIndex;
- UCHAR BkColorIndex;
- char Data[256];//变长最大256
- UCHAR blockTerminator;//0x00
- };
- class APPCTRL
- {
- public:
- UCHAR ExtIntr;// 0x21
- UCHAR Label;//0xFF
- UCHAR BlockSize;//0x0b
- UCHAR Identifier[8];
- UCHAR Authentication[3];
- UCHAR Data[256];//变长最大256
- UCHAR blockTerminator;//0x00
- };
- //-----------------------------
- class CGIF
- {
- public:
- BOOL GetImageInfo(RECT &Rect,COLORREF &tColor ,UINT ImageNo = 0);
- BOOL ShowImage(HDC hDC,POINT StartPos,UINT ImageNo = 0);
- BOOL LoadGIF(LPCTSTR GifFileName);
- CGIF();
- virtual ~CGIF();
- private:
- BOOL ConvertToBmpImage(LPUSTR SrcData);
- BOOL SaveBmp(LPCTSTR BmpFileName,LPUSTR pData);
- UINT GetImage(LPUSTR pData);
- UINT GetNoteContent(LPUSTR pNote);
- UINT GetAppContent(LPUSTR pApp);
- UINT ShowText(LPUSTR pText);
- UINT GetGrphContent(LPUSTR pGrCtrl);
- UINT AnalizeFileHeader(LPUSTR pFileContent);
- //从字符串中任意字节的某个Bits开始取若干bits,并返回结果
- USHORT GetOneCode(LPUSTR CodeStr ,UINT CodeStrLen, UINT OffsetChar , UINT OffsetBits, UINT Length);
- //当某指针指向文件中压缩数据前位置时,取得当前数据区中压缩数据所占字节数
- UINT GetCodeCountOnChar (LPUSTR CodeStr ,UINT &AllDataLen);
- //当某指针指向文件中压缩数据前位置时,取得当前数据区中压缩数据
- LPUSTR GetCodeDataOnChar (LPUSTR CodeStr);
- //把压缩数据解於USHORT * 中,
- LPUSTR GetCodeDataOnBits (LPUSTR CodeDataStr,UINT InitLen ,UINT &CodeDataLen);
- //得到部份真实数据
- void GetPartImageDataFromTable(LPUSTR &pImage,LZWTABLE * Table,UINT TableLen);
- //API end
-
- GIFINFO m_GifInfo;
- LPUSTR m_pDataArea;
- LZWTABLE LZWTable[5200];
-
- CPtrList m_ImageList;
- RGBQUAD m_CurRgbQuad[256];//Bitmap pal;
- short m_CurTColorIndex;
- USHORT m_CurDelayTime;
- BOOL m_CurSaveMode;
- USHORT m_CurX,m_CurY,m_CurWidth,m_CurHeight;
- };
- BOOL BitBltEx(
- HDC hdcDest, // handle to destination device context
- int nXDest, // x-coordinate of destination rectangle's upper-left
- // corner
- int nYDest, // y-coordinate of destination rectangle's upper-left
- // corner
- int nWidth, // width of destination rectangle
- int nHeight, // height of destination rectangle
- HDC hdcSrc, // handle to source device context
- int nXSrc, // x-coordinate of source rectangle's upper-left
- // corner
- int nYSrc, // y-coordinate of source rectangle's upper-left
- COLORREF cTransparentColor // corner
- // raster operation code
- );
- #endif // !defined(AFX_GIF_H__3F3EB142_198E_11D3_ABDA_0000E81A9AA8__INCLUDED_)