mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[master] Reenabled png_set_dither() but renamed it to png_set_quantize() to
reflect more accurately what it actually does. At the same time, renamed the PNG_DITHER_[RED,GREEN_BLUE]_BITS macros to PNG_QUANTIZE_[RED,GREEN,BLUE]_BITS.
This commit is contained in:
24
ANNOUNCE
24
ANNOUNCE
@@ -1,5 +1,5 @@
|
||||
|
||||
Libpng 1.4.2rc01 - April 10, 2010
|
||||
Libpng 1.4.2rc02 - April 16, 2010
|
||||
|
||||
This is not intended to be a public release. It will be replaced
|
||||
within a few weeks by a public version or by another test version.
|
||||
@@ -9,20 +9,20 @@ Files available for download:
|
||||
Source files with LF line endings (for Unix/Linux) and with a
|
||||
"configure" script
|
||||
|
||||
1.4.2rc01.tar.xz (LZMA-compressed, recommended)
|
||||
1.4.2rc01.tar.gz
|
||||
1.4.2rc01.tar.bz2
|
||||
1.4.2rc02.tar.xz (LZMA-compressed, recommended)
|
||||
1.4.2rc02.tar.gz
|
||||
1.4.2rc02.tar.bz2
|
||||
|
||||
Source files with CRLF line endings (for Windows), without the
|
||||
"configure" script
|
||||
|
||||
lp142r01.zip
|
||||
lp142r01.7z
|
||||
lp142r02.zip
|
||||
lp142r02.7z
|
||||
|
||||
Other information:
|
||||
|
||||
1.4.2rc01-README.txt
|
||||
1.4.2rc01-LICENSE.txt
|
||||
1.4.2rc02-README.txt
|
||||
1.4.2rc02-LICENSE.txt
|
||||
|
||||
Changes since the last public release (1.4.1):
|
||||
|
||||
@@ -31,6 +31,14 @@ version 1.4.2beta01 [April 1, 2010]
|
||||
Conditionally compile an "else" statement in png_decompress_chunk().
|
||||
|
||||
version 1.4.2rc01 [April 10, 2010]
|
||||
No changes.
|
||||
|
||||
version 1.4.2rc02 [April 16, 2010]
|
||||
Documented the fact that png_set_dither() was disabled since libpng-1.4.0.
|
||||
Reenabled png_set_dither() but renamed it to png_set_quantize() to reflect
|
||||
more accurately what it actually does. At the same time, renamed
|
||||
the PNG_DITHER_[RED,GREEN_BLUE]_BITS macros to
|
||||
PNG_QUANTIZE_[RED,GREEN,BLUE]_BITS.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
|
||||
12
CHANGES
12
CHANGES
@@ -2054,7 +2054,7 @@ version 1.4.0beta46 [December 10, 2008]
|
||||
PNG_TRANSFORM_STRIP_FILLER (Jim Barry).
|
||||
|
||||
version 1.4.0beta47 [December 15, 2008]
|
||||
Support for dithering was removed by default, because it has never
|
||||
Support for dithering was disabled by default, because it has never
|
||||
been well tested and doesn't work very well. The code has not
|
||||
been removed, however, and can be enabled by building libpng with
|
||||
PNG_READ_DITHER_SUPPORTED defined.
|
||||
@@ -2541,7 +2541,15 @@ version 1.4.2beta01 [April 1, 2010]
|
||||
Conditionally compile an "else" statement in png_decompress_chunk().
|
||||
Restored the macro definition of png_check_sig().
|
||||
|
||||
version 1.4.2rc01 [April 14, 2010]
|
||||
version 1.4.2rc01 [April 10, 2010]
|
||||
No changes.
|
||||
|
||||
version 1.4.2rc02 [April 16, 2010]
|
||||
Documented the fact that png_set_dither() was disabled since libpng-1.4.0.
|
||||
Reenabled png_set_dither() but renamed it to png_set_quantize() to reflect
|
||||
more accurately what it actually does. At the same time, renamed
|
||||
the PNG_DITHER_[RED,GREEN_BLUE]_BITS macros to
|
||||
PNG_QUANTIZE_[RED,GREEN,BLUE]_BITS.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
|
||||
15
example.c
15
example.c
@@ -160,7 +160,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */
|
||||
* If you have enough memory to read in the entire image at once,
|
||||
* and you need to specify only transforms that can be controlled
|
||||
* with one of the PNG_TRANSFORM_* bits (this presently excludes
|
||||
* dithering, filling, setting background, and doing gamma
|
||||
* quantizing, filling, setting background, and doing gamma
|
||||
* adjustment), then you can read the entire image (including
|
||||
* pixels) into the info structure with this call:
|
||||
*/
|
||||
@@ -271,8 +271,8 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */
|
||||
png_set_gamma(png_ptr, screen_gamma, 0.45455);
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_DITHER_SUPPORTED
|
||||
/* Dither RGB files down to 8 bit palette or reduce palettes
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
/* Quantize RGB files down to 8 bit palette or reduce palettes
|
||||
* to the number of colors available on your screen.
|
||||
*/
|
||||
if (color_type & PNG_COLOR_MASK_COLOR)
|
||||
@@ -283,10 +283,11 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */
|
||||
/* This reduces the image to the application supplied palette */
|
||||
if (/* We have our own palette */)
|
||||
{
|
||||
/* An array of colors to which the image should be dithered */
|
||||
/* An array of colors to which the image should be quantized */
|
||||
png_color std_color_cube[MAX_SCREEN_COLORS];
|
||||
|
||||
png_set_dither(png_ptr, std_color_cube, MAX_SCREEN_COLORS,
|
||||
/* Prior to libpng-1.4.2, this was png_set_dither(). */
|
||||
png_set_quantize(png_ptr, std_color_cube, MAX_SCREEN_COLORS,
|
||||
MAX_SCREEN_COLORS, NULL, 0);
|
||||
}
|
||||
/* This reduces the image to the palette supplied in the file */
|
||||
@@ -296,11 +297,11 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */
|
||||
|
||||
png_get_hIST(png_ptr, info_ptr, &histogram);
|
||||
|
||||
png_set_dither(png_ptr, palette, num_palette,
|
||||
png_set_quantize(png_ptr, palette, num_palette,
|
||||
max_screen_colors, histogram, 0);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_DITHER_SUPPORTED */
|
||||
#endif /* PNG_READ_QUANTIZE_SUPPORTED */
|
||||
|
||||
/* Invert monochrome files to have 0 as white and 1 as black */
|
||||
png_set_invert_mono(png_ptr);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
libpng.txt - A description on how to use and modify libpng
|
||||
|
||||
libpng version 1.4.2rc02 - April 14, 2010
|
||||
libpng version 1.4.2rc02 - April 16, 2010
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
<glennrp at users.sourceforge.net>
|
||||
Copyright (c) 1998-2009 Glenn Randers-Pehrson
|
||||
@@ -11,7 +11,7 @@ libpng.txt - A description on how to use and modify libpng
|
||||
|
||||
Based on:
|
||||
|
||||
libpng versions 0.97, January 1998, through 1.4.2rc02 - April 14, 2010
|
||||
libpng versions 0.97, January 1998, through 1.4.2rc02 - April 16, 2010
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2009 Glenn Randers-Pehrson
|
||||
|
||||
@@ -475,7 +475,7 @@ you want to do are limited to the following set:
|
||||
to RGB (or GA to RGBA)
|
||||
|
||||
(This excludes setting a background color, doing gamma transformation,
|
||||
dithering, and setting filler.) If this is the case, simply do this:
|
||||
quantizing, and setting filler.) If this is the case, simply do this:
|
||||
|
||||
png_read_png(png_ptr, info_ptr, png_transforms, NULL)
|
||||
|
||||
@@ -1159,6 +1159,40 @@ recommended that PNG viewers support gamma correction.
|
||||
else
|
||||
png_set_gamma(png_ptr, screen_gamma, 0.45455);
|
||||
|
||||
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_quantize()
|
||||
will do that. Note that this is a simple match dither that merely
|
||||
finds the closest color available. This should work fairly well with
|
||||
optimized palettes, and fairly badly with linear color cubes. If you
|
||||
pass a palette that is larger then maximum_colors, the file will
|
||||
reduce the number of colors in the palette so it will fit into
|
||||
maximum_colors. If there is a histogram, it will use it to make
|
||||
more intelligent choices when reducing the palette. If there is no
|
||||
histogram, it may not do as good a job.
|
||||
|
||||
if (color_type & PNG_COLOR_MASK_COLOR)
|
||||
{
|
||||
if (png_get_valid(png_ptr, info_ptr,
|
||||
PNG_INFO_PLTE))
|
||||
{
|
||||
png_uint_16p histogram = NULL;
|
||||
|
||||
png_get_hIST(png_ptr, info_ptr,
|
||||
&histogram);
|
||||
png_set_quantize(png_ptr, palette, num_palette,
|
||||
max_screen_colors, histogram, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
png_color std_color_cube[MAX_SCREEN_COLORS] =
|
||||
{ ... colors ... };
|
||||
|
||||
png_set_quantize(png_ptr, std_color_cube,
|
||||
MAX_SCREEN_COLORS, MAX_SCREEN_COLORS,
|
||||
NULL,0);
|
||||
}
|
||||
}
|
||||
|
||||
PNG files describe monochrome as black being zero and white being one.
|
||||
The following code will reverse this (make black be one and white be
|
||||
zero):
|
||||
@@ -3105,10 +3139,14 @@ The png_zalloc() and png_zfree() functions are no longer exported.
|
||||
The png_zalloc() function no longer zeroes out the memory that it
|
||||
allocates.
|
||||
|
||||
Support for dithering was removed by default, because it has never
|
||||
been well tested and doesn't work very well. The code has not
|
||||
been removed, however, and can be enabled by building libpng with
|
||||
PNG_READ_DITHER_SUPPORTED defined.
|
||||
Support for dithering was disabled by default in libpng-1.4.0, because
|
||||
been well tested and doesn't actually "dither". The code was not
|
||||
removed, however, and could be enabled by building libpng with
|
||||
PNG_READ_DITHER_SUPPORTED defined. In libpng-1.4.2, this support
|
||||
was reenabled, but the function was renamed png_set_quantize() to
|
||||
reflect more accurately what it actually does. At the same time,
|
||||
the PNG_DITHER_[RED,GREEN_BLUE]_BITS macros were also renamed to
|
||||
PNG_QUANTIZE_[RED,GREEN,BLUE]_BITS.
|
||||
|
||||
We removed the trailing '.' from the warning and error messages.
|
||||
|
||||
@@ -3250,7 +3288,7 @@ Other rules can be inferred by inspecting the libpng source.
|
||||
|
||||
XIII. Y2K Compliance in libpng
|
||||
|
||||
April 14, 2010
|
||||
April 16, 2010
|
||||
|
||||
Since the PNG Development group is an ad-hoc body, we can't make
|
||||
an official declaration.
|
||||
|
||||
64
libpng.3
64
libpng.3
@@ -1,4 +1,4 @@
|
||||
.TH LIBPNG 3 "April 14, 2010"
|
||||
.TH LIBPNG 3 "April 16, 2010"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.4.2rc02
|
||||
.SH SYNOPSIS
|
||||
@@ -454,7 +454,7 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.4.2rc02
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_set_dither (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fP\fInum_palette\fP\fB, int \fP\fImaximum_colors\fP\fB, png_uint_16p \fP\fIhistogram\fP\fB, int \fIfull_dither\fP\fB);\fP
|
||||
\fBvoid png_set_quantize (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fP\fInum_palette\fP\fB, int \fP\fImaximum_colors\fP\fB, png_uint_16p \fP\fIhistogram\fP\fB, int \fIfull_quantize\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
@@ -785,7 +785,7 @@ Following is a copy of the libpng.txt file that accompanies libpng.
|
||||
.SH LIBPNG.TXT
|
||||
libpng.txt - A description on how to use and modify libpng
|
||||
|
||||
libpng version 1.4.2rc02 - April 14, 2010
|
||||
libpng version 1.4.2rc02 - April 16, 2010
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
<glennrp at users.sourceforge.net>
|
||||
Copyright (c) 1998-2009 Glenn Randers-Pehrson
|
||||
@@ -796,7 +796,7 @@ libpng.txt - A description on how to use and modify libpng
|
||||
|
||||
Based on:
|
||||
|
||||
libpng versions 0.97, January 1998, through 1.4.2rc02 - April 14, 2010
|
||||
libpng versions 0.97, January 1998, through 1.4.2rc02 - April 16, 2010
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2009 Glenn Randers-Pehrson
|
||||
|
||||
@@ -1260,7 +1260,7 @@ you want to do are limited to the following set:
|
||||
to RGB (or GA to RGBA)
|
||||
|
||||
(This excludes setting a background color, doing gamma transformation,
|
||||
dithering, and setting filler.) If this is the case, simply do this:
|
||||
quantizing, and setting filler.) If this is the case, simply do this:
|
||||
|
||||
png_read_png(png_ptr, info_ptr, png_transforms, NULL)
|
||||
|
||||
@@ -1944,6 +1944,40 @@ recommended that PNG viewers support gamma correction.
|
||||
else
|
||||
png_set_gamma(png_ptr, screen_gamma, 0.45455);
|
||||
|
||||
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_quantize()
|
||||
will do that. Note that this is a simple match dither that merely
|
||||
finds the closest color available. This should work fairly well with
|
||||
optimized palettes, and fairly badly with linear color cubes. If you
|
||||
pass a palette that is larger then maximum_colors, the file will
|
||||
reduce the number of colors in the palette so it will fit into
|
||||
maximum_colors. If there is a histogram, it will use it to make
|
||||
more intelligent choices when reducing the palette. If there is no
|
||||
histogram, it may not do as good a job.
|
||||
|
||||
if (color_type & PNG_COLOR_MASK_COLOR)
|
||||
{
|
||||
if (png_get_valid(png_ptr, info_ptr,
|
||||
PNG_INFO_PLTE))
|
||||
{
|
||||
png_uint_16p histogram = NULL;
|
||||
|
||||
png_get_hIST(png_ptr, info_ptr,
|
||||
&histogram);
|
||||
png_set_quantize(png_ptr, palette, num_palette,
|
||||
max_screen_colors, histogram, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
png_color std_color_cube[MAX_SCREEN_COLORS] =
|
||||
{ ... colors ... };
|
||||
|
||||
png_set_quantize(png_ptr, std_color_cube,
|
||||
MAX_SCREEN_COLORS, MAX_SCREEN_COLORS,
|
||||
NULL,0);
|
||||
}
|
||||
}
|
||||
|
||||
PNG files describe monochrome as black being zero and white being one.
|
||||
The following code will reverse this (make black be one and white be
|
||||
zero):
|
||||
@@ -3890,10 +3924,14 @@ The png_zalloc() and png_zfree() functions are no longer exported.
|
||||
The png_zalloc() function no longer zeroes out the memory that it
|
||||
allocates.
|
||||
|
||||
Support for dithering was removed by default, because it has never
|
||||
been well tested and doesn't work very well. The code has not
|
||||
been removed, however, and can be enabled by building libpng with
|
||||
PNG_READ_DITHER_SUPPORTED defined.
|
||||
Support for dithering was disabled by default in libpng-1.4.0, because
|
||||
been well tested and doesn't actually "dither". The code was not
|
||||
removed, however, and could be enabled by building libpng with
|
||||
PNG_READ_DITHER_SUPPORTED defined. In libpng-1.4.2, this support
|
||||
was reenabled, but the function was renamed png_set_quantize() to
|
||||
reflect more accurately what it actually does. At the same time,
|
||||
the PNG_DITHER_[RED,GREEN_BLUE]_BITS macros were also renamed to
|
||||
PNG_QUANTIZE_[RED,GREEN,BLUE]_BITS.
|
||||
|
||||
We removed the trailing '.' from the warning and error messages.
|
||||
|
||||
@@ -4035,7 +4073,7 @@ Other rules can be inferred by inspecting the libpng source.
|
||||
|
||||
.SH XIII. Y2K Compliance in libpng
|
||||
|
||||
April 14, 2010
|
||||
April 16, 2010
|
||||
|
||||
Since the PNG Development group is an ad-hoc body, we can't make
|
||||
an official declaration.
|
||||
@@ -4275,7 +4313,7 @@ possible without all of you.
|
||||
|
||||
Thanks to Frank J. T. Wojcik for helping with the documentation.
|
||||
|
||||
Libpng version 1.4.2rc02 - April 14, 2010:
|
||||
Libpng version 1.4.2rc02 - April 16, 2010:
|
||||
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
|
||||
Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
|
||||
|
||||
@@ -4298,7 +4336,7 @@ this sentence.
|
||||
|
||||
This code is released under the libpng license.
|
||||
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.4.2rc02, April 14, 2010, are
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.4.2rc02, April 16, 2010, are
|
||||
Copyright (c) 2004,2006-2007 Glenn Randers-Pehrson, and are
|
||||
distributed according to the same disclaimer and license as libpng-1.2.5
|
||||
with the following individual added to the list of Contributing Authors
|
||||
@@ -4397,7 +4435,7 @@ certification mark of the Open Source Initiative.
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
glennrp at users.sourceforge.net
|
||||
April 14, 2010
|
||||
April 16, 2010
|
||||
|
||||
.\" end of man page
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.TH LIBPNGPF 3 "April 10, 2010"
|
||||
.TH LIBPNGPF 3 "April 16, 2010"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.4.2rc01
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.4.2rc02
|
||||
(private functions)
|
||||
.SH SYNOPSIS
|
||||
\fB#include <png.h>\fP
|
||||
@@ -147,7 +147,7 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.4.2rc01
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_do_dither (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIpalette_lookup\fP\fB, png_bytep \fIdither_lookup\fP\fB);\fP
|
||||
\fBvoid png_do_quantize (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIpalette_lookup\fP\fB, png_bytep \fIquantize_lookup\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
|
||||
42
png.h
42
png.h
@@ -1,7 +1,7 @@
|
||||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng version 1.4.2rc01 - April 10, 2010
|
||||
* libpng version 1.4.2rc02 - April 16, 2010
|
||||
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
@@ -11,7 +11,7 @@
|
||||
* Authors and maintainers:
|
||||
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
|
||||
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
|
||||
* libpng versions 0.97, January 1998, through 1.4.2rc01 - April 10, 2010: Glenn
|
||||
* libpng versions 0.97, January 1998, through 1.4.2rc02 - April 16, 2010: Glenn
|
||||
* See also "Contributing Authors", below.
|
||||
*
|
||||
* Note about libpng version numbers:
|
||||
@@ -171,7 +171,7 @@
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
*
|
||||
* libpng versions 1.2.6, August 15, 2004, through 1.4.2rc01, April 10, 2010, are
|
||||
* libpng versions 1.2.6, August 15, 2004, through 1.4.2rc02, April 16, 2010, are
|
||||
* Copyright (c) 2004, 2006-2010 Glenn Randers-Pehrson, and are
|
||||
* distributed according to the same disclaimer and license as libpng-1.2.5
|
||||
* with the following individual added to the list of Contributing Authors:
|
||||
@@ -283,13 +283,13 @@
|
||||
* Y2K compliance in libpng:
|
||||
* =========================
|
||||
*
|
||||
* April 10, 2010
|
||||
* April 16, 2010
|
||||
*
|
||||
* Since the PNG Development group is an ad-hoc body, we can't make
|
||||
* an official declaration.
|
||||
*
|
||||
* This is your unofficial assurance that libpng from version 0.71 and
|
||||
* upward through 1.4.2rc01 are Y2K compliant. It is my belief that earlier
|
||||
* upward through 1.4.2rc02 are Y2K compliant. It is my belief that earlier
|
||||
* versions were also Y2K compliant.
|
||||
*
|
||||
* Libpng only has three year fields. One is a 2-byte unsigned integer
|
||||
@@ -345,9 +345,9 @@
|
||||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "1.4.2rc01"
|
||||
#define PNG_LIBPNG_VER_STRING "1.4.2rc02"
|
||||
#define PNG_HEADER_VERSION_STRING \
|
||||
" libpng version 1.4.2rc01 - April 10, 2010\n"
|
||||
" libpng version 1.4.2rc02 - April 16, 2010\n"
|
||||
|
||||
#define PNG_LIBPNG_VER_SONUM 14
|
||||
#define PNG_LIBPNG_VER_DLLNUM 14
|
||||
@@ -360,7 +360,7 @@
|
||||
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
|
||||
*/
|
||||
|
||||
#define PNG_LIBPNG_VER_BUILD 01
|
||||
#define PNG_LIBPNG_VER_BUILD 02
|
||||
|
||||
/* Release Status */
|
||||
#define PNG_LIBPNG_BUILD_ALPHA 1
|
||||
@@ -1333,13 +1333,13 @@ struct png_struct_def
|
||||
png_uint_16 offset_table_count_free PNG_DEPSTRUCT;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_DITHER_SUPPORTED
|
||||
png_bytep palette_lookup PNG_DEPSTRUCT; /* lookup table for dithering */
|
||||
png_bytep dither_index PNG_DEPSTRUCT; /* index translation for palette
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
png_bytep palette_lookup PNG_DEPSTRUCT; /* lookup table for quantizing */
|
||||
png_bytep quantize_index PNG_DEPSTRUCT; /* index translation for palette
|
||||
files */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_hIST_SUPPORTED)
|
||||
#if defined(PNG_READ_QUANTIZE_SUPPORTED) || defined(PNG_hIST_SUPPORTED)
|
||||
png_uint_16p hist PNG_DEPSTRUCT; /* histogram */
|
||||
#endif
|
||||
|
||||
@@ -1423,9 +1423,9 @@ struct png_struct_def
|
||||
png_bytep big_row_buf PNG_DEPSTRUCT; /* buffer to save current
|
||||
(unfiltered) row */
|
||||
|
||||
#ifdef PNG_READ_DITHER_SUPPORTED
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
/* The following three members were added at version 1.0.14 and 1.2.4 */
|
||||
png_bytep dither_sort PNG_DEPSTRUCT; /* working sort array */
|
||||
png_bytep quantize_sort PNG_DEPSTRUCT; /* working sort array */
|
||||
png_bytep index_to_palette PNG_DEPSTRUCT; /* where the original
|
||||
index currently is
|
||||
in the palette */
|
||||
@@ -1469,7 +1469,7 @@ struct png_struct_def
|
||||
/* This triggers a compiler error in png.c, if png.c and png.h
|
||||
* do not agree upon the version number.
|
||||
*/
|
||||
typedef png_structp version_1_4_2rc01;
|
||||
typedef png_structp version_1_4_2rc02;
|
||||
|
||||
typedef png_struct FAR * FAR * png_structpp;
|
||||
|
||||
@@ -1716,14 +1716,16 @@ extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr,
|
||||
extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_DITHER_SUPPORTED
|
||||
/* Turn on dithering, and reduce the palette to the number of colors
|
||||
* available.
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
/* Turn on quantizing, and reduce the palette to the number of colors
|
||||
* available. Prior to libpng-1.4.2, this was png_set_dither().
|
||||
*/
|
||||
extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr,
|
||||
extern PNG_EXPORT(void,png_set_quantize) PNGARG((png_structp png_ptr,
|
||||
png_colorp palette, int num_palette, int maximum_colors,
|
||||
png_uint_16p histogram, int full_dither));
|
||||
png_uint_16p histogram, int full_quantize));
|
||||
#endif
|
||||
/* This migration aid will be removed from libpng-1.5.0 */
|
||||
#define png_set_dither png_set_quantize
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
/* Handle gamma correction. Screen_gamma=(display_exponent) */
|
||||
|
||||
39
pngconf.h
39
pngconf.h
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng version 1.4.2rc01 - April 10, 2010
|
||||
* libpng version 1.4.2rc02 - April 16, 2010
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
@@ -391,18 +391,32 @@
|
||||
|
||||
/* Other defines for things like memory and the like can go here. */
|
||||
|
||||
/* This controls how fine the dithering gets. As this allocates
|
||||
/* This controls how fine the quantizing gets. As this allocates
|
||||
* a largish chunk of memory (32K), those who are not as concerned
|
||||
* with dithering quality can decrease some or all of these.
|
||||
* with quantizing quality can decrease some or all of these.
|
||||
*/
|
||||
#ifndef PNG_DITHER_RED_BITS
|
||||
# define PNG_DITHER_RED_BITS 5
|
||||
|
||||
/* Prior to libpng-1.4.2, these were PNG_DITHER_*_BITS
|
||||
* These migration aids will be removed from libpng-1.5.0.
|
||||
*/
|
||||
#ifdef PNG_DITHER_RED_BITS
|
||||
# define PNG_QUANTIZE_RED_BITS PNG_DITHER_RED_BITS
|
||||
#endif
|
||||
#ifndef PNG_DITHER_GREEN_BITS
|
||||
# define PNG_DITHER_GREEN_BITS 5
|
||||
#ifdef PNG_DITHER_GREEN_BITS
|
||||
# define PNG_QUANTIZE_GREEN_BITS PNG_DITHER_GREEN_BITS
|
||||
#endif
|
||||
#ifndef PNG_DITHER_BLUE_BITS
|
||||
# define PNG_DITHER_BLUE_BITS 5
|
||||
#ifdef PNG_DITHER_BLUE_BITS
|
||||
# define PNG_QUANTIZE_BLUE_BITS PNG_DITHER_BLUE_BITS
|
||||
#endif
|
||||
|
||||
#ifndef PNG_QUANTIZE_RED_BITS
|
||||
# define PNG_QUANTIZE_RED_BITS 5
|
||||
#endif
|
||||
#ifndef PNG_QUANTIZE_GREEN_BITS
|
||||
# define PNG_QUANTIZE_GREEN_BITS 5
|
||||
#endif
|
||||
#ifndef PNG_QUANTIZE_BLUE_BITS
|
||||
# define PNG_QUANTIZE_BLUE_BITS 5
|
||||
#endif
|
||||
|
||||
/* This controls how fine the gamma correction becomes when you
|
||||
@@ -499,11 +513,10 @@
|
||||
# ifndef PNG_NO_READ_INVERT
|
||||
# define PNG_READ_INVERT_SUPPORTED
|
||||
# endif
|
||||
#if 0 /* removed from libpng-1.4.0 */
|
||||
# ifndef PNG_NO_READ_DITHER
|
||||
# define PNG_READ_DITHER_SUPPORTED
|
||||
# ifndef PNG_NO_READ_QUANTIZE
|
||||
/* Prior to libpng-1.4.0 this was PNG_READ_DITHER_SUPPORTED */
|
||||
# define PNG_READ_QUANTIZE_SUPPORTED
|
||||
# endif
|
||||
#endif /* 0 */
|
||||
# ifndef PNG_NO_READ_BACKGROUND
|
||||
# define PNG_READ_BACKGROUND_SUPPORTED
|
||||
# endif
|
||||
|
||||
10
pngpriv.h
10
pngpriv.h
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngpriv.h - private declarations for use inside libpng
|
||||
*
|
||||
* libpng version 1.4.2rc01 - April 10, 2010
|
||||
* libpng version 1.4.2rc02 - April 16, 2010
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
@@ -106,7 +106,7 @@
|
||||
#define PNG_SHIFT 0x0008
|
||||
#define PNG_SWAP_BYTES 0x0010
|
||||
#define PNG_INVERT_MONO 0x0020
|
||||
#define PNG_DITHER 0x0040
|
||||
#define PNG_QUANTIZE 0x0040 /* formerly PNG_DITHER */
|
||||
#define PNG_BACKGROUND 0x0080
|
||||
#define PNG_BACKGROUND_EXPAND 0x0100
|
||||
/* 0x0200 unused */
|
||||
@@ -588,9 +588,9 @@ PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row));
|
||||
PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_DITHER_SUPPORTED
|
||||
PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info,
|
||||
png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup));
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
PNG_EXTERN void png_do_quantize PNGARG((png_row_infop row_info,
|
||||
png_bytep row, png_bytep palette_lookup, png_bytep quantize_lookup));
|
||||
|
||||
# ifdef PNG_CORRECT_PALETTE_SUPPORTED
|
||||
PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.4.1 [April 10, 2010]
|
||||
* Last changed in libpng 1.4.1 [April 16, 2010]
|
||||
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
@@ -1080,9 +1080,9 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr,
|
||||
png_free(png_ptr, png_ptr->big_row_buf);
|
||||
png_free(png_ptr, png_ptr->prev_row);
|
||||
png_free(png_ptr, png_ptr->chunkdata);
|
||||
#ifdef PNG_READ_DITHER_SUPPORTED
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
png_free(png_ptr, png_ptr->palette_lookup);
|
||||
png_free(png_ptr, png_ptr->dither_index);
|
||||
png_free(png_ptr, png_ptr->quantize_index);
|
||||
#endif
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
png_free(png_ptr, png_ptr->gamma_table);
|
||||
@@ -1257,7 +1257,7 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
|
||||
png_set_expand(png_ptr);
|
||||
#endif
|
||||
|
||||
/* We don't handle background color or gamma transformation or dithering.
|
||||
/* We don't handle background color or gamma transformation or quantizing.
|
||||
*/
|
||||
|
||||
#ifdef PNG_READ_INVERT_SUPPORTED
|
||||
|
||||
158
pngrtran.c
158
pngrtran.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* Last changed in libpng 1.4.1 [April 14, 2010]
|
||||
* Last changed in libpng 1.4.1 [April 16, 2010]
|
||||
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
@@ -141,13 +141,13 @@ png_set_strip_alpha(png_structp png_ptr)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_DITHER_SUPPORTED
|
||||
/* Dither file to 8 bit. Supply a palette, the current number
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
/* Quantize file to 8 bit. Supply a palette, the current number
|
||||
* of elements in the palette, the maximum number of elements
|
||||
* allowed, and a histogram if possible. If the current number
|
||||
* of colors is greater then the maximum number, the palette will be
|
||||
* modified to fit in the maximum number. "full_dither" indicates
|
||||
* whether we need a dithering cube set up for RGB images, or if we
|
||||
* modified to fit in the maximum number. "full_quantize" indicates
|
||||
* whether we need a quantizeing cube set up for RGB images, or if we
|
||||
* simply are reducing the number of colors in a paletted image.
|
||||
*/
|
||||
|
||||
@@ -161,24 +161,24 @@ typedef png_dsort FAR * png_dsortp;
|
||||
typedef png_dsort FAR * FAR * png_dsortpp;
|
||||
|
||||
void PNGAPI
|
||||
png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
png_set_quantize(png_structp png_ptr, png_colorp palette,
|
||||
int num_palette, int maximum_colors, png_uint_16p histogram,
|
||||
int full_dither)
|
||||
int full_quantize)
|
||||
{
|
||||
png_debug(1, "in png_set_dither");
|
||||
png_debug(1, "in png_set_quantize");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
png_ptr->transformations |= PNG_DITHER;
|
||||
png_ptr->transformations |= PNG_QUANTIZE;
|
||||
|
||||
if (!full_dither)
|
||||
if (!full_quantize)
|
||||
{
|
||||
int i;
|
||||
|
||||
png_ptr->dither_index = (png_bytep)png_malloc(png_ptr,
|
||||
png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)(num_palette * png_sizeof(png_byte)));
|
||||
for (i = 0; i < num_palette; i++)
|
||||
png_ptr->dither_index[i] = (png_byte)i;
|
||||
png_ptr->quantize_index[i] = (png_byte)i;
|
||||
}
|
||||
|
||||
if (num_palette > maximum_colors)
|
||||
@@ -192,12 +192,12 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
int i;
|
||||
|
||||
/* Initialize an array to sort colors */
|
||||
png_ptr->dither_sort = (png_bytep)png_malloc(png_ptr,
|
||||
png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)(num_palette * png_sizeof(png_byte)));
|
||||
|
||||
/* Initialize the dither_sort array */
|
||||
/* Initialize the quantize_sort array */
|
||||
for (i = 0; i < num_palette; i++)
|
||||
png_ptr->dither_sort[i] = (png_byte)i;
|
||||
png_ptr->quantize_sort[i] = (png_byte)i;
|
||||
|
||||
/* Find the least used palette entries by starting a
|
||||
* bubble sort, and running it until we have sorted
|
||||
@@ -214,14 +214,14 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
done = 1;
|
||||
for (j = 0; j < i; j++)
|
||||
{
|
||||
if (histogram[png_ptr->dither_sort[j]]
|
||||
< histogram[png_ptr->dither_sort[j + 1]])
|
||||
if (histogram[png_ptr->quantize_sort[j]]
|
||||
< histogram[png_ptr->quantize_sort[j + 1]])
|
||||
{
|
||||
png_byte t;
|
||||
|
||||
t = png_ptr->dither_sort[j];
|
||||
png_ptr->dither_sort[j] = png_ptr->dither_sort[j + 1];
|
||||
png_ptr->dither_sort[j + 1] = t;
|
||||
t = png_ptr->quantize_sort[j];
|
||||
png_ptr->quantize_sort[j] = png_ptr->quantize_sort[j + 1];
|
||||
png_ptr->quantize_sort[j + 1] = t;
|
||||
done = 0;
|
||||
}
|
||||
}
|
||||
@@ -230,7 +230,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
}
|
||||
|
||||
/* Swap the palette around, and set up a table, if necessary */
|
||||
if (full_dither)
|
||||
if (full_quantize)
|
||||
{
|
||||
int j = num_palette;
|
||||
|
||||
@@ -239,11 +239,11 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
*/
|
||||
for (i = 0; i < maximum_colors; i++)
|
||||
{
|
||||
if ((int)png_ptr->dither_sort[i] >= maximum_colors)
|
||||
if ((int)png_ptr->quantize_sort[i] >= maximum_colors)
|
||||
{
|
||||
do
|
||||
j--;
|
||||
while ((int)png_ptr->dither_sort[j] >= maximum_colors);
|
||||
while ((int)png_ptr->quantize_sort[j] >= maximum_colors);
|
||||
palette[i] = palette[j];
|
||||
}
|
||||
}
|
||||
@@ -258,32 +258,32 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
for (i = 0; i < maximum_colors; i++)
|
||||
{
|
||||
/* Only move the colors we need to */
|
||||
if ((int)png_ptr->dither_sort[i] >= maximum_colors)
|
||||
if ((int)png_ptr->quantize_sort[i] >= maximum_colors)
|
||||
{
|
||||
png_color tmp_color;
|
||||
|
||||
do
|
||||
j--;
|
||||
while ((int)png_ptr->dither_sort[j] >= maximum_colors);
|
||||
while ((int)png_ptr->quantize_sort[j] >= maximum_colors);
|
||||
|
||||
tmp_color = palette[j];
|
||||
palette[j] = palette[i];
|
||||
palette[i] = tmp_color;
|
||||
/* Indicate where the color went */
|
||||
png_ptr->dither_index[j] = (png_byte)i;
|
||||
png_ptr->dither_index[i] = (png_byte)j;
|
||||
png_ptr->quantize_index[j] = (png_byte)i;
|
||||
png_ptr->quantize_index[i] = (png_byte)j;
|
||||
}
|
||||
}
|
||||
|
||||
/* Find closest color for those colors we are not using */
|
||||
for (i = 0; i < num_palette; i++)
|
||||
{
|
||||
if ((int)png_ptr->dither_index[i] >= maximum_colors)
|
||||
if ((int)png_ptr->quantize_index[i] >= maximum_colors)
|
||||
{
|
||||
int min_d, k, min_k, d_index;
|
||||
|
||||
/* Find the closest color to one we threw out */
|
||||
d_index = png_ptr->dither_index[i];
|
||||
d_index = png_ptr->quantize_index[i];
|
||||
min_d = PNG_COLOR_DIST(palette[d_index], palette[0]);
|
||||
for (k = 1, min_k = 0; k < maximum_colors; k++)
|
||||
{
|
||||
@@ -298,12 +298,12 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
}
|
||||
}
|
||||
/* Point to closest color */
|
||||
png_ptr->dither_index[i] = (png_byte)min_k;
|
||||
png_ptr->quantize_index[i] = (png_byte)min_k;
|
||||
}
|
||||
}
|
||||
}
|
||||
png_free(png_ptr, png_ptr->dither_sort);
|
||||
png_ptr->dither_sort = NULL;
|
||||
png_free(png_ptr, png_ptr->quantize_sort);
|
||||
png_ptr->quantize_sort = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -410,19 +410,19 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
num_new_palette--;
|
||||
palette[png_ptr->index_to_palette[j]]
|
||||
= palette[num_new_palette];
|
||||
if (!full_dither)
|
||||
if (!full_quantize)
|
||||
{
|
||||
int k;
|
||||
|
||||
for (k = 0; k < num_palette; k++)
|
||||
{
|
||||
if (png_ptr->dither_index[k] ==
|
||||
if (png_ptr->quantize_index[k] ==
|
||||
png_ptr->index_to_palette[j])
|
||||
png_ptr->dither_index[k] =
|
||||
png_ptr->quantize_index[k] =
|
||||
png_ptr->index_to_palette[next_j];
|
||||
if ((int)png_ptr->dither_index[k] ==
|
||||
if ((int)png_ptr->quantize_index[k] ==
|
||||
num_new_palette)
|
||||
png_ptr->dither_index[k] =
|
||||
png_ptr->quantize_index[k] =
|
||||
png_ptr->index_to_palette[j];
|
||||
}
|
||||
}
|
||||
@@ -475,15 +475,15 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
}
|
||||
png_ptr->num_palette = (png_uint_16)num_palette;
|
||||
|
||||
if (full_dither)
|
||||
if (full_quantize)
|
||||
{
|
||||
int i;
|
||||
png_bytep distance;
|
||||
int total_bits = PNG_DITHER_RED_BITS + PNG_DITHER_GREEN_BITS +
|
||||
PNG_DITHER_BLUE_BITS;
|
||||
int num_red = (1 << PNG_DITHER_RED_BITS);
|
||||
int num_green = (1 << PNG_DITHER_GREEN_BITS);
|
||||
int num_blue = (1 << PNG_DITHER_BLUE_BITS);
|
||||
int total_bits = PNG_QUANTIZE_RED_BITS + PNG_QUANTIZE_GREEN_BITS +
|
||||
PNG_QUANTIZE_BLUE_BITS;
|
||||
int num_red = (1 << PNG_QUANTIZE_RED_BITS);
|
||||
int num_green = (1 << PNG_QUANTIZE_GREEN_BITS);
|
||||
int num_blue = (1 << PNG_QUANTIZE_BLUE_BITS);
|
||||
png_size_t num_entries = ((png_size_t)1 << total_bits);
|
||||
|
||||
png_ptr->palette_lookup = (png_bytep )png_calloc(png_ptr,
|
||||
@@ -496,16 +496,16 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
for (i = 0; i < num_palette; i++)
|
||||
{
|
||||
int ir, ig, ib;
|
||||
int r = (palette[i].red >> (8 - PNG_DITHER_RED_BITS));
|
||||
int g = (palette[i].green >> (8 - PNG_DITHER_GREEN_BITS));
|
||||
int b = (palette[i].blue >> (8 - PNG_DITHER_BLUE_BITS));
|
||||
int r = (palette[i].red >> (8 - PNG_QUANTIZE_RED_BITS));
|
||||
int g = (palette[i].green >> (8 - PNG_QUANTIZE_GREEN_BITS));
|
||||
int b = (palette[i].blue >> (8 - PNG_QUANTIZE_BLUE_BITS));
|
||||
|
||||
for (ir = 0; ir < num_red; ir++)
|
||||
{
|
||||
/* int dr = abs(ir - r); */
|
||||
int dr = ((ir > r) ? ir - r : r - ir);
|
||||
int index_r = (ir << (PNG_DITHER_BLUE_BITS +
|
||||
PNG_DITHER_GREEN_BITS));
|
||||
int index_r = (ir << (PNG_QUANTIZE_BLUE_BITS +
|
||||
PNG_QUANTIZE_GREEN_BITS));
|
||||
|
||||
for (ig = 0; ig < num_green; ig++)
|
||||
{
|
||||
@@ -513,7 +513,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
int dg = ((ig > g) ? ig - g : g - ig);
|
||||
int dt = dr + dg;
|
||||
int dm = ((dr > dg) ? dr : dg);
|
||||
int index_g = index_r | (ig << PNG_DITHER_BLUE_BITS);
|
||||
int index_g = index_r | (ig << PNG_QUANTIZE_BLUE_BITS);
|
||||
|
||||
for (ib = 0; ib < num_blue; ib++)
|
||||
{
|
||||
@@ -536,7 +536,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
png_free(png_ptr, distance);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_DITHER_SUPPORTED */
|
||||
#endif /* PNG_READ_QUANTIZE_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
/* Transform the image from the file_gamma to the screen_gamma. We
|
||||
@@ -1229,8 +1229,8 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
||||
info_ptr->color_type &= ~PNG_COLOR_MASK_COLOR;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_DITHER_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_DITHER)
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_QUANTIZE)
|
||||
{
|
||||
if (((info_ptr->color_type == PNG_COLOR_TYPE_RGB) ||
|
||||
(info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) &&
|
||||
@@ -1451,13 +1451,13 @@ png_do_read_transformations(png_structp png_ptr)
|
||||
png_do_chop(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_DITHER_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_DITHER)
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_QUANTIZE)
|
||||
{
|
||||
png_do_dither((png_row_infop)&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
png_ptr->palette_lookup, png_ptr->dither_index);
|
||||
png_do_quantize((png_row_infop)&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
png_ptr->palette_lookup, png_ptr->quantize_index);
|
||||
if (png_ptr->row_info.rowbytes == (png_uint_32)0)
|
||||
png_error(png_ptr, "png_do_dither returned rowbytes=0");
|
||||
png_error(png_ptr, "png_do_quantize returned rowbytes=0");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3790,16 +3790,16 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_DITHER_SUPPORTED
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
png_do_dither(png_row_infop row_info, png_bytep row,
|
||||
png_bytep palette_lookup, png_bytep dither_lookup)
|
||||
png_do_quantize(png_row_infop row_info, png_bytep row,
|
||||
png_bytep palette_lookup, png_bytep quantize_lookup)
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width=row_info->width;
|
||||
|
||||
png_debug(1, "in png_do_dither");
|
||||
png_debug(1, "in png_do_quantize");
|
||||
|
||||
{
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB &&
|
||||
@@ -3821,14 +3821,14 @@ png_do_dither(png_row_infop row_info, png_bytep row,
|
||||
* (((g >> 3) & 0x1f) << 5) |
|
||||
* ((b >> 3) & 0x1f);
|
||||
*/
|
||||
p = (((r >> (8 - PNG_DITHER_RED_BITS)) &
|
||||
((1 << PNG_DITHER_RED_BITS) - 1)) <<
|
||||
(PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) |
|
||||
(((g >> (8 - PNG_DITHER_GREEN_BITS)) &
|
||||
((1 << PNG_DITHER_GREEN_BITS) - 1)) <<
|
||||
(PNG_DITHER_BLUE_BITS)) |
|
||||
((b >> (8 - PNG_DITHER_BLUE_BITS)) &
|
||||
((1 << PNG_DITHER_BLUE_BITS) - 1));
|
||||
p = (((r >> (8 - PNG_QUANTIZE_RED_BITS)) &
|
||||
((1 << PNG_QUANTIZE_RED_BITS) - 1)) <<
|
||||
(PNG_QUANTIZE_GREEN_BITS + PNG_QUANTIZE_BLUE_BITS)) |
|
||||
(((g >> (8 - PNG_QUANTIZE_GREEN_BITS)) &
|
||||
((1 << PNG_QUANTIZE_GREEN_BITS) - 1)) <<
|
||||
(PNG_QUANTIZE_BLUE_BITS)) |
|
||||
((b >> (8 - PNG_QUANTIZE_BLUE_BITS)) &
|
||||
((1 << PNG_QUANTIZE_BLUE_BITS) - 1));
|
||||
|
||||
*dp++ = palette_lookup[p];
|
||||
}
|
||||
@@ -3850,14 +3850,14 @@ png_do_dither(png_row_infop row_info, png_bytep row,
|
||||
b = *sp++;
|
||||
sp++;
|
||||
|
||||
p = (((r >> (8 - PNG_DITHER_RED_BITS)) &
|
||||
((1 << PNG_DITHER_RED_BITS) - 1)) <<
|
||||
(PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) |
|
||||
(((g >> (8 - PNG_DITHER_GREEN_BITS)) &
|
||||
((1 << PNG_DITHER_GREEN_BITS) - 1)) <<
|
||||
(PNG_DITHER_BLUE_BITS)) |
|
||||
((b >> (8 - PNG_DITHER_BLUE_BITS)) &
|
||||
((1 << PNG_DITHER_BLUE_BITS) - 1));
|
||||
p = (((r >> (8 - PNG_QUANTIZE_RED_BITS)) &
|
||||
((1 << PNG_QUANTIZE_RED_BITS) - 1)) <<
|
||||
(PNG_QUANTIZE_GREEN_BITS + PNG_QUANTIZE_BLUE_BITS)) |
|
||||
(((g >> (8 - PNG_QUANTIZE_GREEN_BITS)) &
|
||||
((1 << PNG_QUANTIZE_GREEN_BITS) - 1)) <<
|
||||
(PNG_QUANTIZE_BLUE_BITS)) |
|
||||
((b >> (8 - PNG_QUANTIZE_BLUE_BITS)) &
|
||||
((1 << PNG_QUANTIZE_BLUE_BITS) - 1));
|
||||
|
||||
*dp++ = palette_lookup[p];
|
||||
}
|
||||
@@ -3867,12 +3867,12 @@ png_do_dither(png_row_infop row_info, png_bytep row,
|
||||
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
|
||||
}
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
dither_lookup && row_info->bit_depth == 8)
|
||||
quantize_lookup && row_info->bit_depth == 8)
|
||||
{
|
||||
sp = row;
|
||||
for (i = 0; i < row_width; i++, sp++)
|
||||
{
|
||||
*sp = dither_lookup[*sp];
|
||||
*sp = quantize_lookup[*sp];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user