gif.c

来自「htp是一个HTML预处理器。页面可以用htp扩展的类HTML的宏编写。这可以简」· C语言 代码 · 共 86 行

C
86
字号
/*//// gif.c//// GIF (Graphic Interchange Format) support functions//// Copyright (c) 1995-96 Jim Nelson.  Permission to distribute// granted by the author.  No warranties are made on the fitness of this// source code.//*/#include "htp.h"BOOL GifFormatFound(FILE *file){    BYTE header[8];    /* move to BOF */    if(fseek(file, 0, SEEK_SET) != 0)    {        DEBUG_PRINT(("unable to seek to start of GIF file"));        return FALSE;    }    /* read first six bytes, looking for GIF header + version info */    if(fread(header, 1, 6, file) != 6)    {        DEBUG_PRINT(("could not read GIF image file header"));        return FALSE;    }    /* is this a GIF file? */    if((memcmp(header, "GIF87a", 6) == 0) || (memcmp(header, "GIF89a", 6) == 0))    {        return TRUE;    }    /* not a GIF file */    return FALSE;}BOOL GifReadDimensions(FILE *file, WORD *height, WORD *width){    BYTE hi;    BYTE lo;    /* move to the image size position in the file header */    if(fseek(file, 6, SEEK_SET) != 0)    {        DEBUG_PRINT(("unable to seek to start of GIF file"));        return FALSE;    }    /* read the width, byte by byte */    /* this gets around machine endian problems while retaining the */    /* fact that GIF uses little-endian notation */    if(fread(&lo, 1, 1, file) != 1)    {        return FALSE;    }    if(fread(&hi, 1, 1, file) != 1)    {        return FALSE;    }    *width = MAKE_WORD(hi, lo);    /* read the height, byte by byte */    if(fread(&lo, 1, 1, file) != 1)    {        return FALSE;    }    if(fread(&hi, 1, 1, file) != 1)    {        return FALSE;    }    *height = MAKE_WORD(hi, lo);    return TRUE;}

⌨️ 快捷键说明

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