Imported from libpng-0.98.tar
This commit is contained in:
parent
2687fcc7b5
commit
c4a2ae6cac
33
CHANGES
33
CHANGES
@ -170,20 +170,33 @@ version 0.96 [May, 1997]
|
||||
version 0.97 [January, 1998]
|
||||
removed PNG_USE_OWN_CRC capability
|
||||
relocated png_set_crc_action from pngrutil.c to pngrtran.c
|
||||
fixed typecasts of "new_key", etc.
|
||||
added RFC 1152 date support
|
||||
fixed typecasts of "new_key", etc. (Andreas Dilger)
|
||||
added RFC 1152 [sic] date support
|
||||
fixed bug in gamma handling of 4-bit grayscale
|
||||
added more typecasts. 65536L becomes (png_uint_32)65536L, etc.
|
||||
added 2-bit grayscale gamma handling (Glenn R-P)
|
||||
added more typecasts. 65536L becomes (png_uint_32)65536L, etc. (Glenn R-P)
|
||||
minor corrections in libpng.txt
|
||||
added simple sRGB support
|
||||
make it simpler to do conditional compiling: PNG_READ_NOT_FULLY_SUPPORTED
|
||||
fixed memory leak in pngwrite.c (free info_ptr->text)
|
||||
added simple sRGB support (Glenn R-P)
|
||||
easier conditional compiling, e.g. define PNG_READ/WRITE_NOT_FULLY_SUPPORTED;
|
||||
all configurable options can be selected from command-line instead
|
||||
of having to edit pngconf.h (Glenn R-P)
|
||||
fixed memory leak in pngwrite.c (free info_ptr->text) (Glenn R-P)
|
||||
added more conditions for png_do_background, to avoid changing
|
||||
black pixels to background when a background is supplied and
|
||||
no pixels are transparent
|
||||
repaired PNG_NO_STDIO behaviour
|
||||
tested NODIV support and made it default behaviour
|
||||
added "-m" option to pngtest
|
||||
[anything else? 2-bit grayscale gamma bug?]
|
||||
tested NODIV support and made it default behaviour (Greg Roelofs)
|
||||
added "-m" option and PNGTEST_DEBUG_MEMORY to pngtest (John Bowler)
|
||||
regularized version numbering scheme and bumped shared-library major
|
||||
version number to 2 to avoid potential problems with libpng 0.89 apps
|
||||
version number to 2 to avoid problems with libpng 0.89 apps (Greg Roelofs)
|
||||
version 0.98 [January, 1998]
|
||||
cleaned up some typos in libpng.txt and in code documentation
|
||||
fixed memory leaks in pCAL chunk processing (Glenn R-P and John Bowler)
|
||||
cosmetic change "display_gamma" to "screen_gamma" in pngrtran.c
|
||||
changed recommendation about file_gamma for PC images to .51 from .45,
|
||||
in example.c and libpng.txt, added comments to distinguish between
|
||||
screen_gamma, viewing_gamma, and display_gamma.
|
||||
changed all references to RFC1152 to read RFC1123 and changed the
|
||||
PNG_TIME_RFC1152_SUPPORTED macro to PNG_TIME_RFC1123_SUPPORTED
|
||||
added png_invert_alpha capability (Glenn R-P -- suggestion by Jon Vincent)
|
||||
changed srgb_intent from png_byte to int to avoid compiler bugs
|
||||
|
34
README
34
README
@ -1,4 +1,4 @@
|
||||
[NOTE: this is still beta version 0.97c; the text below has already
|
||||
[NOTE: this is still beta version 0.97d; the text below has already
|
||||
been updated in anticipation of the imminent 1.0 release.]
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ README for libpng 1.0
|
||||
|
||||
This is the first official release of libpng. Don't let the fact that
|
||||
it's the first release fool you. The libpng library has been in
|
||||
extensive use and testing for about two years. However, it's
|
||||
extensive use and testing for about two and a half years. However, it's
|
||||
finally gotten to the stage where there haven't been significant
|
||||
changes to the API in some time, and people have a bad feeling about
|
||||
libraries with versions < 1.0.
|
||||
@ -77,7 +77,7 @@ If not, it should be at ftp.uu.net in /graphics/png
|
||||
Eventually, it will be at ftp.uu.net in /pub/archiving/zip/zlib
|
||||
|
||||
You may also want a copy of the PNG specification. It is available
|
||||
as an Internet Draft, and RFC, and a W3C Recommendation. Failing
|
||||
as an RFC and a W3C Recommendation. Failing
|
||||
these resources you can try ftp.uu.net in the /graphics/png directory.
|
||||
|
||||
This code is currently being archived at ftp.uu.net in the
|
||||
@ -97,19 +97,19 @@ Finally, if you get any warning messages when compiling libpng
|
||||
fix. Please mention "libpng" somewhere in the subject line. Thanks.
|
||||
|
||||
This release was created and will be supported by myself (of course
|
||||
based in a large way on Guy's earlier work), and the PNG group.
|
||||
based in a large way on Guy's and Andreas' earlier work), and the PNG group.
|
||||
|
||||
adilger@enel.ucalgary.ca
|
||||
png-implement@dworkin.wustl.edu
|
||||
|
||||
You can reach Guy, the original libpng author, at (internet preferred):
|
||||
|
||||
internet: schalnat@group42.com
|
||||
CompuServe: 75501,1625
|
||||
You can't reach Guy, the original libpng author, at the addresses
|
||||
given in previous versions of this document. He will read mail
|
||||
addressed to the png-implement list, however.
|
||||
|
||||
Please do not send general questions about PNG. Send them to
|
||||
the address in the specification. At the same time, please do
|
||||
not send libpng questions to that address, send them to me. I'll
|
||||
the address in the specification (png-group@w3.org). At the same
|
||||
time, please do not send libpng questions to that address, send them to me
|
||||
or to png-implement@dworkin.wustl.edu. I'll
|
||||
get them in the end anyway. If you have a question about something
|
||||
in the PNG specification that is related to using libpng, send it
|
||||
to me. Send me any questions that start with "I was using libpng,
|
||||
@ -132,18 +132,20 @@ Files in this distribution:
|
||||
descrip.mms => VMS project file
|
||||
example.c => Example code for using libpng functions
|
||||
libpng.txt => Description of libpng and its functions
|
||||
makefile => Default Unixish makefile
|
||||
makefile.aco => ACORN makefile
|
||||
makefile.ama => Amiga makefile
|
||||
makefile.atr => Atari makefile
|
||||
makefile.bor => Borland makefile
|
||||
makefile.dec => DEC makefile
|
||||
makefile.dj2 => DJGPP 2 makefile
|
||||
makefile.elf => Unix ELF makefile
|
||||
makefile.knr => Makefile which calls ansi2knr to convert files
|
||||
makefile.mip => MIPS makefile
|
||||
makefile.msc => Microsoft C makefile
|
||||
makefile.sgi => Silicon Graphics Irix makefile
|
||||
makefile.std => Standard Unix makefile
|
||||
makefile.tc => Turbo C makefile
|
||||
makefile.sun => SUN makefile
|
||||
makefile.tc3 => Turbo C 3.0 makefile
|
||||
makevms.com => VMS make program
|
||||
png.c => Basic interface functions common to library
|
||||
png.h => Library function and interface declarations
|
||||
@ -166,13 +168,15 @@ Files in this distribution:
|
||||
|
||||
Good luck, and happy coding.
|
||||
|
||||
-Glenn Randers-Pehrson
|
||||
Internet: randeg@alumni.rpi.edu
|
||||
Web: http://www.rpi.edu/~randeg/index.html
|
||||
|
||||
-Andreas Eric Dilger
|
||||
Internet: adilger@enel.ucalgary.ca
|
||||
Web: http://www-mddsp.enel.ucalgary.ca/People/adilger/
|
||||
|
||||
-Guy Eric Schalnat
|
||||
Group 42, Inc.
|
||||
Internet: schalnat@group42.com
|
||||
CompuServe: 75501,1625
|
||||
(formerly of Group 42, Inc)
|
||||
Web: http://www.group42.com/
|
||||
|
||||
|
2
TODO
2
TODO
@ -5,7 +5,7 @@ improved dithering
|
||||
multi-lingual error and warning message support
|
||||
sPLT chunk handling
|
||||
cHRM transformation
|
||||
complete sRGB transformation (presently it simply uses gamma=0.5)
|
||||
complete sRGB transformation (presently it simply uses gamma=0.51)
|
||||
man pages for function calls
|
||||
high-level API for reading images
|
||||
final bug fixes
|
||||
|
16
example.c
16
example.c
@ -190,19 +190,22 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
|
||||
|
||||
/* Some suggestions as to how to get a screen gamma value */
|
||||
|
||||
/* Note that screen gamma is (display_gamma/viewing_gamma)
|
||||
if (/* We have a user-defined screen gamma value */)
|
||||
{
|
||||
screen_gamma = user-defined screen_gamma;
|
||||
}
|
||||
/* This is one way that applications share the same screen gamma value */
|
||||
else if ((gamma_str = getenv("DISPLAY_GAMMA")) != NULL)
|
||||
else if ((gamma_str = getenv("SCREEN_GAMMA")) != NULL)
|
||||
{
|
||||
screen_gamma = atof(gamma_str);
|
||||
}
|
||||
/* If we don't have another value */
|
||||
else
|
||||
{
|
||||
screen_gamma = 2.2; /* A good guess for PC monitors */
|
||||
screen_gamma = 2.2; /* A good guess for a PC monitors in a brightly
|
||||
lit room */
|
||||
screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */
|
||||
}
|
||||
|
||||
@ -211,13 +214,16 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
* by the user at run time by the user. It is strongly suggested that
|
||||
* your application support gamma correction.
|
||||
*/
|
||||
if (png_get_sRGB(png_ptr, info_ptr, &srgb_intent)
|
||||
png_set_sRGB(png_ptr, srgb_intent, 0);
|
||||
|
||||
int intent;
|
||||
|
||||
if (png_get_sRGB(png_ptr, info_ptr, &intent)
|
||||
png_set_sRGB(png_ptr, intent, 0);
|
||||
else
|
||||
if (png_get_gAMA(png_ptr, info_ptr, &image_gamma)
|
||||
png_set_gamma(png_ptr, screen_gamma, image_gamma);
|
||||
else
|
||||
png_set_gamma(png_ptr, screen_gamma, 0.45);
|
||||
png_set_gamma(png_ptr, screen_gamma, 0.51);
|
||||
|
||||
/* Dither RGB files down to 8 bit palette or reduce palettes
|
||||
* to the number of colors available on your screen.
|
||||
|
161
libpng.txt
161
libpng.txt
@ -1,10 +1,13 @@
|
||||
libpng.txt - a description on how to use and modify libpng
|
||||
|
||||
libpng version 1.00 version 0.97
|
||||
libpng version 0.98
|
||||
Updated and distributed by Glenn Randers-Pehrson <randeg@alumni.rpi.edu>
|
||||
Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
January 16, 1998
|
||||
|
||||
based on:
|
||||
|
||||
libpng version 1.00 version 0.96
|
||||
libpng 1.0 beta 6 version 0.96
|
||||
Updated and distributed by Andreas Dilger <adilger@enel.ucalgary.ca>,
|
||||
Copyright (c) 1996, 1997 Andreas Dilger
|
||||
May 28, 1997
|
||||
@ -29,7 +32,7 @@ it is heavily commented and should include everything most people
|
||||
will need.
|
||||
|
||||
Libpng was written as a companion to the PNG specification, as a way
|
||||
to reduce the amount of time and effort it takes to support the PNG
|
||||
of reducing the amount of time and effort it takes to support the PNG
|
||||
file format in application programs. The PNG specification is available
|
||||
as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/> and as a
|
||||
W3C Recommendation <http://www.w3.org/pub/WWW/TR/REC.png.html>. Some
|
||||
@ -49,12 +52,14 @@ 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 it's users.
|
||||
majority of the needs of its users.
|
||||
|
||||
Libpng uses zlib for its compression and decompression of PNG files.
|
||||
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
|
||||
@ -69,13 +74,15 @@ 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.
|
||||
variable passed to every libpng function call. It is not actually
|
||||
used in many of the functions; do not be alarmed about compiler
|
||||
warnings that say something to the effect that "png_ptr is not used."
|
||||
|
||||
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 were delevoped. The fields
|
||||
a set of interface functions for png_info 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.
|
||||
|
||||
@ -193,6 +200,19 @@ libpng know that there are some bytes missing from the start of the file.
|
||||
|
||||
png_set_sig_bytes(png_ptr, number);
|
||||
|
||||
In PNG files, the alpha channel in an image is the level of opacity.
|
||||
If you need the alpha channel in an image to be the level of transparency
|
||||
instead of opacity, you can invert the alpha channel (or the tRNS chunk
|
||||
data) after it's read, so that 0 is fully opaque and 255 (in 8-bit or
|
||||
paletted images) or 65535 (in 16-bit images) is fully transparent, with
|
||||
|
||||
png_set_invert_alpha(png_ptr);
|
||||
|
||||
This has to appear here rather than later with the other transformations
|
||||
because the tRNS chunk data must be modified in the case of paletted images.
|
||||
If your image is not a paletted image, the tRNS data (which in such cases
|
||||
represents a single color to be rendered as transparent) won't be changed.
|
||||
|
||||
You are now ready to read all the file information up to the actual
|
||||
image data. You do this with a call to png_read_info().
|
||||
|
||||
@ -252,6 +272,12 @@ into the info_ptr is returned for any complex types.
|
||||
png_get_gAMA(png_ptr, info_ptr, &gamma);
|
||||
gamma - the gamma the file is written at (PNG_INFO_gAMA)
|
||||
|
||||
png_get_sRGB(png_ptr, info_ptr, &srgb_intent);
|
||||
srgb_intent - the rendering intent (PNG_INFO_sRGB)
|
||||
The presence of the sRGB chunk means that the pixel
|
||||
data is in the sRGB color space. This chunk also
|
||||
implies specific values of gAMA and cHRM.
|
||||
|
||||
png_get_sBIT(png_ptr, info_ptr, &sig_bit);
|
||||
sig_bit - the number of significant bits for (PNG_INFO_sBIT)
|
||||
the gray, red, green, and blue channels, whichever
|
||||
@ -301,9 +327,9 @@ keyword/text pairs, one pair per chunk, with no limit on the number
|
||||
of text chunks, and a 2^31 byte limit on their size. While there are
|
||||
suggested keywords, there is no requirement to restrict the use to these
|
||||
strings. It is strongly suggested that keywords and text be sensible
|
||||
to humans (that's the point), so don't use abbreviations or non-printing
|
||||
symbols. See the PNG specification for more details. There is also
|
||||
no requirement to have text after the keyword.
|
||||
to humans (that's the point), so don't use abbreviations. Non-printing
|
||||
symbols are not allowed. See the PNG specification for more details.
|
||||
There is also no requirement to have text after the keyword.
|
||||
|
||||
Keywords should be limited to 79 Latin-1 characters without leading or
|
||||
trailing spaces, but non-consecutive spaces are allowed within the
|
||||
@ -381,7 +407,7 @@ values of the pixels:
|
||||
png_set_packing(png_ptr);
|
||||
|
||||
PNG files have possible bit depths of 1, 2, 4, 8, and 16. All pixels
|
||||
stored in a PNG image whave been "scaled" or "shifted" up to the next
|
||||
stored in a PNG image have been "scaled" or "shifted" up to the next
|
||||
higher possible bit depth (eg from 5 bits/sample in the range [0,31] to
|
||||
8 bits/sample in the range [0, 255]). However, it is also possible to
|
||||
convert the PNG pixel data back to the original bit depth of the image.
|
||||
@ -429,7 +455,7 @@ color. If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid),
|
||||
you may use this color, or supply another color more suitable for
|
||||
the current display (e.g., the background color from a web page). You
|
||||
need to tell libpng whether the color is in the gamma space of the
|
||||
dispay (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file
|
||||
display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file
|
||||
(PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one
|
||||
that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't
|
||||
know why anyone would use this, but it's here).
|
||||
@ -457,28 +483,39 @@ To properly display PNG images on any kind of system, the application needs
|
||||
to know what the display gamma is. Ideally, the user will know this, and
|
||||
the application will allow them to set it. One method of allowing the user
|
||||
to set the display gamma separately for each system is to check for the
|
||||
DISPLAY_GAMMA environment variable, which will hopefully be correctly set.
|
||||
DISPLAY_GAMMA and VIEWING_GAMMA environment variables or for a SCREEN_GAMMA
|
||||
environment variable, which will hopefully be correctly set.
|
||||
|
||||
Note that display_gamma is the gamma of your display, while screen_gamma is
|
||||
the overall gamma correction required to produce pleasing results,
|
||||
which depends on the lighting conditions in the surrounding environment.
|
||||
Screen_gamma is display_gamma/viewing_gamma, where viewing_gamma is
|
||||
the amount of additional gamma correction needed to compensate for
|
||||
a dim (viewing_gamma=1.125) or dark (viewing_gamma=1.25) environment.
|
||||
In a brightly lit room, no compensation other than the display_gamma
|
||||
is needed (viewing_gamma=1.0).
|
||||
|
||||
if (/* We have a user-defined screen gamma value */)
|
||||
{
|
||||
screen_gamma = user_defined_screen_gamma;
|
||||
}
|
||||
/* One way that applications can share the same screen gamma value */
|
||||
else if ((gamma_str = getenv("DISPLAY_GAMMA")) != NULL)
|
||||
else if ((gamma_str = getenv("SCREEN_GAMMA")) != NULL)
|
||||
{
|
||||
screen_gamma = atof(gamma_str);
|
||||
}
|
||||
/* If we don't have another value */
|
||||
else
|
||||
{
|
||||
screen_gamma = 2.2; /* A good guess for PC monitors */
|
||||
screen_gamma = 2.2; /* A good guess for a PC monitor in a bright office */
|
||||
screen_gamma = 1.956; /* A good guess for a PC monitor in a dim room */
|
||||
screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */
|
||||
}
|
||||
|
||||
The png_set_gamma() function handles gamma transformations of the data.
|
||||
Pass both the file gamma and the current screen_gamma. If the file does
|
||||
not have a gamma value, you can pass one anyway if you have an idea what
|
||||
it is (usually 0.45 is a good guess for GIF images on PCs). Note
|
||||
it is (usually 0.51 is a good guess for GIF images on PCs). Note
|
||||
that file gammas are inverted from screen gammas. See the discussions
|
||||
on gamma in the PNG specification for an excellent description of what
|
||||
gamma is, and why all applications should support it. It is strongly
|
||||
@ -487,7 +524,7 @@ recommended that PNG viewers support gamma correction.
|
||||
if (png_get_gAMA(png_ptr, info_ptr, &gamma))
|
||||
png_set_gamma(png_ptr, screen_gamma, gamma);
|
||||
else
|
||||
png_set_gamma(png_ptr, screen_gamma, 0.45);
|
||||
png_set_gamma(png_ptr, screen_gamma, 0.51);
|
||||
|
||||
If you need to reduce an RGB file to a paletted file, or if a paletted
|
||||
file has more entries then will fit on your screen, png_set_dither()
|
||||
@ -544,7 +581,7 @@ need to change the order the pixels are packed into bytes, you can use:
|
||||
The last thing to handle is interlacing; this is covered in detail below,
|
||||
but you must call the function here.
|
||||
|
||||
number_passes = png_set_interlace_handling(png_ptr);
|
||||
number_of_passes = png_set_interlace_handling(png_ptr);
|
||||
|
||||
After setting the transformations, libpng can update your png_info
|
||||
structure to reflect any transformations you've requested with this
|
||||
@ -582,7 +619,7 @@ where row_pointers is:
|
||||
|
||||
You can point to void or char or whatever you use for pixels.
|
||||
|
||||
If you don't want to read int the whole image at once, you can
|
||||
If you don't want to read in the whole image at once, you can
|
||||
use png_read_rows() instead. If there is no interlacing (check
|
||||
interlace_type == PNG_INTERLACE_TYPE_NONE), this is simple:
|
||||
|
||||
@ -599,24 +636,24 @@ row_pointers:
|
||||
If the file is interlaced (info_ptr->interlace_type != 0), things get
|
||||
somewhat harder. The only current (PNG Specification version 1.0)
|
||||
interlacing type for PNG is (interlace_type == PNG_INTERLACE_TYPE_ADAM7)
|
||||
is a someewhat complicated 2D interlace scheme, known as Adam7, that
|
||||
is a somewhat complicated 2D interlace scheme, known as Adam7, that
|
||||
breaks down an image into seven smaller images of varying size, based
|
||||
on an 8x8 grid.
|
||||
|
||||
libpng can fill out those images or it can give them to you "as is".
|
||||
If you want them filled out, there are two ways to do that. The one
|
||||
mentioned in the PNG specification is to expand each pixel to cover
|
||||
those pixels that have not been read yet. This results in a blocky
|
||||
image for the first pass, which gradually smoothes out as more pixels
|
||||
are read. The other method is the "sparkle" method, where pixels are
|
||||
draw only in their final locations, with the rest of the image remaining
|
||||
whatever colors they were initialized to before the start of the read.
|
||||
The first method usually looks better, but tends to be slower, as there
|
||||
are more pixels to put in the rows.
|
||||
those pixels that have not been read yet (the "rectangle" method).
|
||||
This results in a blocky image for the first pass, which gradually
|
||||
smooths out as more pixels are read. The other method is the "sparkle"
|
||||
method, where pixels are drawn only in their final locations, with the
|
||||
rest of the image remaining whatever colors they were initialized to
|
||||
before the start of the read. The first method usually looks better,
|
||||
but tends to be slower, as there are more pixels to put in the rows.
|
||||
|
||||
If you don't want libpng to handle the interlacing details, just call
|
||||
png_read_rows() seven times to read in all seven images. Each of the
|
||||
images are valid images by themselves, or they can be combined on an
|
||||
images is a valid image by itself, or they can all be combined on an
|
||||
8x8 grid to form a single image (although if you intend to combine them
|
||||
you would be far better off using the libpng interlace handling).
|
||||
|
||||
@ -638,7 +675,7 @@ If you want libpng to expand the images, call this before calling
|
||||
png_start_read_image() or png_read_update_info():
|
||||
|
||||
if (interlace_type == PNG_INTERLACE_TYPE_ADAM7)
|
||||
number_passes = png_set_interlace_handling(png_ptr);
|
||||
number_of_passes = png_set_interlace_handling(png_ptr);
|
||||
|
||||
This will return the number of passes needed. Currently, this
|
||||
is seven, but may change if another interlace type is added.
|
||||
@ -649,12 +686,12 @@ If you are not going to display the image after each pass, but are
|
||||
going to wait until the entire image is read in, use the sparkle
|
||||
effect. This effect is faster and the end result of either method
|
||||
is exactly the same. If you are planning on displaying the image
|
||||
after each pass, the rectangle effect is generally considered the
|
||||
after each pass, the "rectangle" effect is generally considered the
|
||||
better looking one.
|
||||
|
||||
If you only want the "sparkle" effect, just call png_read_rows() as
|
||||
normal, with the third parameter NULL. Make sure you make pass over
|
||||
the image number_passes times, and you don't change the data in the
|
||||
the image number_of_passes times, and you don't change the data in the
|
||||
rows between calls. You can change the locations of the data, just
|
||||
not the data. Each pass only writes the pixels appropriate for that
|
||||
pass, and assumes the data from previous passes is still valid.
|
||||
@ -963,6 +1000,19 @@ Some of the more important parts of the png_info are:
|
||||
png_set_gAMA(png_ptr, info_ptr, gamma);
|
||||
gamma - the gamma the image was created at (PNG_INFO_gAMA)
|
||||
|
||||
png_set_sRGB(png_ptr, info_ptr, srgb_intent);
|
||||
srgb_intent - the rendering intent (PNG_INFO_sRGB)
|
||||
The presence of the sRGB chunk means that the pixel
|
||||
data is in the sRGB color space. This chunk also
|
||||
implies specific values of gAMA and cHRM.
|
||||
|
||||
png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, srgb_intent);
|
||||
srgb_intent - the rendering intent (PNG_INFO_sRGB)
|
||||
The presence of the sRGB chunk means that the pixel
|
||||
data is in the sRGB color space. This chunk also
|
||||
causes gAMA and cHRM chunks with the specific values
|
||||
that are consistent with sRGB to be written.
|
||||
|
||||
png_set_sBIT(png_ptr, info_ptr, sig_bit);
|
||||
sig_bit - the number of significant bits for (PNG_INFO_sBIT)
|
||||
the gray, red, green, and blue channels, whichever
|
||||
@ -996,11 +1046,25 @@ Some of the more important parts of the png_info are:
|
||||
offset_y - positive offset from the top edge of the screen
|
||||
unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER
|
||||
|
||||
png_get_pHYs(png_ptr, info_ptr, res_x, res_y, unit_type);
|
||||
png_set_pHYs(png_ptr, info_ptr, res_x, res_y, unit_type);
|
||||
res_x - pixels/unit physical resolution in x direction
|
||||
res_y - pixels/unit physical resolution in x direction
|
||||
unit_type - PNG_RESOLUTION_UNKOWN, PNG_RESOLUTION_METER
|
||||
|
||||
In PNG files, the alpha channel in an image is the level of opacity.
|
||||
If your data is supplied as a level of transparency, you can invert the
|
||||
alpha channel before you write it, so that 0 is fully transparent and 255
|
||||
(in 8-bit or paletted images) or 65535 (in 16-bit images) is fully opaque,
|
||||
with
|
||||
|
||||
png_set_invert_alpha(png_ptr);
|
||||
|
||||
This must appear here instead of later with the other transformations
|
||||
because in the case of paletted images the tRNS chunk data has to
|
||||
be inverted before the tRNS chunk is written. If your image is not a
|
||||
paletted image, the tRNS data (which in such cases represents a single
|
||||
color to be rendered as transparent) won't be changed.
|
||||
|
||||
A quick word about text and num_text. text is an array of png_text
|
||||
structures. num_text is the number of valid structures in the array.
|
||||
If you want, you can use max_text to hold the size of the array, but
|
||||
@ -1072,8 +1136,8 @@ tEXt chunk use RFC 1123 format dates (eg 22 May 1997 18:07:10 GMT"),
|
||||
although this isn't a requirement. Unlike the tIME chunk, the
|
||||
"Creation Time" tEXt chunk is not expected to be automatically changed
|
||||
by the software. To facilitate the use of RFC 1123 dates, a function
|
||||
png_convert_to_rfc1152(png_timep) is provided to convert from PNG
|
||||
time to an RFC 1152 format string.
|
||||
png_convert_to_rfc1123(png_timep) is provided to convert from PNG
|
||||
time to an RFC 1123 format string.
|
||||
|
||||
You are now ready to write all the file information up to the actual
|
||||
image data. You do this with a call to png_write_info().
|
||||
@ -1229,12 +1293,12 @@ correct number of times to write all seven sub-images.
|
||||
If you want libpng to build the sub-images, call this before you start
|
||||
writing any rows:
|
||||
|
||||
number_passes = png_set_interlace_handling(png_ptr);
|
||||
number_of_passes = png_set_interlace_handling(png_ptr);
|
||||
|
||||
This will return the number of passes needed. Currently, this
|
||||
is seven, but may change if another interlace type is added.
|
||||
|
||||
Then write the complete image number_passes times.
|
||||
Then write the complete image number_of_passes times.
|
||||
|
||||
png_write_rows(png_ptr, row_pointers, number_of_rows);
|
||||
|
||||
@ -1280,7 +1344,7 @@ MAXSEG_64K in zlib.h. Since it is unlikely that the method of handling
|
||||
memory allocation on a platform will change between applications, these
|
||||
functions must be modified in the library at compile time.
|
||||
|
||||
Input/Output in libpng is done throught png_read() and png_write(),
|
||||
Input/Output in libpng is done through png_read() and png_write(),
|
||||
which currently just call fread() and fwrite(). The FILE * is stored in
|
||||
png_struct and is initialized via png_init_io(). If you wish to change
|
||||
the method of I/O, the library supplies callbacks that you can set
|
||||
@ -1378,7 +1442,7 @@ call. See zlib.h or zconf.h in the zlib library for more information.
|
||||
Configuring for Medium Model:
|
||||
|
||||
Libpng's support for medium model has been tested on most of the popular
|
||||
complers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets
|
||||
compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets
|
||||
defined, and FAR gets defined to far in pngconf.h, and you should be
|
||||
all set. Everything in the library (except for zlib's structure) is
|
||||
expecting far data. You must use the typedefs with the p or pp on
|
||||
@ -1410,8 +1474,8 @@ most useful one changes the compression level, which currently uses
|
||||
input compression values in the range 0 - 9. The library normally
|
||||
uses the default compression level (Z_DEFAULT_COMPRESSION = 6). Tests
|
||||
have shown that for a large majority of images, compression values in
|
||||
the range 3-6 compress as well as higher levels, and do so much faster.
|
||||
For online applications it may be desirable to have maximum speed
|
||||
the range 3-6 compress nearly as well as higher levels, and do so much
|
||||
faster. For online applications it may be desirable to have maximum speed
|
||||
(Z_BEST_SPEED = 1). With versions of zlib after v0.99, you can also
|
||||
specify no compression (Z_NO_COMPRESSION = 0), but this would create
|
||||
files larger than just storing the raw bitmap. You can specify the
|
||||
@ -1495,8 +1559,13 @@ Removing unwanted object code:
|
||||
There are a bunch of #define's in pngconf.h that control what parts of
|
||||
libpng are compiled. All the defines end in _SUPPORTED. If you are
|
||||
never going to use an ability, you can change the #define to #undef
|
||||
before recompiling libpng and save yourself code and data space. All
|
||||
the reading and writing specific code are in seperate files, so the
|
||||
before recompiling libpng and save yourself code and data space.
|
||||
You can also turn them off en masse with a compiler directive to
|
||||
define PNG_READ_NOT_FULLY_SUPPORTED or PNG_WRITE_NOT_FULLY_SUPPORTED,
|
||||
along with directives to turn on any of the capabilities that you do
|
||||
want.
|
||||
|
||||
All the reading and writing specific code are in separate files, so the
|
||||
linker should only grab the files it needs. However, if you want to
|
||||
make sure, or if you are building a stand alone library, all the
|
||||
reading files start with pngr and all the writing files start with
|
||||
@ -1514,10 +1583,12 @@ those sections which are actually used will be loaded into memory.
|
||||
|
||||
Changes to Libpng from version 0.88
|
||||
|
||||
It should be noted that versions of libpng later than 0.88 are not
|
||||
distributed by the original libpng author, Guy Schalnat, but rather
|
||||
another member of the original PNG Group, Andreas Dilger. Guy is still
|
||||
alive and well, but he has moved on to other things.
|
||||
It should be noted that versions of libpng later than 0.96 are not
|
||||
distributed by the original libpng author, Guy Schalnat, nor by
|
||||
Andreas Dilger, who had taken over from Guy during 1996 and 1997, and
|
||||
distributed versions 0.89 through 0.96, but rather by another member
|
||||
of the original PNG Group, Glenn Randers-Pehrson. Guy and Andreas are
|
||||
still alive and well, but they have moved on to other things.
|
||||
|
||||
The old libpng functions png_read_init(), png_write_init(),
|
||||
png_info_init(), png_read_destroy(), and png_write_destory() have been
|
||||
|
@ -1,6 +1,6 @@
|
||||
# makefile for libpng on Linux ELF with gcc
|
||||
# Copyright (C) 1996, 1997 Andreas Dilger
|
||||
# Copyright (C) 1998 Glenn Randers-Pehrson
|
||||
# Copyright (C) 1998 Greg Roelofs
|
||||
# For conditions of distribution and use, see copyright notice in png.h
|
||||
|
||||
CC=gcc
|
||||
@ -22,7 +22,7 @@ RANLIB=ranlib
|
||||
#RANLIB=echo
|
||||
|
||||
PNGMAJ = 2
|
||||
PNGMIN = 0.97
|
||||
PNGMIN = 0.98
|
||||
PNGVER = $(PNGMAJ).$(PNGMIN)
|
||||
|
||||
# where make install puts libpng.a, libpng.so*, and png.h
|
||||
|
69
makefile.sgi
Normal file
69
makefile.sgi
Normal file
@ -0,0 +1,69 @@
|
||||
# makefile for libpng
|
||||
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
# For conditions of distribution and use, see copyright notice in png.h
|
||||
|
||||
# Where the zlib library and include files are located
|
||||
#ZLIBLIB=/usr/local/lib
|
||||
#ZLIBINC=/usr/local/include
|
||||
ZLIBLIB=../zlib
|
||||
ZLIBINC=../zlib
|
||||
|
||||
CC=cc
|
||||
|
||||
CFLAGS=-I$(ZLIBINC) -O -fullwarn # -g -DPNG_DEBUG=1
|
||||
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
|
||||
|
||||
RANLIB=echo
|
||||
#RANLIB=ranlib
|
||||
|
||||
# where make install puts libpng.a and png.h
|
||||
prefix=/usr/local
|
||||
|
||||
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
|
||||
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
|
||||
pngwtran.o pngmem.o pngerror.o pngpread.o
|
||||
|
||||
all: libpng.a pngtest
|
||||
|
||||
libpng.a: $(OBJS)
|
||||
ar rc $@ $(OBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
pngtest: pngtest.o libpng.a
|
||||
$(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
|
||||
|
||||
test: pngtest
|
||||
./pngtest
|
||||
|
||||
install: libpng.a
|
||||
-@mkdir $(prefix)/include
|
||||
-@mkdir $(prefix)/lib
|
||||
cp png.h $(prefix)/include
|
||||
cp pngconf.h $(prefix)/include
|
||||
chmod 644 $(prefix)/include/png.h
|
||||
chmod 644 $(prefix)/include/pngconf.h
|
||||
cp libpng.a $(prefix)/lib
|
||||
chmod 644 $(prefix)/lib/libpng.a
|
||||
|
||||
clean:
|
||||
rm -f *.o libpng.a pngtest pngout.png
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
png.o: png.h pngconf.h
|
||||
pngerror.o: png.h pngconf.h
|
||||
pngrio.o: png.h pngconf.h
|
||||
pngwio.o: png.h pngconf.h
|
||||
pngmem.o: png.h pngconf.h
|
||||
pngset.o: png.h pngconf.h
|
||||
pngget.o: png.h pngconf.h
|
||||
pngread.o: png.h pngconf.h
|
||||
pngrtran.o: png.h pngconf.h
|
||||
pngrutil.o: png.h pngconf.h
|
||||
pngtest.o: png.h pngconf.h
|
||||
pngtrans.o: png.h pngconf.h
|
||||
pngwrite.o: png.h pngconf.h
|
||||
pngwtran.o: png.h pngconf.h
|
||||
pngwutil.o: png.h pngconf.h
|
||||
pngpread.o: png.h pngconf.h
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Makefile for libpng
|
||||
# TurboC++ 3.0 (Note: All modules are compiled in C mode)
|
||||
|
||||
# To use, do "make -fmakefile.tc"
|
||||
# To use, do "make -fmakefile.tc3"
|
||||
|
||||
# ------------- Turbo C++ 3.0 -------------
|
||||
MODEL=-ml
|
6
png.c
6
png.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* png.c - location for general purpose libpng functions
|
||||
*
|
||||
* libpng 0.97
|
||||
* libpng 0.98
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* January 7, 1998
|
||||
* January 16, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@ -16,7 +16,7 @@
|
||||
/* Version information for C files. This had better match the version
|
||||
* string defined in png.h.
|
||||
*/
|
||||
char png_libpng_ver[] = "0.97";
|
||||
char png_libpng_ver[] = "0.98";
|
||||
|
||||
/* Place to hold the signiture string for a PNG file. */
|
||||
png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||
|
108
png.h
108
png.h
@ -1,12 +1,37 @@
|
||||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng 0.97 beta
|
||||
* libpng 0.98 beta
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998 Glenn Randers-Pehrson
|
||||
* January 7, 1998
|
||||
* January 16, 1998
|
||||
*
|
||||
* Note about libpng version numbers:
|
||||
*
|
||||
* Due to various miscommunications, unforeseen code incompatibilities
|
||||
* and occasional factors outside the authors' control, version numbering
|
||||
* on the library has not always been consistent and straightforward.
|
||||
* The following table summarizes matters since version 0.89c, which was
|
||||
* the first widely used release:
|
||||
*
|
||||
* source png.h shared-lib
|
||||
* version string version
|
||||
* ------- ------ ----------
|
||||
* 0.89c ("1.0 beta 3") 0.89 1.0.89
|
||||
* 0.90 ("1.0 beta 4") 0.90 0.90 [should have been 2.0.90]
|
||||
* 0.95 ("1.0 beta 5") 0.95 0.95 [should have been 2.0.95]
|
||||
* 0.96 ("1.0 beta 6") 0.96 0.96 [should have been 2.0.96]
|
||||
* 0.97b ("1.00.97 beta 7") 1.00.97 1.0.0 [should have been 2.0.97]
|
||||
* 0.97c 0.97 2.0.97
|
||||
* 0.98 0.98 2.0.98
|
||||
* 0.99 0.99 2.0.99
|
||||
* 1.0 1.00 2.1.0
|
||||
*
|
||||
* Henceforth the source version will match the shared-library minor
|
||||
* and patch numbers; the shared-library major version number will be
|
||||
* used for changes in backward compatibility, as it is intended.
|
||||
*
|
||||
* BETA NOTICE:
|
||||
* This is a beta version. It reads and writes valid files on the
|
||||
@ -94,12 +119,12 @@ extern "C" {
|
||||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "0.97"
|
||||
#define PNG_LIBPNG_VER_STRING "0.98"
|
||||
|
||||
/* careful here. At one time, I wanted to use 082, but that would be octal.
|
||||
* Version 1.0 will be 100 here, etc.
|
||||
*/
|
||||
#define PNG_LIBPNG_VER 97
|
||||
#define PNG_LIBPNG_VER 98
|
||||
|
||||
/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
|
||||
#ifndef PNG_NO_EXTERN
|
||||
@ -108,33 +133,6 @@ extern "C" {
|
||||
*/
|
||||
extern char png_libpng_ver[];
|
||||
|
||||
/*
|
||||
* Note about libpng version numbers:
|
||||
*
|
||||
* Due to various miscommunications, unforeseen code incompatibilities
|
||||
* and occasional factors outside the authors' control, version numbering
|
||||
* on the library has not always been consistent and straightforward.
|
||||
* The following table summarizes matters since version 0.89c, which was
|
||||
* the first widely used release:
|
||||
*
|
||||
* source png.h shared-lib
|
||||
* version string version
|
||||
* ------- ------ ----------
|
||||
* 0.89c ("1.0 beta 3") 0.89 1.0.89
|
||||
* 0.90 ("1.0 beta 4") 0.90 0.90 [should have been 2.0.90]
|
||||
* 0.95 ("1.0 beta 5") 0.95 0.95 [should have been 2.0.95]
|
||||
* 0.96 ("1.0 beta 6") 0.96 0.96 [should have been 2.0.96]
|
||||
* 0.97b ("1.00.97 beta 7") 1.00.97 1.0.0 [should have been 2.0.97]
|
||||
* 0.97c 0.97 2.0.97
|
||||
* 0.98 0.98 2.0.98
|
||||
* 0.99 0.99 2.0.99
|
||||
* 1.0 1.00 2.1.0
|
||||
*
|
||||
* Henceforth the source version will match the shared-library minor
|
||||
* and patch numbers; the shared-library major version number will be
|
||||
* used for changes in backward compatibility, as it is intended.
|
||||
*/
|
||||
|
||||
/* Structures to facilitate easy interlacing. See png.c for more details */
|
||||
extern int FARDATA png_pass_start[];
|
||||
extern int FARDATA png_pass_inc[];
|
||||
@ -582,9 +580,9 @@ struct png_struct_def
|
||||
png_uint_32 flush_rows; /* number of rows written since last flush */
|
||||
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED)
|
||||
int gamma_shift; /* number of "insignificant" bits 16-bit gamma */
|
||||
float gamma; /* file gamma value */
|
||||
float display_gamma; /* display gamma value */
|
||||
int gamma_shift; /* number of "insignificant" bits 16-bit gamma */
|
||||
float gamma; /* file gamma value */
|
||||
float screen_gamma; /* screen gamma value (display_gamma/viewing_gamma */
|
||||
#endif /* PNG_READ_GAMMA_SUPPORTED */
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
png_bytep gamma_table; /* gamma table for 8 bit depth files */
|
||||
@ -626,6 +624,7 @@ struct png_struct_def
|
||||
png_charp current_text; /* current text chunk buffer */
|
||||
png_charp current_text_ptr; /* current location in current_text */
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_READ_tEXt/zTXt_SUPPORTED */
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
||||
/* for the Borland special 64K segment handler */
|
||||
png_bytepp offset_table_ptr;
|
||||
@ -633,8 +632,7 @@ struct png_struct_def
|
||||
png_uint_16 offset_table_number;
|
||||
png_uint_16 offset_table_count;
|
||||
png_uint_16 offset_table_count_free;
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED&&__TURBOC__&&!_Windows&&!__FLAT__ */
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
#endif /* __TURBOC__&&!_Windows&&!__FLAT__ */
|
||||
#if defined(PNG_READ_DITHER_SUPPORTED)
|
||||
png_bytep palette_lookup; /* lookup table for dithering */
|
||||
png_bytep dither_index; /* index translation for palette files */
|
||||
@ -649,9 +647,9 @@ struct png_struct_def
|
||||
png_uint_16p filter_costs; /* relative filter calculation cost */
|
||||
png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */
|
||||
#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
|
||||
#if defined(PNG_TIME_RFC1152_SUPPORTED)
|
||||
png_charp time_buffer; /* String to hold RFC 1152 time text */
|
||||
#endif /* PNG_TIME_RFC1152_SUPPORTED */
|
||||
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||
png_charp time_buffer; /* String to hold RFC 1123 time text */
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
};
|
||||
|
||||
typedef png_struct FAR * FAR * png_structpp;
|
||||
@ -706,10 +704,10 @@ extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr,
|
||||
extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr,
|
||||
png_infop info_ptr));
|
||||
|
||||
#if defined(PNG_TIME_RFC1152_SUPPORTED)
|
||||
extern PNG_EXPORT(png_charp,png_convert_to_rfc1152)
|
||||
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||
extern PNG_EXPORT(png_charp,png_convert_to_rfc1123)
|
||||
PNGARG((png_structp png_ptr, png_timep ptime));
|
||||
#endif /* PNG_TIME_RFC1152_SUPPORTED */
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
|
||||
#if defined(PNG_WRITE_tIME_SUPPORTED)
|
||||
/* convert from a struct tm to png_time */
|
||||
@ -753,6 +751,11 @@ extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr));
|
||||
extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr));
|
||||
#endif /* PNG_READ_SWAP_ALPHA_SUPPORTED || PNG_WRITE_SWAP_ALPHA_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
|
||||
defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||
extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr));
|
||||
#endif /* PNG_READ_INVERT_ALPHA_SUPPORTED || PNG_WRITE_INVERT_ALPHA_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||
/* Add a filler byte to 24-bit RGB images. */
|
||||
extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr,
|
||||
@ -819,7 +822,7 @@ extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr,
|
||||
#endif /* PNG_READ_DITHER_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED)
|
||||
/* Handle gamma correction. */
|
||||
/* Handle gamma correction. Screen_gamma=(display_gamma/viewing_gamma) */
|
||||
extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr,
|
||||
double screen_gamma, double default_file_gamma));
|
||||
#endif /* PNG_READ_GAMMA_SUPPORTED */
|
||||
@ -1240,14 +1243,14 @@ extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr,
|
||||
|
||||
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||
extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr,
|
||||
png_infop info_ptr, png_bytep srgb_intent));
|
||||
png_infop info_ptr, int *intent));
|
||||
#endif /* PNG_READ_sRGB_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_sRGB_SUPPORTED) || defined(PNG_WRITE_sRGB_SUPPORTED)
|
||||
extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr,
|
||||
png_infop info_ptr, png_byte srgb_intent));
|
||||
png_infop info_ptr, int intent));
|
||||
extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr,
|
||||
png_infop info_ptr, png_byte srgb_intent));
|
||||
png_infop info_ptr, int intent));
|
||||
#endif /* PNG_READ_sRGB_SUPPORTED || PNG_WRITE_sRGB_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
|
||||
@ -1361,6 +1364,7 @@ extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
|
||||
#define PNG_PACKSWAP 0x10000
|
||||
#define PNG_SWAP_ALPHA 0x20000
|
||||
#define PNG_STRIP_ALPHA 0x40000
|
||||
#define PNG_INVERT_ALPHA 0x80000
|
||||
|
||||
/* flags for png_create_struct */
|
||||
#define PNG_STRUCT_PNG 0x0001
|
||||
@ -1585,7 +1589,7 @@ PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr,
|
||||
|
||||
#if defined(PNG_WRITE_sRGB_SUPPORTED)
|
||||
PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr,
|
||||
png_byte srgb_intent));
|
||||
int intent));
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_tRNS_SUPPORTED)
|
||||
@ -1702,6 +1706,16 @@ PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info,
|
||||
png_bytep row));
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
|
||||
PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info,
|
||||
png_bytep row));
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||
PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info,
|
||||
png_bytep row));
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
|
||||
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
||||
PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info,
|
||||
|
38
pngconf.h
38
pngconf.h
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngconf.c - machine configurable file for libpng
|
||||
*
|
||||
* libpng 0.97
|
||||
* libpng 0.98
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* January 7, 1998
|
||||
* January 16, 1998
|
||||
*/
|
||||
|
||||
/* Any machine specific code is near the front of this file, so if you
|
||||
@ -191,24 +191,25 @@ __dont__ include it again
|
||||
* less then 8, and even that may not work (I haven't tested it).
|
||||
*/
|
||||
|
||||
#ifndef PNG_MAX_GAMMA_8
|
||||
#define PNG_MAX_GAMMA_8 11
|
||||
#endif
|
||||
|
||||
/* This controls how much a difference in gamma we can tolerate before
|
||||
* we actually start doing gamma conversion.
|
||||
*/
|
||||
#ifndef PNG_GAMMA_THRESHOLD
|
||||
#define PNG_GAMMA_THRESHOLD 0.05
|
||||
#endif
|
||||
|
||||
#endif /* PNG_INTERNAL */
|
||||
|
||||
/* The following uses const char * instead of char * for error
|
||||
* and warning message functions, so some compilers won't complain.
|
||||
* If you want to use const, define PNG_USE_CONST here. It is not
|
||||
* normally defined to make configuration easier, as it is not a
|
||||
* critical part of the code.
|
||||
* If you do not want to use const, define PNG_NO_CONST here.
|
||||
*/
|
||||
#define PNG_USE_CONST
|
||||
|
||||
#ifdef PNG_USE_CONST
|
||||
#ifndef PNG_NO_CONST
|
||||
# define PNG_CONST const
|
||||
#else
|
||||
# define PNG_CONST
|
||||
@ -259,6 +260,7 @@ __dont__ include it again
|
||||
#define PNG_READ_GAMMA_SUPPORTED
|
||||
#define PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||
#define PNG_READ_SWAP_ALPHA_SUPPORTED
|
||||
#define PNG_READ_INVERT_ALPHA_SUPPORTED
|
||||
#define PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel */
|
||||
#endif /* PNG_READ_FULLY_SUPPORTED */
|
||||
@ -275,22 +277,32 @@ __dont__ include it again
|
||||
#define PNG_WRITE_FILLER_SUPPORTED /* This is the same as WRITE_STRIP_ALPHA */
|
||||
#define PNG_WRITE_FLUSH_SUPPORTED
|
||||
#define PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||
#define PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||
#endif /* PNG_WRITE_FULLY_SUPPORTED */
|
||||
|
||||
#if !defined(PNG_NO_STDIO)
|
||||
#define PNG_TIME_RFC1152_SUPPORTED
|
||||
#define PNG_TIME_RFC1123_SUPPORTED
|
||||
#endif
|
||||
|
||||
/* These are currently experimental features */
|
||||
#undef PNG_READ_16_TO_8_ACCURATE_SHIFT_SUPPORTED /* very little testing */
|
||||
/* These are currently experimental features, define them if you want */
|
||||
|
||||
/* very little testing */
|
||||
/*
|
||||
#define PNG_READ_16_TO_8_ACCURATE_SHIFT_SUPPORTED
|
||||
*/
|
||||
|
||||
/* This is only for PowerPC big-endian and 680x0 systems */
|
||||
#undef PNG_READ_BIG_ENDIAN_SUPPORTED /* some testing */
|
||||
/* some testing */
|
||||
/*
|
||||
#define PNG_READ_BIG_ENDIAN_SUPPORTED
|
||||
*/
|
||||
|
||||
/* These functions are turned off by default, as they will be phased out. */
|
||||
#undef PNG_USELESS_TESTS_SUPPORTED
|
||||
#undef PNG_CORRECT_PALETTE_SUPPORTED
|
||||
/*
|
||||
#define PNG_USELESS_TESTS_SUPPORTED
|
||||
#define PNG_CORRECT_PALETTE_SUPPORTED
|
||||
*/
|
||||
|
||||
/* Any chunks you are not interested in, you can undef here. The
|
||||
* ones that allocate memory may be expecially important (hIST,
|
||||
|
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* libpng 0.97
|
||||
* libpng 0.98
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* January 7, 1998
|
||||
* January 16, 1998
|
||||
*
|
||||
* This file provides a location for all error handling. Users which
|
||||
* need special error handling are expected to write replacement functions
|
||||
|
12
pngget.c
12
pngget.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* libpng 0.97
|
||||
* libpng 0.98
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* January 7, 1998
|
||||
* January 16, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@ -112,14 +112,13 @@ png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
|
||||
|
||||
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||
png_uint_32
|
||||
png_get_sRGB(png_structp png_ptr, png_infop info_ptr, png_bytep
|
||||
file_srgb_intent)
|
||||
png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
|
||||
{
|
||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_sRGB &&
|
||||
file_srgb_intent != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "sRGB");
|
||||
*file_srgb_intent = info_ptr->srgb_intent;
|
||||
*file_srgb_intent = (int)info_ptr->srgb_intent;
|
||||
return (PNG_INFO_sRGB);
|
||||
}
|
||||
return (0);
|
||||
@ -272,7 +271,8 @@ png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
|
||||
if ((info_ptr != NULL) || (info_ptr->num_text > 0))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n",
|
||||
(png_ptr->chunk_name[0] == '\0' ? "text" : png_ptr->chunk_name));
|
||||
(png_ptr->chunk_name[0] == '\0' ? "text"
|
||||
: (png_const_charp)png_ptr->chunk_name));
|
||||
if (text_ptr != NULL)
|
||||
*text_ptr = info_ptr->text;
|
||||
if (num_text != NULL)
|
||||
|
27
pngmem.c
27
pngmem.c
@ -1,12 +1,11 @@
|
||||
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* libpng 0.97
|
||||
* libpng 0.98
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* January 7, 1998
|
||||
* January 16, 1998
|
||||
*
|
||||
* This file provides a location for all memory allocation. Users which
|
||||
* need special memory handling are expected to modify the code in this file
|
||||
@ -16,6 +15,16 @@
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
/* The following "hides" PNG_MALLOC and PNG_FREE thus allowing the pngtest
|
||||
application to put a wrapper on top of them. */
|
||||
#ifdef PNGTEST_MEMORY_DEBUG
|
||||
#define PNG_MALLOC png_debug_malloc
|
||||
#define PNG_FREE png_debug_free
|
||||
#else
|
||||
#define PNG_MALLOC png_malloc
|
||||
#define PNG_FREE png_free
|
||||
#endif
|
||||
|
||||
/* Borland DOS special memory handler */
|
||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
||||
/* if you change this, be sure to change the one in png.h also */
|
||||
@ -72,7 +81,7 @@ png_destroy_struct(png_voidp struct_ptr)
|
||||
* (which should cause a fatal error) and introducing major problems.
|
||||
*/
|
||||
png_voidp
|
||||
png_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
PNG_MALLOC(png_structp png_ptr, png_uint_32 size)
|
||||
{
|
||||
png_voidp ret;
|
||||
if (png_ptr == NULL || size == 0)
|
||||
@ -166,11 +175,11 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* free a pointer allocated by png_malloc(). In the default
|
||||
/* free a pointer allocated by PNG_MALLOC(). In the default
|
||||
configuration, png_ptr is not used, but is passed in case it
|
||||
is needed. If ptr is NULL, return without taking any action. */
|
||||
void
|
||||
png_free(png_structp png_ptr, png_voidp ptr)
|
||||
PNG_FREE(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
return;
|
||||
@ -260,7 +269,7 @@ png_destroy_struct(png_voidp struct_ptr)
|
||||
have the ability to do that. */
|
||||
|
||||
png_voidp
|
||||
png_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
PNG_MALLOC(png_structp png_ptr, png_uint_32 size)
|
||||
{
|
||||
png_voidp ret;
|
||||
if (png_ptr == NULL || size == 0)
|
||||
@ -289,11 +298,11 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Free a pointer allocated by png_malloc(). In the default
|
||||
/* Free a pointer allocated by PNG_MALLOC(). In the default
|
||||
configuration, png_ptr is not used, but is passed in case it
|
||||
is needed. If ptr is NULL, return without taking any action. */
|
||||
void
|
||||
png_free(png_structp png_ptr, png_voidp ptr)
|
||||
PNG_FREE(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
return;
|
||||
|
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngpread.c - read a png file in push mode
|
||||
*
|
||||
* libpng 0.97
|
||||
* libpng 0.98
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* January 7, 1998
|
||||
* January 16, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
|
10
pngread.c
10
pngread.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* libpng 0.97
|
||||
* libpng 0.98
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* January 7, 1998
|
||||
* January 16, 1998
|
||||
*
|
||||
* This file contains routines that an application calls directly to
|
||||
* read a PNG file or stream.
|
||||
@ -655,12 +655,18 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
||||
|
||||
if (info_ptr != NULL)
|
||||
{
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
|
||||
png_free(png_ptr, info_ptr->text);
|
||||
#endif
|
||||
png_destroy_struct((png_voidp)info_ptr);
|
||||
*info_ptr_ptr = (png_infop)NULL;
|
||||
}
|
||||
|
||||
if (end_info_ptr != NULL)
|
||||
{
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
|
||||
png_free(png_ptr, info_ptr->text);
|
||||
#endif
|
||||
png_destroy_struct((png_voidp)end_info_ptr);
|
||||
*end_info_ptr_ptr = (png_infop)NULL;
|
||||
}
|
||||
|
4
pngrio.c
4
pngrio.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* libpng 0.97
|
||||
* libpng 0.98
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* January 7, 1998
|
||||
* January 16, 1998
|
||||
*
|
||||
* This file provides a location for all input. Users which need
|
||||
* special handling are expected to write a function which has the same
|
||||
|
134
pngrtran.c
134
pngrtran.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* libpng 0.97
|
||||
* libpng 0.98
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* January 7, 1998
|
||||
* January 16, 1998
|
||||
*
|
||||
* This file contains functions optionally called by an application
|
||||
* in order to tell libpng how to handle data when reading a PNG.
|
||||
@ -549,13 +549,13 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
* also needlessly introduces small errors.
|
||||
*/
|
||||
void
|
||||
png_set_gamma(png_structp png_ptr, double screen_gamma, double file_gamma)
|
||||
png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma)
|
||||
{
|
||||
png_debug(1, "in png_set_gamma\n");
|
||||
if (fabs(screen_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD)
|
||||
if (fabs(scrn_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD)
|
||||
png_ptr->transformations |= PNG_GAMMA;
|
||||
png_ptr->gamma = (float)file_gamma;
|
||||
png_ptr->display_gamma = (float)screen_gamma;
|
||||
png_ptr->screen_gamma = (float)scrn_gamma;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -592,6 +592,7 @@ png_set_rgb_to_gray(png_structp png_ptr, int gray_bits)
|
||||
png_debug(1, "in png_set_rgb_to_gray\n");
|
||||
png_ptr->transformations |= PNG_RGB_TO_GRAY;
|
||||
/* Need to do something with gray_bits here. */
|
||||
png_warning(png_ptr, "RGB to GRAY transformation is not yet implemented.");
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -644,6 +645,23 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
png_ptr->palette[png_ptr->background.index].green;
|
||||
png_ptr->background.blue =
|
||||
png_ptr->palette[png_ptr->background.index].blue;
|
||||
|
||||
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_INVERT_ALPHA)
|
||||
{
|
||||
#if defined(PNG_READ_EXPAND_SUPPORTED)
|
||||
if (png_ptr->transformations & !PNG_EXPAND)
|
||||
#endif
|
||||
{
|
||||
/* invert the alpha channel (in tRNS) unless the pixels are
|
||||
going to be expanded, in which case leave it for later */
|
||||
int i;
|
||||
for (i=0; i<png_ptr->num_trans; i++)
|
||||
png_ptr->trans[i] = 255 - png_ptr->trans[i];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -681,7 +699,7 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
{
|
||||
double g;
|
||||
|
||||
g = 1.0 / (png_ptr->background_gamma * png_ptr->display_gamma);
|
||||
g = 1.0 / (png_ptr->background_gamma * png_ptr->screen_gamma);
|
||||
|
||||
if (png_ptr->background_gamma_type==PNG_BACKGROUND_GAMMA_SCREEN||
|
||||
fabs(g - 1.0) < PNG_GAMMA_THRESHOLD)
|
||||
@ -761,17 +779,17 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
switch (png_ptr->background_gamma_type)
|
||||
{
|
||||
case PNG_BACKGROUND_GAMMA_SCREEN:
|
||||
g = (png_ptr->display_gamma);
|
||||
g = (png_ptr->screen_gamma);
|
||||
gs = 1.0;
|
||||
break;
|
||||
case PNG_BACKGROUND_GAMMA_FILE:
|
||||
g = 1.0 / (png_ptr->gamma);
|
||||
gs = 1.0 / (png_ptr->gamma * png_ptr->display_gamma);
|
||||
gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma);
|
||||
break;
|
||||
case PNG_BACKGROUND_GAMMA_UNIQUE:
|
||||
g = 1.0 / (png_ptr->background_gamma);
|
||||
gs = 1.0 / (png_ptr->background_gamma *
|
||||
png_ptr->display_gamma);
|
||||
png_ptr->screen_gamma);
|
||||
break;
|
||||
}
|
||||
|
||||