libpng.txt - A description on how to use and modify libpng
libpng version 1.4.0 - January 3, 2010
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2009 Glenn Randers-Pehrson
This document is released under the libpng license.
For conditions of distribution and use, see the disclaimer
and license in png.h
Based on:
libpng versions 0.97, January 1998, through 1.4.0 - January 3, 2010
Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2009 Glenn Randers-Pehrson
libpng 1.0 beta 6 version 0.96 May 28, 1997
Updated and distributed by Andreas Dilger
Copyright (c) 1996, 1997 Andreas Dilger
libpng 1.0 beta 2 - version 0.88 January 26, 1996
For conditions of distribution and use, see copyright
notice in png.h. Copyright (c) 1995, 1996 Guy Eric
Schalnat, Group 42, Inc.
Updated/rewritten per request in the libpng FAQ
Copyright (c) 1995, 1996 Frank J. T. Wojcik
December 18, 1995 & January 20, 1996
I. Introduction
This file describes how to use and modify the PNG reference library
(known as libpng) for your own use. There are five sections to this
file: introduction, structures, reading, writing, and modification and
configuration notes for various special platforms. In addition to this
file, example.c is a good starting point for using the library, as
it is heavily commented and should include everything most people
will need. We assume that libpng is already installed; see the
INSTALL file for instructions on how to install libpng.
For examples of libpng usage, see the files "example.c", "pngtest.c",
and the files in the "contrib" directory, all of which are included in
the libpng distribution.
Libpng was written as a companion to the PNG specification, as a way
of reducing the amount of time and effort it takes to support the PNG
file format in application programs.
The PNG specification (second edition), November 2003, is available as
a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2003 (E)) at
<http://www.w3.org/TR/2003/REC-PNG-20031110/
The W3C and ISO documents have identical technical content.
The PNG-1.2 specification is available at
<http://www.libpng.org/pub/png/documents/>. It is technically equivalent
to the PNG specification (second edition) but has some additional material.
The PNG-1.0 specification is available
as RFC 2083 <http://www.libpng.org/pub/png/documents/> and as a
W3C Recommendation <http://www.w3.org/TR/REC.png.html>.
Some additional chunks are described in the special-purpose public chunks
documents at <http://www.libpng.org/pub/png/documents/>.
Other information
about PNG, and the latest version of libpng, can be found at the PNG home
page, <http://www.libpng.org/pub/png/>.
Most users will not have to modify the library significantly; advanced
users may want to modify it more. All attempts were made to make it as
complete as possible, while keeping the code easy to understand.
Currently, this library only supports C. Support for other languages
is being considered.
Libpng has been designed to handle multiple sessions at one time,
to be easily modifiable, to be portable to the vast majority of
machines (ANSI, K&R, 16-, 32-, and 64-bit) available, and to be easy
to use. The ultimate goal of libpng is to promote the acceptance of
the PNG file format in whatever way possible. While there is still
work to be done (see the TODO file), libpng should cover the
majority of the needs of its users.
Libpng uses zlib for its compression and decompression of PNG files.
Further information about zlib, and the latest version of zlib, can
be found at the zlib home page, <http://www.info-zip.org/pub/infozip/zlib/>.
The zlib compression utility is a general purpose utility that is
useful for more than PNG files, and can be used without libpng.
See the documentation delivered with zlib for more details.
You can usually find the source files for the zlib utility wherever you
find the libpng source files.
Libpng is thread safe, provided the threads are using different
instances of the structures. Each thread should have its own
png_struct and png_info instances, and thus its own image.
Libpng does not protect itself against two threads using the
same instance of a structure.
II. Structures
There are two main structures that are important to libpng, png_struct
and png_info. The first, png_struct, is an internal structure that
will not, for the most part, be used by a user except as the first
variable passed to every libpng function call.
The png_info structure is designed to provide information about the
PNG file. At one time, the fields of png_info were intended to be
directly accessible to the user. However, this tended to cause problems
with applications using dynamically loaded libraries, and as a result
a set of interface functions for png_info (the png_get_*() and png_set_*()
functions) was developed. The fields of png_info are still available for
older applications, but it is suggested that applications use the new
interfaces if at all possible.
Applications that do make direct access to the members of png_struct (except
for png_ptr->jmpbuf) must be recompiled whenever the library is updated,
and applications that make direct access to the members of png_info must
be recompiled if they were compiled or loaded with libpng version 1.0.6,
in which the members were in a different order. In version 1.0.7, the
members of the png_info structure reverted to the old order, as they were
in versions 0.97c through 1.0.5. Starting with version 2.0.0, both
structures are going to be hidden, and the contents of the structures will
only be accessible through the png_get/png_set functions.
The png.h header file is an invaluable reference for programming with libpng.
And while I'm on the topic, make sure you include the libpng header file:
#include <png.h>
III. Reading
We'll now walk you through the possible functions to call when reading
in a PNG file sequentially, briefly explaining the syntax and purpose
of each one. See example.c and png.h for more detail. While
progressive reading is covered in the next section, you will still
need some of the functions discussed in this section to read a PNG
file.
Setup
You will want to do the I/O initialization(*) before you get into libpng,
so if it doesn't work, you don't have much to undo. Of course, you
will also want to insure that you are, in fact, dealing with a PNG
file. Libpng provides a simple check to see if a file is a PNG file.
To use it, pass in the first 1 to 8 bytes of the file to the function
png_sig_cmp(), and it will return 0 (false) if the bytes match the
corresponding bytes of the PNG signature, or nonzero (true) otherwise.
Of course, the more bytes you pass in, the greater the accuracy of the
prediction.
If you are intending to keep the file pointer open for use in libpng,
you must ensure you don't read more than 8 bytes from the beginning
of the file, and you also have to make a call to png_set_sig_bytes_read()
with the number of bytes you read from the beginning. Libpng will
then only check the bytes (if any) that your program didn't read.
(*): If you are not using the standard I/O functions, you will need
to replace them with custom functions. See the discussion under
Customizing libpng.
FILE *fp = fopen(file_name, "rb");
if (!fp)
{
return (ERROR);
}
fread(header, 1, number, fp);
is_png = !png_sig_cmp(header, 0, number);
if (!is_png)
{
return (NOT_PNG);
}
Next, png_struct and png_info need to be allocated and initialized. In
order to ensure that the size of these structures is correct even with a
dynamically linked libpng, there are functions to initialize and
allocate the structures. We also pass the library version,
没有合适的资源?快使用搜索试试~ 我知道了~
window下png和bmp像素读取
共129个文件
sbr:27个
c:27个
obj:27个
需积分: 35 12 下载量 144 浏览量
2017-01-09
09:34:32
上传
评论
收藏 1.84MB RAR 举报
温馨提示
查找当前目录下的png和bmp图片,将其像素点读取出来压缩进theme.bin中,并将图片的其他信息如宽高压缩前后大小和在theme.bin中的偏移位置保存在bmpaddr.h中,方便在其他代码中读取图片像素信息。
资源推荐
资源详情
资源评论
收起资源包目录
window下png和bmp像素读取 (129个子文件)
libpng.3 175KB
libpngpf.3 19KB
png.5 2KB
announce 20KB
theme.bin 8KB
Alllight.bmp 3KB
All.bmp 3KB
autobmp.bsc 2.91MB
pngrtran.c 141KB
pngrutil.c 98KB
pngwutil.c 85KB
deflate.c 64KB
inflate.c 49KB
pngpread.c 47KB
pngwrite.c 47KB
trees.c 44KB
pngread.c 42KB
pngset.c 35KB
png.c 27KB
pngget.c 24KB
pngtrans.c 21KB
pngwtran.c 17KB
pngmem.c 16KB
autobmp.c 15KB
inftrees.c 14KB
crc32.c 13KB
inffast.c 13KB
pngerror.c 12KB
zutil.c 8KB
pngwio.c 8KB
pngdisp.c 6KB
pngrio.c 5KB
adler32.c 5KB
compress.c 3KB
uncompr.c 2KB
changes 125KB
configure 444B
autobmp.dsp 7KB
autobmp.dsw 520B
autobmp.exe 616KB
png.h 112KB
zlib.h 66KB
pngconf.h 45KB
pngpriv.h 35KB
crc32.h 30KB
deflate.h 12KB
zconf.h 10KB
trees.h 8KB
zutil.h 7KB
inffixed.h 6KB
pngdisp.h 6KB
inflate.h 6KB
stdint.h 5KB
inftrees.h 2KB
bmpaddr.h 2KB
bmp.h 828B
inffast.h 418B
vc60.idb 81KB
autobmp.ilk 404KB
libpng-config.in 2KB
libpng.pc.in 304B
install 5KB
license 4KB
autobmp.ncb 169KB
pngrutil.obj 100KB
pngrtran.obj 90KB
pngwutil.obj 78KB
pngpread.obj 52KB
pngset.obj 44KB
pngwrite.obj 44KB
pngread.obj 41KB
pngget.obj 41KB
png.obj 38KB
trees.obj 35KB
deflate.obj 33KB
inflate.obj 33KB
pngtrans.obj 26KB
autobmp.obj 24KB
pngwtran.obj 22KB
pngmem.obj 18KB
pngerror.obj 18KB
crc32.obj 18KB
pngwio.obj 14KB
pngrio.obj 13KB
pngdisp.obj 13KB
zutil.obj 6KB
inffast.obj 6KB
inftrees.obj 5KB
adler32.obj 4KB
compress.obj 4KB
uncompr.obj 3KB
autobmp.opt 49KB
autobmp.pch 359KB
autobmp.pdb 809KB
vc60.pdb 84KB
autobmp.plg 2KB
Add2.png 5KB
Add1.png 4KB
readme 13KB
pngset.sbr 0B
共 129 条
- 1
- 2
资源评论
mkchiny
- 粉丝: 13
- 资源: 13
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于java的健康医院门诊在线挂号系统设计与实现.docx
- 基于java的红色革命文物征集管理系统设计与实现.docx
- 基于java的可信捐赠系统的设计与开发设计与实现.docx
- 基于java的健身房管理系统设计与实现.docx
- 基于java的健美操评分系统设计与实现.docx
- 基于java的流浪动物救助平台设计与实现.docx
- 基于java的冷链物流系统设计与实现.docx
- 基于java的乐乐农产品销售系统设计与实现.docx
- 基于java的民宿租赁系统设计与实现.docx
- 基于java的律师事务所案件管理系统设计与实现.docx
- 基于java的农产品智慧物流系统设计与实现.docx
- 基于java的企业内管信息化系统设计与实现.docx
- 基于java的企业车辆管理系统设计与实现.docx
- 基于java的农事管理系统设计与实现.docx
- 基于java的企业项目管理系统设计与实现.docx
- 基于java的售楼管理系统设计与实现.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功