📄 libmng_chunk_descr.c
字号:
/* ************************************************************************** *//* * For conditions of distribution and use, * *//* * see copyright notice in libmng.h * *//* ************************************************************************** *//* * * *//* * project : libmng * *//* * file : libmng_chunk_descr.c copyright (c) 2004 G.Juyn * *//* * version : 1.0.9 * *//* * * *//* * purpose : Chunk descriptor functions (implementation) * *//* * * *//* * author : G.Juyn * *//* * * *//* * comment : implementation of the chunk- anf field-descriptor * *//* * routines * *//* * * *//* * changes : 1.0.9 - 12/06/2004 - G.Juyn * *//* * - added conditional MNG_OPTIMIZE_CHUNKREADER * *//* * 1.0.9 - 12/11/2004 - G.Juyn * *//* * - made all constants 'static' * *//* * 1.0.9 - 12/20/2004 - G.Juyn * *//* * - cleaned up macro-invocations (thanks to D. Airlie) * *//* * 1.0.9 - 01/17/2005 - G.Juyn * *//* * - fixed problem with global PLTE/tRNS * *//* * * *//* ************************************************************************** */#include <stddef.h> /* needed for offsetof() */#include "libmng.h"#include "libmng_data.h"#include "libmng_error.h"#include "libmng_trace.h"#ifdef __BORLANDC__#pragma hdrstop#endif#include "libmng_memory.h"#include "libmng_objects.h"#include "libmng_chunks.h"#include "libmng_chunk_descr.h"#include "libmng_object_prc.h"#include "libmng_chunk_prc.h"#include "libmng_chunk_io.h"#include "libmng_display.h"#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)#pragma option -A /* force ANSI-C */#endif/* ************************************************************************** */#ifdef MNG_OPTIMIZE_CHUNKREADER#if defined(MNG_INCLUDE_READ_PROCS) || defined(MNG_INCLUDE_WRITE_PROCS)/* ************************************************************************** *//* ************************************************************************** *//* PNG chunks */MNG_LOCAL mng_field_descriptor mng_fields_ihdr [] = { {MNG_NULL, MNG_FIELD_INT | MNG_FIELD_NOHIGHBIT, 1, 0, 4, 4, offsetof(mng_ihdr, iWidth), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_INT | MNG_FIELD_NOHIGHBIT, 1, 0, 4, 4, offsetof(mng_ihdr, iHeight), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_INT, 1, 16, 1, 1, offsetof(mng_ihdr, iBitdepth), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_INT, 0, 6, 1, 1, offsetof(mng_ihdr, iColortype), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_INT, 0, 0, 1, 1, offsetof(mng_ihdr, iCompression), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_INT, 0, 0, 1, 1, offsetof(mng_ihdr, iFilter), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_INT, 0, 1, 1, 1, offsetof(mng_ihdr, iInterlace), MNG_NULL, MNG_NULL} };/* ************************************************************************** */MNG_LOCAL mng_field_descriptor mng_fields_plte [] = { {mng_debunk_plte, MNG_NULL, 0, 0, 0, 0, MNG_NULL, MNG_NULL, MNG_NULL} };/* ************************************************************************** */MNG_LOCAL mng_field_descriptor mng_fields_idat [] = { {MNG_NULL, MNG_NULL, 0, 0, 0, 0, offsetof(mng_idat, pData), MNG_NULL, offsetof(mng_idat, iDatasize)} };/* ************************************************************************** */MNG_LOCAL mng_field_descriptor mng_fields_trns [] = { {mng_debunk_trns, MNG_NULL, 0, 0, 0, 0, MNG_NULL, MNG_NULL, MNG_NULL} };/* ************************************************************************** */#ifndef MNG_SKIPCHUNK_gAMAMNG_LOCAL mng_field_descriptor mng_fields_gama [] = { {MNG_NULL, MNG_FIELD_INT, 0, 0, 4, 4, offsetof(mng_gama, iGamma), MNG_NULL, MNG_NULL} };#endif/* ************************************************************************** */#ifndef MNG_SKIPCHUNK_cHRMMNG_LOCAL mng_field_descriptor mng_fields_chrm [] = { {MNG_NULL, MNG_FIELD_INT, 0, 0, 4, 4, offsetof(mng_chrm, iWhitepointx), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_INT, 0, 0, 4, 4, offsetof(mng_chrm, iWhitepointy), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_INT, 0, 0, 4, 4, offsetof(mng_chrm, iRedx), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_INT, 0, 0, 4, 4, offsetof(mng_chrm, iRedy), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_INT, 0, 0, 4, 4, offsetof(mng_chrm, iGreeny), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_INT, 0, 0, 4, 4, offsetof(mng_chrm, iGreeny), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_INT, 0, 0, 4, 4, offsetof(mng_chrm, iBluex), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_INT, 0, 0, 4, 4, offsetof(mng_chrm, iBluey), MNG_NULL, MNG_NULL} };#endif/* ************************************************************************** */#ifndef MNG_SKIPCHUNK_sRGBMNG_LOCAL mng_field_descriptor mng_fields_srgb [] = { {MNG_NULL, MNG_FIELD_INT, 0, 4, 1, 1, offsetof(mng_srgb, iRenderingintent), MNG_NULL, MNG_NULL} };#endif/* ************************************************************************** */#ifndef MNG_SKIPCHUNK_iCCPMNG_LOCAL mng_field_descriptor mng_fields_iccp [] = { {MNG_NULL, MNG_FIELD_TERMINATOR, 0, 0, 1, 79, offsetof(mng_iccp, zName), MNG_NULL, offsetof(mng_iccp, iNamesize)}, {MNG_NULL, MNG_FIELD_INT, 0, 0, 1, 1, offsetof(mng_iccp, iCompression), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_DEFLATED, 0, 0, 0, 0, offsetof(mng_iccp, pProfile), MNG_NULL, offsetof(mng_iccp, iProfilesize)} };#endif/* ************************************************************************** */#ifndef MNG_SKIPCHUNK_tEXtMNG_LOCAL mng_field_descriptor mng_fields_text [] = { {MNG_NULL, MNG_FIELD_TERMINATOR, 0, 0, 1, 79, offsetof(mng_text, zKeyword), MNG_NULL, offsetof(mng_text, iKeywordsize)}, {MNG_NULL, MNG_NULL, 0, 0, 0, 0, offsetof(mng_text, zText), MNG_NULL, offsetof(mng_text, iTextsize)} };#endif/* ************************************************************************** */#ifndef MNG_SKIPCHUNK_zTXtMNG_LOCAL mng_field_descriptor mng_fields_ztxt [] = { {MNG_NULL, MNG_FIELD_TERMINATOR, 0, 0, 1, 79, offsetof(mng_ztxt, zKeyword), MNG_NULL, offsetof(mng_ztxt, iKeywordsize)}, {MNG_NULL, MNG_FIELD_INT, 0, 0, 1, 1, offsetof(mng_ztxt, iCompression), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_DEFLATED, 0, 0, 0, 0, offsetof(mng_ztxt, zText), MNG_NULL, offsetof(mng_ztxt, iTextsize)} };#endif/* ************************************************************************** */#ifndef MNG_SKIPCHUNK_iTXtMNG_LOCAL mng_field_descriptor mng_fields_itxt [] = { {MNG_NULL, MNG_FIELD_TERMINATOR, 0, 0, 1, 79, offsetof(mng_itxt, zKeyword), MNG_NULL, offsetof(mng_itxt, iKeywordsize)}, {MNG_NULL, MNG_FIELD_INT, 0, 1, 1, 1, offsetof(mng_itxt, iCompressionflag), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_INT, 0, 0, 1, 1, offsetof(mng_itxt, iCompressionmethod), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_TERMINATOR, 0, 0, 0, 0, offsetof(mng_itxt, zLanguage), MNG_NULL, offsetof(mng_itxt, iLanguagesize)}, {MNG_NULL, MNG_FIELD_TERMINATOR, 0, 0, 0, 0, offsetof(mng_itxt, zTranslation), MNG_NULL, offsetof(mng_itxt, iTranslationsize)}, {mng_deflate_itxt, MNG_NULL, 0, 0, 0, 0, MNG_NULL, MNG_NULL, MNG_NULL} };#endif/* ************************************************************************** */#ifndef MNG_SKIPCHUNK_bKGDMNG_LOCAL mng_field_descriptor mng_fields_bkgd [] = { {MNG_NULL, MNG_FIELD_INT | MNG_FIELD_PUTIMGTYPE, 0, 0, 0, 0, offsetof(mng_bkgd, iType), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE3, 0, 0xFF, 1, 1, offsetof(mng_bkgd, iIndex), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE0 | MNG_FIELD_IFIMGTYPE4, 0, 0xFFFF, 2, 2, offsetof(mng_bkgd, iGray), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE2 | MNG_FIELD_IFIMGTYPE6, 0, 0xFFFF, 2, 2, offsetof(mng_bkgd, iRed), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE2 | MNG_FIELD_IFIMGTYPE6, 0, 0xFFFF, 2, 2, offsetof(mng_bkgd, iGreen), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE2 | MNG_FIELD_IFIMGTYPE6, 0, 0xFFFF, 2, 2, offsetof(mng_bkgd, iBlue), MNG_NULL, MNG_NULL} };#endif/* ************************************************************************** */#ifndef MNG_SKIPCHUNK_pHYsMNG_LOCAL mng_field_descriptor mng_fields_phys [] = { {MNG_NULL, MNG_FIELD_INT, 0, 0, 4, 4, offsetof(mng_phys, iSizex), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_INT, 0, 0, 4, 4, offsetof(mng_phys, iSizey), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_INT, 0, 1, 1, 1, offsetof(mng_phys, iUnit), MNG_NULL, MNG_NULL} };#endif/* ************************************************************************** */#ifndef MNG_SKIPCHUNK_sBITMNG_LOCAL mng_field_descriptor mng_fields_sbit [] = { {MNG_NULL, MNG_FIELD_INT | MNG_FIELD_PUTIMGTYPE, 0, 0, 0, 0, offsetof(mng_sbit, iType), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_INT | MNG_FIELD_IFIMGTYPES, 0, 0xFF, 1, 1, offsetof(mng_sbit, aBits[0]), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE2 | MNG_FIELD_IFIMGTYPE3 | MNG_FIELD_IFIMGTYPE4 | MNG_FIELD_IFIMGTYPE6, 0, 0xFF, 1, 1, offsetof(mng_sbit, aBits[1]), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE2 | MNG_FIELD_IFIMGTYPE3 | MNG_FIELD_IFIMGTYPE6, 0, 0xFF, 1, 1, offsetof(mng_sbit, aBits[2]), MNG_NULL, MNG_NULL}, {MNG_NULL, MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE6, 0, 0xFF, 1, 1, offsetof(mng_sbit, aBits[3]), MNG_NULL, MNG_NULL} };#endif/* ************************************************************************** */#ifndef MNG_SKIPCHUNK_sPLTMNG_LOCAL mng_field_descriptor mng_fields_splt [] = { {MNG_NULL, MNG_NULL, 0, 0, 1, 79, offsetof(mng_splt, zName), MNG_NULL, offsetof(mng_splt, iNamesize)}, {MNG_NULL, MNG_FIELD_INT, 8, 16, 1, 1, offsetof(mng_splt, iSampledepth), MNG_NULL, MNG_NULL}, {mng_splt_entries, MNG_NULL, 0, 0, 0, 0, MNG_NULL, MNG_NULL, MNG_NULL} };#endif/* ************************************************************************** */#ifndef MNG_SKIPCHUNK_hISTMNG_LOCAL mng_field_descriptor mng_fields_hist [] = {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -