diff options
author | loislo@chromium.org <loislo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-24 11:14:38 +0000 |
---|---|---|
committer | loislo@chromium.org <loislo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-24 11:14:38 +0000 |
commit | e59f44088b630fab61069a89e6af242fb01d5576 (patch) | |
tree | 5522e494e336ad67de08cdf827d0340965ebe750 /third_party/libpng/pngwtran.c | |
parent | 94de3e7a33032bad4b5b1157ee8f7306682c163a (diff) | |
download | chromium_src-e59f44088b630fab61069a89e6af242fb01d5576.zip chromium_src-e59f44088b630fab61069a89e6af242fb01d5576.tar.gz chromium_src-e59f44088b630fab61069a89e6af242fb01d5576.tar.bz2 |
Revert "libpng 1.6.3"
This reverts commit 777c940a87944192afaa28904c30145bfeb54d09.
Many Blink LayoutTests starts failing after this patch.
http://test-results.appspot.com/dashboards/flakiness_dashboard.html#group=%40ToT%20Blink&tests=canvas/philip/tests/security.dataURI.html,canvas/philip/tests/toDataURL.arguments.1.html,canvas/philip/tests/toDataURL.arguments.2.html,canvas/philip/tests/toDataURL.arguments.3.html,canvas/philip/tests/toDataURL.bogustype.html,canvas/philip/tests/toDataURL.default.html,canvas/philip/tests/toDataURL.lowercase.ascii.html,canvas/philip/tests/toDataURL.lowercase.unicode.html,canvas/philip/tests/toDataURL.nocontext.html,canvas/philip/tests/toDataURL.png.complexcolours.html,canvas/philip/tests/toDataURL.png.html,canvas/philip/tests/toDataURL.png.primarycolours.html,canvas/philip/tests/toDataURL.unrecognised.html,compositing/overflow/image-load-overflow-scrollbars.html,compositing/overflow/invisible-descendants-should-not-affect-opt-in.html,compositing/tiling/huge-layer-img.html,css2.1/20110323/inline-replaced-width-014.htm,css2.1/t0905-c414-flt-wrap-01-d-g.html,fast/backgrounds/bgCompositeCopy.html,fast/canvas/canvas-blending-color-over-image.html,fast/canvas/canvas-blending-color-over-pattern.html,fast/canvas/canvas-blending-gradient-over-image.html,fast/canvas/canvas-blending-gradient-over-pattern.html,fast/canvas/canvas-blending-image-over-color.html,fast/canvas/canvas-blending-image-over-gradient.html,fast/canvas/canvas-blending-image-over-image.html,fast/canvas/canvas-blending-image-over-pattern.html,fast/canvas/canvas-blending-pattern-over-color.html,fast/canvas/canvas-blending-pattern-over-gradient.html,fast/canvas/canvas-blending-pattern-over-image.html,fast/canvas/canvas-blending-pattern-over-pattern.html,fast/canvas/canvas-createImageBitmap-drawImage.html,fast/canvas/canvas-createImageBitmap-immutable.html,fast/canvas/canvas-createImageBitmap-invalid-args.html,fast/canvas/canvas-createImageBitmap-out-of-bounds-src.html,fast/canvas/canvas-createImageBitmap-recursive.html,fast/canvas/canvas-createPattern-fillRect-shadow.html,fast/canvas/canvas-drawImage-out-of-bounds-src.html,fast/canvas/canvas-drawImage-shadow.html,fast/canvas/canvas-scale-drawImage-shadow.html,fast/canvas/canvas-toDataURL-case-insensitive-mimetype.html,fast/canvas/check-stale-putImageData.html,fast/canvas/toDataURL-alpha.html,fast/canvas/toDataURL-supportedTypes.html,fast/canvas/webgl/gl-teximage.html,fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgb565.html,fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgba4444.html,fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgba5551.html,fast/canvas/webgl/tex-image-and-sub-image-2d-with-image.html,fast/css/color-correction-on-backgrounds.html,fast/css/color-correction.html,fast/images/paint-subrect-grid.html,fast/images/png-suite/test.html,fast/images/png-with-color-profile.html,fast/images/rgb-png-with-cmyk-color-profile.html,inspector/profiler/canvas2d/canvas-get-resource-state.html,inspector/profiler/webgl/webgl-get-resource-state.html,svg/W3C-SVG-1.1/filters-blend-01-b.svg,svg/W3C-SVG-1.1/masking-path-04-b.svg,svg/dynamic-updates/SVGFEBlendElement-dom-in-attr.html,svg/dynamic-updates/SVGFEBlendElement-dom-in2-attr.html,svg/dynamic-updates/SVGFEBlendElement-dom-mode-attr.html,svg/dynamic-updates/SVGFEBlendElement-svgdom-in-prop.html,svg/dynamic-updates/SVGFEBlendElement-svgdom-in2-prop.html,svg/dynamic-updates/SVGFEBlendElement-svgdom-mode-prop.html,virtual/deferred/fast/images/paint-subrect-grid.html,virtual/deferred/fast/images/png-suite/test.html,virtual/deferred/fast/images/png-with-color-profile.html,virtual/deferred/fast/images/rgb-png-with-cmyk-color-profile.html,virtual/gpu/canvas/philip/tests/security.dataURI.html,virtual/gpu/canvas/philip/tests/toDataURL.arguments.1.html,virtual/gpu/canvas/philip/tests/toDataURL.arguments.2.html,virtual/gpu/canvas/philip/tests/toDataURL.arguments.3.html,virtual/gpu/canvas/philip/tests/toDataURL.bogustype.html,virtual/gpu/canvas/philip/tests/toDataURL.default.html,virtual/gpu/canvas/philip/tests/toDataURL.lowercase.ascii.html,virtual/gpu/canvas/philip/tests/toDataURL.lowercase.unicode.html,virtual/gpu/canvas/philip/tests/toDataURL.nocontext.html,virtual/gpu/canvas/philip/tests/toDataURL.png.complexcolours.html,virtual/gpu/canvas/philip/tests/toDataURL.png.html,virtual/gpu/canvas/philip/tests/toDataURL.png.primarycolours.html,virtual/gpu/canvas/philip/tests/toDataURL.unrecognised.html,virtual/gpu/compositedscrolling/overflow/image-load-overflow-scrollbars.html,virtual/gpu/compositedscrolling/overflow/invisible-descendants-should-not-affect-opt-in.html,virtual/gpu/fast/canvas/canvas-blending-color-over-image.html,virtual/gpu/fast/canvas/canvas-blending-color-over-pattern.html,virtual/gpu/fast/canvas/canvas-blending-gradient-over-image.html,virtual/gpu/fast/canvas/canvas-blending-gradient-over-pattern.html,virtual/gpu/fast/canvas/canvas-blending-image-over-color.html,virtual/gpu/fast/canvas/canvas-blending-image-over-gradient.html,virtual/gpu/fast/canvas/canvas-blending-image-over-image.html,virtual/gpu/fast/canvas/canvas-blending-image-over-pattern.html,virtual/gpu/fast/canvas/canvas-blending-pattern-over-color.html,virtual/gpu/fast/canvas/canvas-blending-pattern-over-gradient.html,virtual/gpu/fast/canvas/canvas-blending-pattern-over-image.html,virtual/gpu/fast/canvas/canvas-blending-pattern-over-pattern.html,virtual/gpu/fast/canvas/canvas-createImageBitmap-drawImage.html,virtual/gpu/fast/canvas/canvas-createImageBitmap-immutable.html,virtual/gpu/fast/canvas/canvas-createImageBitmap-invalid-args.html,virtual/gpu/fast/canvas/canvas-createImageBitmap-out-of-bounds-src.html,virtual/gpu/fast/canvas/canvas-createImageBitmap-recursive.html,virtual/gpu/fast/canvas/canvas-createPattern-fillRect-shadow.html,virtual/gpu/fast/canvas/canvas-drawImage-out-of-bounds-src.html,virtual/gpu/fast/canvas/canvas-scale-drawImage-shadow.html,virtual/gpu/fast/canvas/canvas-toDataURL-case-insensitive-mimetype.html,virtual/gpu/fast/canvas/check-stale-putImageData.html,virtual/gpu/fast/canvas/toDataURL-alpha.html,virtual/gpu/fast/canvas/toDataURL-supportedTypes.html,virtual/gpu/fast/canvas/webgl/gl-teximage.html,virtual/gpu/fast/canvas/webgl/premultiplyalpha-test.html,virtual/gpu/fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgb565.html,virtual/gpu/fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgba4444.html,virtual/gpu/fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgba5551.html,virtual/gpu/fast/canvas/webgl/tex-image-and-sub-image-2d-with-image.html,virtual/softwarecompositing/overflow/image-load-overflow-scrollbars.html,virtual/softwarecompositing/overflow/invisible-descendants-should-not-affect-opt-in.html,virtual/softwarecompositing/tiling/huge-layer-img.html
BUG=none
TBR= dominikg@chromium.org, arv@chromium.org
Review URL: https://codereview.chromium.org/23494067
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@224979 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/libpng/pngwtran.c')
-rw-r--r-- | third_party/libpng/pngwtran.c | 225 |
1 files changed, 85 insertions, 140 deletions
diff --git a/third_party/libpng/pngwtran.c b/third_party/libpng/pngwtran.c index 98703f8..0ce9b9b 100644 --- a/third_party/libpng/pngwtran.c +++ b/third_party/libpng/pngwtran.c @@ -1,8 +1,8 @@ /* pngwtran.c - transforms the data in a row for PNG writers * - * Last changed in libpng 1.6.0 [February 14, 2013] - * Copyright (c) 1998-2013 Glenn Randers-Pehrson + * Last changed in libpng 1.2.43 [February 25, 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,16 +11,16 @@ * and license in png.h */ -#include "pngpriv.h" - +#define PNG_INTERNAL +#define PNG_NO_PEDANTIC_WARNINGS +#include "png.h" #ifdef PNG_WRITE_SUPPORTED -#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED /* Transform the data according to the user's wishes. The order of * transformations is significant. */ void /* PRIVATE */ -png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info) +png_do_write_transformations(png_structp png_ptr) { png_debug(1, "in png_do_write_transformations"); @@ -30,65 +30,56 @@ png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info) #ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED if (png_ptr->transformations & PNG_USER_TRANSFORM) if (png_ptr->write_user_transform_fn != NULL) - (*(png_ptr->write_user_transform_fn)) /* User write transform + (*(png_ptr->write_user_transform_fn)) /* User write transform function */ - (png_ptr, /* png_ptr */ - row_info, /* row_info: */ - /* png_uint_32 width; width of row */ - /* png_size_t rowbytes; number of bytes in row */ - /* png_byte color_type; color type of pixels */ - /* png_byte bit_depth; bit depth of samples */ - /* png_byte channels; number of channels (1-4) */ - /* png_byte pixel_depth; bits per pixel (depth*channels) */ - png_ptr->row_buf + 1); /* start of pixel data for row */ + (png_ptr, /* png_ptr */ + &(png_ptr->row_info), /* row_info: */ + /* png_uint_32 width; width of row */ + /* png_uint_32 rowbytes; number of bytes in row */ + /* png_byte color_type; color type of pixels */ + /* png_byte bit_depth; bit depth of samples */ + /* png_byte channels; number of channels (1-4) */ + /* png_byte pixel_depth; bits per pixel (depth*channels) */ + png_ptr->row_buf + 1); /* start of pixel data for row */ #endif - #ifdef PNG_WRITE_FILLER_SUPPORTED if (png_ptr->transformations & PNG_FILLER) - png_do_strip_channel(row_info, png_ptr->row_buf + 1, - !(png_ptr->flags & PNG_FLAG_FILLER_AFTER)); + png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, + png_ptr->flags); #endif - #ifdef PNG_WRITE_PACKSWAP_SUPPORTED if (png_ptr->transformations & PNG_PACKSWAP) - png_do_packswap(row_info, png_ptr->row_buf + 1); + png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif - #ifdef PNG_WRITE_PACK_SUPPORTED if (png_ptr->transformations & PNG_PACK) - png_do_pack(row_info, png_ptr->row_buf + 1, - (png_uint_32)png_ptr->bit_depth); + png_do_pack(&(png_ptr->row_info), png_ptr->row_buf + 1, + (png_uint_32)png_ptr->bit_depth); #endif - #ifdef PNG_WRITE_SWAP_SUPPORTED if (png_ptr->transformations & PNG_SWAP_BYTES) - png_do_swap(row_info, png_ptr->row_buf + 1); + png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif - #ifdef PNG_WRITE_SHIFT_SUPPORTED if (png_ptr->transformations & PNG_SHIFT) - png_do_shift(row_info, png_ptr->row_buf + 1, - &(png_ptr->shift)); + png_do_shift(&(png_ptr->row_info), png_ptr->row_buf + 1, + &(png_ptr->shift)); #endif - #ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED if (png_ptr->transformations & PNG_SWAP_ALPHA) - png_do_write_swap_alpha(row_info, png_ptr->row_buf + 1); + png_do_write_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif - #ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED if (png_ptr->transformations & PNG_INVERT_ALPHA) - png_do_write_invert_alpha(row_info, png_ptr->row_buf + 1); + png_do_write_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif - #ifdef PNG_WRITE_BGR_SUPPORTED if (png_ptr->transformations & PNG_BGR) - png_do_bgr(row_info, png_ptr->row_buf + 1); + png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif - #ifdef PNG_WRITE_INVERT_SUPPORTED if (png_ptr->transformations & PNG_INVERT_MONO) - png_do_invert(row_info, png_ptr->row_buf + 1); + png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif } @@ -103,6 +94,9 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) png_debug(1, "in png_do_pack"); if (row_info->bit_depth == 8 && +#ifdef PNG_USELESS_TESTS_SUPPORTED + row != NULL && row_info != NULL && +#endif row_info->channels == 1) { switch ((int)bit_depth) @@ -123,12 +117,9 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) { if (*sp != 0) v |= mask; - sp++; - if (mask > 1) mask >>= 1; - else { mask = 0x80; @@ -137,13 +128,10 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) v = 0; } } - if (mask != 0x80) *dp = (png_byte)v; - break; } - case 2: { png_bytep sp, dp; @@ -155,14 +143,12 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) dp = row; shift = 6; v = 0; - for (i = 0; i < row_width; i++) { png_byte value; value = (png_byte)(*sp & 0x03); v |= (value << shift); - if (shift == 0) { shift = 6; @@ -170,19 +156,14 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) dp++; v = 0; } - else shift -= 2; - sp++; } - if (shift != 6) *dp = (png_byte)v; - break; } - case 4: { png_bytep sp, dp; @@ -194,7 +175,6 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) dp = row; shift = 4; v = 0; - for (i = 0; i < row_width; i++) { png_byte value; @@ -209,27 +189,20 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) dp++; v = 0; } - else shift -= 4; sp++; } - if (shift != 4) *dp = (png_byte)v; - break; } - - default: - break; } - row_info->bit_depth = (png_byte)bit_depth; row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels); row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, - row_info->width); + row_info->width); } } #endif @@ -243,12 +216,16 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) * data to 0 to 15. */ void /* PRIVATE */ -png_do_shift(png_row_infop row_info, png_bytep row, - png_const_color_8p bit_depth) +png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth) { png_debug(1, "in png_do_shift"); - if (row_info->color_type != PNG_COLOR_TYPE_PALETTE) +#ifdef PNG_USELESS_TESTS_SUPPORTED + if (row != NULL && row_info != NULL && +#else + if ( +#endif + row_info->color_type != PNG_COLOR_TYPE_PALETTE) { int shift_start[4], shift_dec[4]; int channels = 0; @@ -258,23 +235,19 @@ png_do_shift(png_row_infop row_info, png_bytep row, shift_start[channels] = row_info->bit_depth - bit_depth->red; shift_dec[channels] = bit_depth->red; channels++; - shift_start[channels] = row_info->bit_depth - bit_depth->green; shift_dec[channels] = bit_depth->green; channels++; - shift_start[channels] = row_info->bit_depth - bit_depth->blue; shift_dec[channels] = bit_depth->blue; channels++; } - else { shift_start[channels] = row_info->bit_depth - bit_depth->gray; shift_dec[channels] = bit_depth->gray; channels++; } - if (row_info->color_type & PNG_COLOR_MASK_ALPHA) { shift_start[channels] = row_info->bit_depth - bit_depth->alpha; @@ -286,40 +259,33 @@ png_do_shift(png_row_infop row_info, png_bytep row, if (row_info->bit_depth < 8) { png_bytep bp = row; - png_size_t i; - unsigned int mask; - png_size_t row_bytes = row_info->rowbytes; + png_uint_32 i; + png_byte mask; + png_uint_32 row_bytes = row_info->rowbytes; if (bit_depth->gray == 1 && row_info->bit_depth == 2) mask = 0x55; - else if (row_info->bit_depth == 4 && bit_depth->gray == 3) mask = 0x11; - else mask = 0xff; for (i = 0; i < row_bytes; i++, bp++) { + png_uint_16 v; int j; - unsigned int v, out; v = *bp; - out = 0; - + *bp = 0; for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0]) { if (j > 0) - out |= v << j; - + *bp |= (png_byte)((v << j) & 0xff); else - out |= (v >> (-j)) & mask; + *bp |= (png_byte)((v >> (-j)) & mask); } - - *bp = (png_byte)(out & 0xff); } } - else if (row_info->bit_depth == 8) { png_bytep bp = row; @@ -329,26 +295,21 @@ png_do_shift(png_row_infop row_info, png_bytep row, for (i = 0; i < istop; i++, bp++) { - const unsigned int c = i%channels; + png_uint_16 v; int j; - unsigned int v, out; + int c = (int)(i%channels); v = *bp; - out = 0; - + *bp = 0; for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c]) { if (j > 0) - out |= v << j; - + *bp |= (png_byte)((v << j) & 0xff); else - out |= v >> (-j); + *bp |= (png_byte)((v >> (-j)) & 0xff); } - - *bp = (png_byte)(out & 0xff); } } - else { png_bytep bp; @@ -357,22 +318,20 @@ png_do_shift(png_row_infop row_info, png_bytep row, for (bp = row, i = 0; i < istop; i++) { - const unsigned int c = i%channels; + int c = (int)(i%channels); + png_uint_16 value, v; int j; - unsigned int value, v; - v = png_get_uint_16(bp); + v = (png_uint_16)(((png_uint_16)(*bp) << 8) + *(bp + 1)); value = 0; - for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c]) { if (j > 0) - value |= v << j; - + value |= (png_uint_16)((v << j) & (png_uint_16)0xffff); else - value |= v >> (-j); + value |= (png_uint_16)((v >> (-j)) & (png_uint_16)0xffff); } - *bp++ = (png_byte)((value >> 8) & 0xff); + *bp++ = (png_byte)(value >> 8); *bp++ = (png_byte)(value & 0xff); } } @@ -386,16 +345,18 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_write_swap_alpha"); +#ifdef PNG_USELESS_TESTS_SUPPORTED + if (row != NULL && row_info != NULL) +#endif { if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { + /* This converts from ARGB to RGBA */ if (row_info->bit_depth == 8) { - /* This converts from ARGB to RGBA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; - for (i = 0, sp = dp = row; i < row_width; i++) { png_byte save = *(sp++); @@ -405,11 +366,9 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) *(dp++) = save; } } - -#ifdef PNG_WRITE_16BIT_SUPPORTED + /* This converts from AARRGGBB to RRGGBBAA */ else { - /* This converts from AARRGGBB to RRGGBBAA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; @@ -429,14 +388,12 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) *(dp++) = save[1]; } } -#endif /* PNG_WRITE_16BIT_SUPPORTED */ } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { + /* This converts from AG to GA */ if (row_info->bit_depth == 8) { - /* This converts from AG to GA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; @@ -448,11 +405,9 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) *(dp++) = save; } } - -#ifdef PNG_WRITE_16BIT_SUPPORTED + /* This converts from AAGG to GGAA */ else { - /* This converts from AAGG to GGAA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; @@ -468,7 +423,6 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) *(dp++) = save[1]; } } -#endif /* PNG_WRITE_16BIT_SUPPORTED */ } } } @@ -480,16 +434,18 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_write_invert_alpha"); +#ifdef PNG_USELESS_TESTS_SUPPORTED + if (row != NULL && row_info != NULL) +#endif { if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { + /* This inverts the alpha channel in RGBA */ if (row_info->bit_depth == 8) { - /* This inverts the alpha channel in RGBA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; - for (i = 0, sp = dp = row; i < row_width; i++) { /* Does nothing @@ -501,11 +457,9 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) *(dp++) = (png_byte)(255 - *(sp++)); } } - -#ifdef PNG_WRITE_16BIT_SUPPORTED + /* This inverts the alpha channel in RRGGBBAA */ else { - /* This inverts the alpha channel in RRGGBBAA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; @@ -525,14 +479,12 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) *(dp++) = (png_byte)(255 - *(sp++)); } } -#endif /* PNG_WRITE_16BIT_SUPPORTED */ } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { + /* This inverts the alpha channel in GA */ if (row_info->bit_depth == 8) { - /* This inverts the alpha channel in GA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; @@ -543,11 +495,9 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) *(dp++) = (png_byte)(255 - *(sp++)); } } - -#ifdef PNG_WRITE_16BIT_SUPPORTED + /* This inverts the alpha channel in GGAA */ else { - /* This inverts the alpha channel in GGAA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; @@ -563,12 +513,10 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) *(dp++) = (png_byte)(255 - *(sp++)); } } -#endif /* PNG_WRITE_16BIT_SUPPORTED */ } } } #endif -#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */ #ifdef PNG_MNG_FEATURES_SUPPORTED /* Undoes intrapixel differencing */ @@ -577,7 +525,11 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_write_intrapixel"); - if ((row_info->color_type & PNG_COLOR_MASK_COLOR)) + if ( +#ifdef PNG_USELESS_TESTS_SUPPORTED + row != NULL && row_info != NULL && +#endif + (row_info->color_type & PNG_COLOR_MASK_COLOR)) { int bytes_per_pixel; png_uint_32 row_width = row_info->width; @@ -588,21 +540,17 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row) if (row_info->color_type == PNG_COLOR_TYPE_RGB) bytes_per_pixel = 3; - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) bytes_per_pixel = 4; - else return; for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) { - *(rp) = (png_byte)((*rp - *(rp + 1)) & 0xff); - *(rp + 2) = (png_byte)((*(rp + 2) - *(rp + 1)) & 0xff); + *(rp) = (png_byte)((*rp - *(rp+1))&0xff); + *(rp+2) = (png_byte)((*(rp+2) - *(rp+1))&0xff); } } - -#ifdef PNG_WRITE_16BIT_SUPPORTED else if (row_info->bit_depth == 16) { png_bytep rp; @@ -610,27 +558,24 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row) if (row_info->color_type == PNG_COLOR_TYPE_RGB) bytes_per_pixel = 6; - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) bytes_per_pixel = 8; - else return; for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) { - png_uint_32 s0 = (*(rp ) << 8) | *(rp + 1); - png_uint_32 s1 = (*(rp + 2) << 8) | *(rp + 3); - png_uint_32 s2 = (*(rp + 4) << 8) | *(rp + 5); + png_uint_32 s0 = (*(rp ) << 8) | *(rp+1); + png_uint_32 s1 = (*(rp+2) << 8) | *(rp+3); + png_uint_32 s2 = (*(rp+4) << 8) | *(rp+5); png_uint_32 red = (png_uint_32)((s0 - s1) & 0xffffL); png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL); - *(rp ) = (png_byte)((red >> 8) & 0xff); - *(rp + 1) = (png_byte)(red & 0xff); - *(rp + 4) = (png_byte)((blue >> 8) & 0xff); - *(rp + 5) = (png_byte)(blue & 0xff); + *(rp ) = (png_byte)((red >> 8) & 0xff); + *(rp+1) = (png_byte)(red & 0xff); + *(rp+4) = (png_byte)((blue >> 8) & 0xff); + *(rp+5) = (png_byte)(blue & 0xff); } } -#endif /* PNG_WRITE_16BIT_SUPPORTED */ } } #endif /* PNG_MNG_FEATURES_SUPPORTED */ |