summaryrefslogtreecommitdiff
path: root/plugins/AdvaImg/src/LibPNG/pngwtran.c
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-08-12 20:13:00 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-08-12 20:13:00 +0000
commit25cb5bf3f7a6b7c9e71ffc9f26eefd7d8093a0c7 (patch)
tree84d9e4f0bb26c9497683e7e7e5ce966073447fab /plugins/AdvaImg/src/LibPNG/pngwtran.c
parentd9013df6a880f0bd7459f952d654ff476e480a90 (diff)
update for libpng 1.6.3 + aMNG patch
git-svn-id: http://svn.miranda-ng.org/main/trunk@5662 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/AdvaImg/src/LibPNG/pngwtran.c')
-rw-r--r--plugins/AdvaImg/src/LibPNG/pngwtran.c58
1 files changed, 25 insertions, 33 deletions
diff --git a/plugins/AdvaImg/src/LibPNG/pngwtran.c b/plugins/AdvaImg/src/LibPNG/pngwtran.c
index e962b68353..2cdd7c95c2 100644
--- a/plugins/AdvaImg/src/LibPNG/pngwtran.c
+++ b/plugins/AdvaImg/src/LibPNG/pngwtran.c
@@ -1,8 +1,8 @@
/* pngwtran.c - transforms the data in a row for PNG writers
*
- * Last changed in libpng 1.5.13 [September 27, 2012]
- * Copyright (c) 1998-2012 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.0 [February 14, 2013]
+ * Copyright (c) 1998-2013 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.)
*
@@ -20,7 +20,7 @@
* transformations is significant.
*/
void /* PRIVATE */
-png_do_write_transformations(png_structp png_ptr, png_row_infop row_info)
+png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info)
{
png_debug(1, "in png_do_write_transformations");
@@ -45,20 +45,8 @@ png_do_write_transformations(png_structp png_ptr, png_row_infop row_info)
#ifdef PNG_WRITE_FILLER_SUPPORTED
if (png_ptr->transformations & PNG_FILLER)
- {
- if (png_ptr->color_type & (PNG_COLOR_MASK_ALPHA|PNG_COLOR_MASK_PALETTE))
- {
- /* GA, RGBA or palette; in any of these cases libpng will not do the
- * the correct thing (whatever that might be).
- */
- png_warning(png_ptr, "incorrect png_set_filler call ignored");
- png_ptr->transformations &= ~PNG_FILLER;
- }
-
- else
- png_do_strip_channel(row_info, png_ptr->row_buf + 1,
- !(png_ptr->flags & PNG_FLAG_FILLER_AFTER));
- }
+ png_do_strip_channel(row_info, png_ptr->row_buf + 1,
+ !(png_ptr->flags & PNG_FLAG_FILLER_AFTER));
#endif
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
@@ -299,7 +287,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
{
png_bytep bp = row;
png_size_t i;
- png_byte mask;
+ unsigned int mask;
png_size_t row_bytes = row_info->rowbytes;
if (bit_depth->gray == 1 && row_info->bit_depth == 2)
@@ -313,20 +301,22 @@ png_do_shift(png_row_infop row_info, png_bytep row,
for (i = 0; i < row_bytes; i++, bp++)
{
- png_uint_16 v;
int j;
+ unsigned int v, out;
v = *bp;
- *bp = 0;
+ out = 0;
for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0])
{
if (j > 0)
- *bp |= (png_byte)((v << j) & 0xff);
+ out |= v << j;
else
- *bp |= (png_byte)((v >> (-j)) & mask);
+ out |= (v >> (-j)) & mask;
}
+
+ *bp = (png_byte)(out & 0xff);
}
}
@@ -339,21 +329,23 @@ png_do_shift(png_row_infop row_info, png_bytep row,
for (i = 0; i < istop; i++, bp++)
{
- png_uint_16 v;
+ const unsigned int c = i%channels;
int j;
- int c = (int)(i%channels);
+ unsigned int v, out;
v = *bp;
- *bp = 0;
+ out = 0;
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
{
if (j > 0)
- *bp |= (png_byte)((v << j) & 0xff);
+ out |= v << j;
else
- *bp |= (png_byte)((v >> (-j)) & 0xff);
+ out |= v >> (-j);
}
+
+ *bp = (png_byte)(out & 0xff);
}
}
@@ -365,22 +357,22 @@ png_do_shift(png_row_infop row_info, png_bytep row,
for (bp = row, i = 0; i < istop; i++)
{
- int c = (int)(i%channels);
- png_uint_16 value, v;
+ const unsigned int c = i%channels;
int j;
+ unsigned int value, v;
- v = (png_uint_16)(((png_uint_16)(*bp) << 8) + *(bp + 1));
+ v = png_get_uint_16(bp);
value = 0;
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
{
if (j > 0)
- value |= (png_uint_16)((v << j) & (png_uint_16)0xffff);
+ value |= v << j;
else
- value |= (png_uint_16)((v >> (-j)) & (png_uint_16)0xffff);
+ value |= v >> (-j);
}
- *bp++ = (png_byte)(value >> 8);
+ *bp++ = (png_byte)((value >> 8) & 0xff);
*bp++ = (png_byte)(value & 0xff);
}
}