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

📄 png.c

📁 htp是一个HTML预处理器。页面可以用htp扩展的类HTML的宏编写。这可以简化维护一个一致外观的Web页面集.
💻 C
字号:
/*//// png.c//// PNG (Portable Network Graphic format) support functions//// Copyright (c) 2001 Kentarou Fukuchi.  Permission to distribute// granted by the author.  No warranties are made on the fitness of this// source code.//*/#include "htp.h"BOOL PngFormatFound(FILE *file){    BYTE header[8];	BYTE png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};    /* move to BOF */    if(fseek(file, 0, SEEK_SET) != 0)    {        DEBUG_PRINT(("unable to seek to start of PNG file"));        return FALSE;    }    /* read first eight bytes, looking for PNG header */    if(fread(header, 1, 8, file) != 8)    {        DEBUG_PRINT(("could not read PNG image file header"));        return FALSE;    }    /* is this a PNG file? */    if(memcmp(header, png_sig, 8) == 0)    {        return TRUE;    }    /* not a PNG file */    return FALSE;}BOOL PngReadDimensions(FILE *file, WORD *height, WORD *width){	unsigned int length;	unsigned char buf[4];    /* move to the image size position in the file header */    if(fseek(file, 8, SEEK_SET) != 0)    {        DEBUG_PRINT(("unable to seek to start of PNG file"));        return FALSE;    }	for(;;)	{		/* read the length of chunk */		if(fread(&length, 1, 4, file) != 4)		{			return FALSE;		}		/* read the chunk name */		if(fread(&buf, 1, 4, file) != 4)		{			return FALSE;		}		if(memcmp(buf, "IHDR", 4) != 0)		{			if(fseek(file, length, SEEK_CUR) != 0)			{				return FALSE;			}			continue;		} else {			if(fread(&buf, 1, 4, file) != 4)			{				return FALSE;			}			*width = MAKE_WORD(buf[2], buf[3]);			if(fread(&buf, 1, 4, file) != 4)			{				return FALSE;			}			*height = MAKE_WORD(buf[2], buf[3]);			break;		}	}    return TRUE;}

⌨️ 快捷键说明

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