资源简介
libpng用于图片处理,zlib用于压缩。两者密切相关,libpng依赖zlib。
对于要用到这两个库的工程,主要需要做三件事:
1. project property->Configuration properties->C/C++/General->Additional Include Directories中把包含png.h等头文件的目录加进来
2. Linker->Input->Additional Dependencies中加zlib.lib;libpng.lib(:\libpng\libpng-1.5.28\projects\visualc71\Win32_DLL_Debug\)。
3. Configuration properties->VC++ Directories->Library Directories中把放着zlib.lib和libpng.lib的目录加进来。
代码片段和文件信息
#if 0 /* in case someone actually tries to compile this */
/* example.c - an example of using libpng
* Last changed in libpng 1.5.19 [August 21 2014]
* Maintained 1998-2014 Glenn Randers-Pehrson
* Maintained 1996 1997 Andreas Dilger
* Written 1995 1996 Guy Eric Schalnat Group 42 Inc.
*/
/* This is an example of how to use libpng to read and write PNG files.
* The file libpng-manual.txt is much more verbose then this. If you have not
* read it do so first. This was designed to be a starting point of an
* implementation. This is not officially part of libpng is hereby placed
* in the public domain and therefore does not require a copyright notice.
* To the extent possible under law the authors have waived all copyright and
* related or neighboring rights to this file.
*
* This file does not currently compile because it is missing certain
* parts like allocating memory to hold an image. You will have to
* supply these parts to get it to compile. For an example of a minimal
* working PNG reader/writer see pngtest.c included in this distribution;
* see also the programs in the contrib directory.
*/
#define _POSIX_SOURCE 1 /* libpng and zlib are POSIX-compliant. You may
* change this if your application uses non-POSIX
* extensions. */
#include “png.h“
/* The png_jmpbuf() macro used in error handling became available in
* libpng version 1.0.6. If you want to be able to run your code with older
* versions of libpng you must define the macro yourself (but only if it
* is not already defined by libpng!).
*/
#ifndef png_jmpbuf
# define png_jmpbuf(png_ptr) ((png_ptr)->png_jmpbuf)
#endif
/* Check to see if a file is a PNG file using png_sig_cmp(). png_sig_cmp()
* returns zero if the image is a PNG and nonzero if it isn‘t a PNG.
*
* The function check_if_png() shown here but not used returns nonzero (true)
* if the file can be opened and is a PNG 0 (false) otherwise.
*
* If this call is successful and you are going to keep the file open
* you should call png_set_sig_bytes(png_ptr PNG_BYTES_TO_CHECK); once
* you have created the png_ptr so that libpng knows your application
* has read that many bytes from the start of the file. Make sure you
* don‘t call png_set_sig_bytes() with more than 8 bytes read or give it
* an incorrect number of bytes read or you will either have read too
* many bytes (your fault) or you are telling libpng to read the wrong
* number of magic bytes (also your fault).
*
* Many applications already read the first 2 or 4 bytes from the start
* of the image to determine the file type so it would be easiest just
* to pass the bytes to png_sig_cmp() or even skip that if you know
* you have a PNG file and call png_set_sig_bytes().
*/
#define PNG_BYTES_TO_CHECK 4
int check_if_png(char *file_name FILE **fp)
{
char buf[PNG_BYTES_TO_CHECK];
/* Open the prospective PNG file. */
if ((*fp = fopen(fi
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-01-04 15:28 libpng-1.5.28\
文件 2474 2016-12-29 08:35 libpng-1.5.28\ANNOUNCE
文件 221470 2016-12-29 08:35 libpng-1.5.28\CHANGES
文件 24394 2016-12-29 08:35 libpng-1.5.28\CMakeLists.txt
文件 17103 2016-12-29 08:35 libpng-1.5.28\INSTALL
文件 4637 2016-12-29 08:35 libpng-1.5.28\LICENSE
文件 9433 2015-03-16 06:13 libpng-1.5.28\Makefile.am
文件 80206 2016-12-29 08:35 libpng-1.5.28\Makefile.in
文件 11172 2016-12-29 08:35 libpng-1.5.28\README
文件 1068 2016-10-30 22:24 libpng-1.5.28\TODO
文件 374800 2016-12-29 08:35 libpng-1.5.28\aclocal.m4
目录 0 2017-01-04 15:25 libpng-1.5.28\arm\
文件 6994 2016-12-29 08:35 libpng-1.5.28\arm\arm_init.c
文件 7638 2016-12-29 08:35 libpng-1.5.28\arm\filter_neon.S
文件 877 2010-09-15 04:22 libpng-1.5.28\autogen.sh
文件 7333 2015-02-22 02:40 libpng-1.5.28\compile
文件 42938 2015-02-22 02:40 libpng-1.5.28\config.guess
文件 3160 2016-12-29 08:35 libpng-1.5.28\config.h.in
文件 35987 2015-02-22 02:40 libpng-1.5.28\config.sub
文件 476053 2016-12-29 08:35 libpng-1.5.28\configure
文件 9090 2016-12-29 08:35 libpng-1.5.28\configure.ac
目录 0 2017-01-04 15:25 libpng-1.5.28\contrib\
文件 210 2011-11-17 02:52 libpng-1.5.28\contrib\README.txt
目录 0 2017-01-04 15:25 libpng-1.5.28\contrib\gregbook\
文件 18097 2016-12-29 08:35 libpng-1.5.28\contrib\gregbook\COPYING
文件 2373 2016-12-29 08:35 libpng-1.5.28\contrib\gregbook\LICENSE
文件 3940 2016-12-29 08:35 libpng-1.5.28\contrib\gregbook\Makefile.mingw32
文件 2990 2016-12-29 08:35 libpng-1.5.28\contrib\gregbook\Makefile.sgi
文件 4093 2016-12-29 08:35 libpng-1.5.28\contrib\gregbook\Makefile.unx
文件 3357 2016-12-29 08:35 libpng-1.5.28\contrib\gregbook\Makefile.w32
文件 7850 2016-12-29 08:35 libpng-1.5.28\contrib\gregbook\README
............此处省略623个文件信息
评论
共有 条评论