2025-06-27 00:32:57 +08:00
|
|
|
|
#ifndef __GIF_H__
|
|
|
|
|
#define __GIF_H__
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB>ѧϰʹ<CFB0>ã<EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD><CEBA><EFBFBD>;
|
|
|
|
|
//ALIENTEK STM32<33><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-gif<69><66><EFBFBD>벿<EFBFBD><EBB2BF>
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>@ALIENTEK
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̳:www.openedv.com
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:2016/1/7
|
|
|
|
|
//<2F>汾<EFBFBD><E6B1BE>V1.0
|
|
|
|
|
//<2F><>Ȩ<EFBFBD><C8A8><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD>
|
|
|
|
|
//Copyright(C) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿƼ<D3BF><C6BC><EFBFBD><EFBFBD><EFBFBD>˾ 2014-2024
|
2025-06-27 00:32:57 +08:00
|
|
|
|
//All rights reserved
|
|
|
|
|
//********************************************************************************
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>
|
|
|
|
|
//<2F><>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ܽ<EFBFBD><DCBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>gif֡<66><D6A1>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
#define GIF_PICCONT_MAX 400
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
#define PIC_FORMAT_ERR 0x27 //<2F><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>
|
|
|
|
|
#define PIC_SIZE_ERR 0x28 //ͼƬ<CDBC>ߴ<EFBFBD><DFB4><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
#define PIC_WINDOW_ERR 0x29 //<2F><><EFBFBD><EFBFBD><EFBFBD>趨<EFBFBD><E8B6A8><EFBFBD><EFBFBD>
|
|
|
|
|
#define PIC_MEM_ERR 0x11 //<2F>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//////////////////////////////////////////<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>//////////////////////////////////
|
|
|
|
|
#define GIF_USE_MALLOC 1 //<2F><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9>malloc,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>ʹ<EFBFBD><CAB9>malloc
|
2025-06-27 00:32:57 +08:00
|
|
|
|
//////////////////////////////////////////////END/////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define LCD_MAX_LOG_COLORS 256
|
|
|
|
|
#define MAX_NUM_LWZ_BITS 12
|
|
|
|
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
#define GIF_INTRO_TERMINATOR ';' //0X3B GIF<49>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
#define GIF_INTRO_EXTENSION '!' //0X21
|
|
|
|
|
#define GIF_INTRO_IMAGE ',' //0X2C
|
|
|
|
|
|
|
|
|
|
#define GIF_COMMENT 0xFE
|
|
|
|
|
#define GIF_APPLICATION 0xFF
|
|
|
|
|
#define GIF_PLAINTEXT 0x01
|
|
|
|
|
#define GIF_GRAPHICCTL 0xF9
|
|
|
|
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD>gifͼƬ<CDBC><C6AC><EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD><E1B9B9>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
int frameNumber;
|
|
|
|
|
int x_size;
|
|
|
|
|
int y_size;
|
2025-07-05 19:47:28 +08:00
|
|
|
|
int delay[GIF_PICCONT_MAX];//<2F><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>λms
|
2025-06-27 00:32:57 +08:00
|
|
|
|
u16 *frame[GIF_PICCONT_MAX];
|
|
|
|
|
}GIF_DecodeStruct;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F>ͷ<EFBFBD>GIF_DecodeStruct <20>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
void GIF_DecodeStructFree (GIF_DecodeStruct *gif);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
u8 aBuffer[258]; // Input buffer for data block
|
|
|
|
|
short aCode [(1 << MAX_NUM_LWZ_BITS)]; // This array stores the LZW codes for the compressed strings
|
|
|
|
|
u8 aPrefix[(1 << MAX_NUM_LWZ_BITS)]; // Prefix character of the LZW code.
|
|
|
|
|
u8 aDecompBuffer[3000]; // Decompression buffer. The higher the compression, the more bytes are needed in the buffer.
|
|
|
|
|
u8 * sp; // Pointer into the decompression buffer
|
|
|
|
|
int CurBit;
|
|
|
|
|
int LastBit;
|
|
|
|
|
int GetDone;
|
|
|
|
|
int LastByte;
|
|
|
|
|
int ReturnClear;
|
|
|
|
|
int CodeSize;
|
|
|
|
|
int SetCodeSize;
|
|
|
|
|
int MaxCode;
|
|
|
|
|
int MaxCodeSize;
|
|
|
|
|
int ClearCode;
|
|
|
|
|
int EndCode;
|
|
|
|
|
int FirstCode;
|
|
|
|
|
int OldCode;
|
|
|
|
|
}LZW_INFO;
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><EFBFBD><DFBC><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2025-06-28 18:16:25 +08:00
|
|
|
|
typedef struct __packed
|
2025-06-27 00:32:57 +08:00
|
|
|
|
{
|
2025-07-05 19:47:28 +08:00
|
|
|
|
u16 width; //GIF<49><46><EFBFBD><EFBFBD>
|
|
|
|
|
u16 height; //GIF<49>߶<EFBFBD>
|
|
|
|
|
u8 flag; //<2F><>ʶ<EFBFBD><CAB6> 1:3:1:3=ȫ<><C8AB><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>־(1):<3A><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>(3):<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־(1):ȫ<><C8AB><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>С(3)
|
|
|
|
|
u8 bkcindex; //<2F><><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB>ʱ<EFBFBD><CAB1>Ч)
|
|
|
|
|
u8 pixratio; //<2F><><EFBFBD>ؿ<EFBFBD><D8BF>߱<EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}LogicalScreenDescriptor;
|
|
|
|
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2025-06-28 18:16:25 +08:00
|
|
|
|
typedef struct __packed
|
2025-06-27 00:32:57 +08:00
|
|
|
|
{
|
2025-07-05 19:47:28 +08:00
|
|
|
|
u16 xoff; //x<><78><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB>
|
|
|
|
|
u16 yoff; //y<><79><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB>
|
|
|
|
|
u16 width; //<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
u16 height; //<2F>߶<EFBFBD>
|
|
|
|
|
u8 flag; //<2F><>ʶ<EFBFBD><CAB6> 1:1:1:2:3=<3D>ֲ<EFBFBD><D6B2><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>־(1):<3A><>֯<EFBFBD><D6AF>־(1):<3A><><EFBFBD><EFBFBD>(2):<3A>ֲ<EFBFBD><D6B2><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>С(3)
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}ImageScreenDescriptor;
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2025-06-28 18:16:25 +08:00
|
|
|
|
typedef struct __packed
|
2025-06-27 00:32:57 +08:00
|
|
|
|
{
|
2025-07-05 19:47:28 +08:00
|
|
|
|
LogicalScreenDescriptor gifLSD; //<2F><EFBFBD><DFBC><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ImageScreenDescriptor gifISD; //ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
u16 colortbl[256]; //<2F><>ǰʹ<C7B0><CAB9><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB>
|
|
|
|
|
u16 bkpcolortbl[256]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB>.<2E><><EFBFBD><EFBFBD><EFBFBD>ھֲ<DABE><D6B2><EFBFBD>ɫ<EFBFBD><C9AB>ʱʹ<CAB1><CAB9>
|
|
|
|
|
u16 numcolors; //<2F><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>С
|
|
|
|
|
u16 delay; //<2F>ӳ<EFBFBD>ʱ<EFBFBD><CAB1>
|
|
|
|
|
LZW_INFO *lzw; //LZW<5A><57>Ϣ
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}gif89a;
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//extern u8 gifdecoding; //GIF<49><46><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
2025-06-27 00:32:57 +08:00
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
2025-07-05 19:47:28 +08:00
|
|
|
|
u8 gif_check_head(FIL *file); //<2F><><EFBFBD><EFBFBD>GIFͷ
|
|
|
|
|
u16 gif_getrgb565(u8 *ctb); //<2F><>RGB888תΪRGB565
|
|
|
|
|
u8 gif_readcolortbl(FIL *file,gif89a * gif,u16 num); //<2F><>ȡ<EFBFBD><C8A1>ɫ<EFBFBD><C9AB>
|
|
|
|
|
u8 gif_getinfo(FIL *file,gif89a * gif); //<2F>õ<EFBFBD><C3B5><EFBFBD><DFBC><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>,ͼ<><CDBC><EFBFBD>ߴ<EFBFBD><DFB4><EFBFBD>
|
|
|
|
|
void gif_savegctbl(gif89a* gif); //<2F><><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB>
|
|
|
|
|
void gif_recovergctbl(gif89a* gif); //<2F>ָ<EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB>
|
|
|
|
|
void gif_initlzw(gif89a* gif,u8 codesize); //<2F><>ʼ<EFBFBD><CABC>LZW<5A><57><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>
|
|
|
|
|
u16 gif_getdatablock(FIL *gfile,u8 *buf,u16 maxnum); //<2F><>ȡһ<C8A1><D2BB><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>
|
|
|
|
|
u8 gif_readextension(FIL *gfile,gif89a* gif, int *pTransIndex,u8 *pDisposal); //<2F><>ȡ<EFBFBD><C8A1>չ<EFBFBD><D5B9><EFBFBD><EFBFBD>
|
|
|
|
|
int gif_getnextcode(FIL *gfile,gif89a* gif); //<2F><>LZW<5A><57><EFBFBD><EFBFBD><EFBFBD>еõ<D0B5><C3B5><EFBFBD>һ<EFBFBD><D2BB>LZW<5A><57>,ÿ<><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>12λ
|
|
|
|
|
int gif_getnextbyte(FIL *gfile,gif89a* gif); //<2F>õ<EFBFBD>LZW<5A><57><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>
|
|
|
|
|
u8 gif_dispimage(FIL *gfile,gif89a* gif,u16 x0,u16 y0,int Transparency, u8 Disposal); //<2F><>ʾͼƬ
|
|
|
|
|
void gif_clear2bkcolor(u16 x,u16 y,gif89a* gif,ImageScreenDescriptor pimge); //<2F>ָ<EFBFBD><D6B8>ɱ<EFBFBD><C9B1><EFBFBD>ɫ
|
|
|
|
|
u8 gif_drawimage(FIL *gfile,gif89a* gif,u16 x0,u16 y0); //<2F><>GIFͼ<46><CDBC><EFBFBD><EFBFBD>һ֡
|
2025-06-27 00:32:57 +08:00
|
|
|
|
|
|
|
|
|
int GIF_Decode(GIF_DecodeStruct *gif,const u8 *filename);
|
2025-07-05 19:47:28 +08:00
|
|
|
|
void gif_quit(void); //<2F>˳<EFBFBD><CBB3><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>.
|
2025-06-27 00:32:57 +08:00
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
#endif
|