libpng.txt - A description on how to use and modify libpng
libpng version 1.0.9 - January 31, 2001
Updated and distributed by Glenn Randers-Pehrson
<randeg@alum.rpi.edu>
Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
For conditions of distribution and use, see copyright
notice in png.h.
based on:
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.
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-1.2 specification is available at <http://www.libpng.org/pub/png>
and at <ftp://ftp.uu.net/graphics/png/documents/>.
The PNG-1.0 specification is available
as RFC 2083 <ftp://ftp.uu.net/graphics/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 <ftp://ftp.uu.net/graphics/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/>
and at <ftp://ftp.uu.net/graphics/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 if the bytes match the corresponding
bytes of the PNG signature, or nonzero 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, optional
pointers to error handling functions, and a pointer to a data struct for
use by the error functions, if necessary (the pointer and functions can
be NULL if the default error handlers are to be used). See the section
on Changes to Libpng below regarding the old initialization functions.
The structure allocation functions quietly return NULL if they fail to
create the structure, so your application should check for that.
png_structp png_ptr = png_create_read_struct
(PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
user_error_fn, user_warning_fn);
if (!png_ptr)
return (ERROR);
png_infop info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr)
{
png_destroy_read_struct(&png_ptr,
(png_infopp)NULL, (png_infopp)NULL);
return (ERROR);
}
png_infop end_info = png_create_info
没有合适的资源?快使用搜索试试~ 我知道了~
qt-x11-2.3.2.tar.gz
5星 · 超过95%的资源 需积分: 10 726 下载量 201 浏览量
2009-03-19
19:23:28
上传
评论 3
收藏 8.56MB GZ 举报
温馨提示
共4299个文件
html:1172个
h:748个
3qt:666个
嵌入式QT平台搭建的必要文件之一,是LINUX平台优秀的人机界面编写工具,搭建这个平台需要六个文件,我会全部上传。
资源推荐
资源详情
资源评论
收起资源包目录
qt-x11-2.3.2.tar.gz (4299个子文件)
changes-2.3.0 5KB
moc.1 13KB
changes-2.3.1 5KB
uic.1 2KB
changes-2.3.2 9KB
libpng.3 147KB
libpngpf.3 17KB
zlib.3 3KB
qwidget.3qt 126KB
qapplication.3qt 66KB
qpainter.3qt 64KB
qstring.3qt 52KB
qlistbox.3qt 43KB
qlistview.3qt 40KB
qscrollview.3qt 39KB
qiconview.3qt 39KB
qobject.3qt 39KB
qmultilineedit.3qt 36KB
qtable.3qt 35KB
qcstring.3qt 34KB
qpixmap.3qt 33KB
qstyle.3qt 33KB
qimage.3qt 32KB
qdir.3qt 31KB
qtableview.3qt 29KB
qfont.3qt 29KB
qmenudata.3qt 29KB
qfiledialog.3qt 28KB
qvariant.3qt 27KB
qlistviewitem.3qt 27KB
qmessagebox.3qt 26KB
qcombobox.3qt 24KB
qtabdialog.3qt 23KB
qlist.3qt 23KB
qnetworkprotocol.3qt 22KB
qurloperator.3qt 22KB
qt.3qt 22KB
qdomnode.3qt 22KB
qlineedit.3qt 21KB
qtextstream.3qt 21KB
qmainwindow.3qt 20KB
qpopupmenu.3qt 20KB
qprinter.3qt 20KB
qiconviewitem.3qt 20KB
qcolor.3qt 19KB
qcanvas.3qt 19KB
qheader.3qt 19KB
qbutton.3qt 19KB
qspinbox.3qt 19KB
qrect.3qt 18KB
qglwidget.3qt 17KB
qiodevice.3qt 17KB
qvaluelist.3qt 17KB
qchar.3qt 17KB
qdatastream.3qt 17KB
qsocketdevice.3qt 17KB
qframe.3qt 16KB
qlabel.3qt 16KB
qtextcodec.3qt 16KB
qslider.3qt 16KB
qfile.3qt 15KB
qfontmetrics.3qt 15KB
qgridlayout.3qt 15KB
qpushbutton.3qt 15KB
qsocket.3qt 15KB
qstylesheetitem.3qt 15KB
qglformat.3qt 15KB
qboxlayout.3qt 15KB
qfileinfo.3qt 15KB
qarray.3qt 14KB
qprogressdialog.3qt 14KB
qtabwidget.3qt 14KB
qscrollbar.3qt 14KB
qlayout.3qt 14KB
qtoolbutton.3qt 14KB
qtextview.3qt 13KB
qbytearray.3qt 13KB
qmovie.3qt 13KB
qmenubar.3qt 13KB
qstylesheet.3qt 13KB
qtranslator.3qt 13KB
qcanvasitem.3qt 12KB
qsgistyle.3qt 12KB
qmap.3qt 12KB
qdial.3qt 12KB
qrangecontrol.3qt 12KB
qregion.3qt 12KB
qurl.3qt 12KB
qtabbar.3qt 12KB
qaccel.3qt 12KB
qasciidict.3qt 12KB
qtooltip.3qt 11KB
qlcdnumber.3qt 11KB
qwmatrix.3qt 11KB
qcolorgroup.3qt 11KB
qaction.3qt 11KB
qxmlcontenthandler.3qt 11KB
qdict.3qt 11KB
qtime.3qt 11KB
qsessionmanager.3qt 11KB
共 4299 条
- 1
- 2
- 3
- 4
- 5
- 6
- 43
黑鸟与幽灵
- 粉丝: 32
- 资源: 20
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于matlab实现的RSSI-Localization-WiFi-master 接收信号强度WIFI定位
- SP804定时器参考手册
- 基于matlab实现的牛顿法求解非线性方程组 源程序代码.rar
- 基于matlab实现的多目标无功优化算法,采用遗传算法,非支配排序,前推回代潮流计算.rar
- LQ9G20MW项目智能化网通计划5.4.mpp
- 5G网优案例:SA网络ToB业务接入异常处理案例.docx
- C语言期末/课程设计:通讯录管理系统(Dev-C++)
- QT Widgets 实现的文本编辑器
- 5G网优案例:开启 BWP2 节能开关后导致 VONR MOS 低案例.docx
- hal-spi-slave
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页