0N/A/*
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/* pngwtran.c - transforms the data in a row for PNG writers
0N/A *
0N/A * This file is available under and governed by the GNU General Public
0N/A * License version 2 only, as published by the Free Software Foundation.
0N/A * However, the following notice accompanied the original version of this
0N/A * file and, per its terms, should not be removed:
0N/A *
4418N/A * Last changed in libpng 1.5.4 [July 7, 2011]
4418N/A * Copyright (c) 1998-2011 Glenn Randers-Pehrson
0N/A * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
0N/A * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
4418N/A *
4418N/A * This code is released under the libpng license.
4418N/A * For conditions of distribution and use, see the disclaimer
4418N/A * and license in png.h
0N/A */
0N/A
4418N/A#include "pngpriv.h"
4418N/A
0N/A#ifdef PNG_WRITE_SUPPORTED
0N/A
4418N/A#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
0N/A/* Transform the data according to the user's wishes. The order of
0N/A * transformations is significant.
0N/A */
0N/Avoid /* PRIVATE */
0N/Apng_do_write_transformations(png_structp png_ptr)
0N/A{
4418N/A png_debug(1, "in png_do_write_transformations");
0N/A
0N/A if (png_ptr == NULL)
0N/A return;
0N/A
4418N/A#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
0N/A if (png_ptr->transformations & PNG_USER_TRANSFORM)
4418N/A if (png_ptr->write_user_transform_fn != NULL)
4418N/A (*(png_ptr->write_user_transform_fn)) /* User write transform
4418N/A function */
4418N/A (png_ptr, /* png_ptr */
4418N/A &(png_ptr->row_info), /* row_info: */
4418N/A /* png_uint_32 width; width of row */
4418N/A /* png_size_t rowbytes; number of bytes in row */
4418N/A /* png_byte color_type; color type of pixels */
4418N/A /* png_byte bit_depth; bit depth of samples */
4418N/A /* png_byte channels; number of channels (1-4) */
4418N/A /* png_byte pixel_depth; bits per pixel (depth*channels) */
4418N/A png_ptr->row_buf + 1); /* start of pixel data for row */
0N/A#endif
4418N/A
4418N/A#ifdef PNG_WRITE_FILLER_SUPPORTED
0N/A if (png_ptr->transformations & PNG_FILLER)
4418N/A png_do_strip_channel(&(png_ptr->row_info), png_ptr->row_buf + 1,
4418N/A !(png_ptr->flags & PNG_FLAG_FILLER_AFTER));
0N/A#endif
4418N/A
4418N/A#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
0N/A if (png_ptr->transformations & PNG_PACKSWAP)
0N/A png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1);
0N/A#endif
4418N/A
4418N/A#ifdef PNG_WRITE_PACK_SUPPORTED
0N/A if (png_ptr->transformations & PNG_PACK)
0N/A png_do_pack(&(png_ptr->row_info), png_ptr->row_buf + 1,
4418N/A (png_uint_32)png_ptr->bit_depth);
0N/A#endif
4418N/A
4418N/A#ifdef PNG_WRITE_SWAP_SUPPORTED
0N/A if (png_ptr->transformations & PNG_SWAP_BYTES)
0N/A png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1);
0N/A#endif
4418N/A
4418N/A#ifdef PNG_WRITE_SHIFT_SUPPORTED
0N/A if (png_ptr->transformations & PNG_SHIFT)
0N/A png_do_shift(&(png_ptr->row_info), png_ptr->row_buf + 1,
4418N/A &(png_ptr->shift));
0N/A#endif
4418N/A
4418N/A#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
0N/A if (png_ptr->transformations & PNG_SWAP_ALPHA)
0N/A png_do_write_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
0N/A#endif
4418N/A
4418N/A#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
0N/A if (png_ptr->transformations & PNG_INVERT_ALPHA)
0N/A png_do_write_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
0N/A#endif
4418N/A
4418N/A#ifdef PNG_WRITE_BGR_SUPPORTED
0N/A if (png_ptr->transformations & PNG_BGR)
0N/A png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1);
0N/A#endif
4418N/A
4418N/A#ifdef PNG_WRITE_INVERT_SUPPORTED
0N/A if (png_ptr->transformations & PNG_INVERT_MONO)
0N/A png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1);
0N/A#endif
0N/A}
0N/A
4418N/A#ifdef PNG_WRITE_PACK_SUPPORTED
0N/A/* Pack pixels into bytes. Pass the true bit depth in bit_depth. The
0N/A * row_info bit depth should be 8 (one pixel per byte). The channels
0N/A * should be 1 (this only happens on grayscale and paletted images).
0N/A */
0N/Avoid /* PRIVATE */
0N/Apng_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
0N/A{
4418N/A png_debug(1, "in png_do_pack");
4418N/A
0N/A if (row_info->bit_depth == 8 &&
0N/A row_info->channels == 1)
0N/A {
0N/A switch ((int)bit_depth)
0N/A {
0N/A case 1:
0N/A {
0N/A png_bytep sp, dp;
0N/A int mask, v;
0N/A png_uint_32 i;
0N/A png_uint_32 row_width = row_info->width;
0N/A
0N/A sp = row;
0N/A dp = row;
0N/A mask = 0x80;
0N/A v = 0;
0N/A
0N/A for (i = 0; i < row_width; i++)
0N/A {
0N/A if (*sp != 0)
0N/A v |= mask;
4418N/A
0N/A sp++;
4418N/A
0N/A if (mask > 1)
0N/A mask >>= 1;
4418N/A
0N/A else
0N/A {
0N/A mask = 0x80;
0N/A *dp = (png_byte)v;
0N/A dp++;
0N/A v = 0;
0N/A }
0N/A }
4418N/A
0N/A if (mask != 0x80)
0N/A *dp = (png_byte)v;
4418N/A
0N/A break;
0N/A }
4418N/A
0N/A case 2:
0N/A {
0N/A png_bytep sp, dp;
0N/A int shift, v;
0N/A png_uint_32 i;
0N/A png_uint_32 row_width = row_info->width;
0N/A
0N/A sp = row;
0N/A dp = row;
0N/A shift = 6;
0N/A v = 0;
4418N/A
0N/A for (i = 0; i < row_width; i++)
0N/A {
0N/A png_byte value;
0N/A
0N/A value = (png_byte)(*sp & 0x03);
0N/A v |= (value << shift);
4418N/A
0N/A if (shift == 0)
0N/A {
0N/A shift = 6;
0N/A *dp = (png_byte)v;
0N/A dp++;
0N/A v = 0;
0N/A }
4418N/A
0N/A else
0N/A shift -= 2;
4418N/A
0N/A sp++;
0N/A }
4418N/A
0N/A if (shift != 6)
0N/A *dp = (png_byte)v;
4418N/A
0N/A break;
0N/A }
4418N/A
0N/A case 4:
0N/A {
0N/A png_bytep sp, dp;
0N/A int shift, v;
0N/A png_uint_32 i;
0N/A png_uint_32 row_width = row_info->width;
0N/A
0N/A sp = row;
0N/A dp = row;
0N/A shift = 4;
0N/A v = 0;
4418N/A
0N/A for (i = 0; i < row_width; i++)
0N/A {
0N/A png_byte value;
0N/A
0N/A value = (png_byte)(*sp & 0x0f);
0N/A v |= (value << shift);
0N/A
0N/A if (shift == 0)
0N/A {
0N/A shift = 4;
0N/A *dp = (png_byte)v;
0N/A dp++;
0N/A v = 0;
0N/A }
4418N/A
0N/A else
0N/A shift -= 4;
0N/A
0N/A sp++;
0N/A }
4418N/A
0N/A if (shift != 4)
0N/A *dp = (png_byte)v;
4418N/A
0N/A break;
0N/A }
4418N/A
4418N/A default:
4418N/A break;
0N/A }
4418N/A
0N/A row_info->bit_depth = (png_byte)bit_depth;
0N/A row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels);
0N/A row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,
4418N/A row_info->width);
0N/A }
0N/A}
0N/A#endif
0N/A
4418N/A#ifdef PNG_WRITE_SHIFT_SUPPORTED
0N/A/* Shift pixel values to take advantage of whole range. Pass the
0N/A * true number of bits in bit_depth. The row should be packed
0N/A * according to row_info->bit_depth. Thus, if you had a row of
0N/A * bit depth 4, but the pixels only had values from 0 to 7, you
0N/A * would pass 3 as bit_depth, and this routine would translate the
0N/A * data to 0 to 15.
0N/A */
0N/Avoid /* PRIVATE */
4418N/Apng_do_shift(png_row_infop row_info, png_bytep row,
4418N/A png_const_color_8p bit_depth)
0N/A{
4418N/A png_debug(1, "in png_do_shift");
4418N/A
4418N/A if (row_info->color_type != PNG_COLOR_TYPE_PALETTE)
0N/A {
0N/A int shift_start[4], shift_dec[4];
0N/A int channels = 0;
0N/A
0N/A if (row_info->color_type & PNG_COLOR_MASK_COLOR)
0N/A {
0N/A shift_start[channels] = row_info->bit_depth - bit_depth->red;
0N/A shift_dec[channels] = bit_depth->red;
0N/A channels++;
4418N/A
0N/A shift_start[channels] = row_info->bit_depth - bit_depth->green;
0N/A shift_dec[channels] = bit_depth->green;
0N/A channels++;
4418N/A
0N/A shift_start[channels] = row_info->bit_depth - bit_depth->blue;
0N/A shift_dec[channels] = bit_depth->blue;
0N/A channels++;
0N/A }
4418N/A
0N/A else
0N/A {
0N/A shift_start[channels] = row_info->bit_depth - bit_depth->gray;
0N/A shift_dec[channels] = bit_depth->gray;
0N/A channels++;
0N/A }
4418N/A
0N/A if (row_info->color_type & PNG_COLOR_MASK_ALPHA)
0N/A {
0N/A shift_start[channels] = row_info->bit_depth - bit_depth->alpha;
0N/A shift_dec[channels] = bit_depth->alpha;
0N/A channels++;
0N/A }
0N/A
4418N/A /* With low row depths, could only be grayscale, so one channel */
0N/A if (row_info->bit_depth < 8)
0N/A {
0N/A png_bytep bp = row;
4418N/A png_size_t i;
0N/A png_byte mask;
4418N/A png_size_t row_bytes = row_info->rowbytes;
0N/A
0N/A if (bit_depth->gray == 1 && row_info->bit_depth == 2)
0N/A mask = 0x55;
4418N/A
0N/A else if (row_info->bit_depth == 4 && bit_depth->gray == 3)
0N/A mask = 0x11;
4418N/A
0N/A else
0N/A mask = 0xff;
0N/A
0N/A for (i = 0; i < row_bytes; i++, bp++)
0N/A {
0N/A png_uint_16 v;
0N/A int j;
0N/A
0N/A v = *bp;
0N/A *bp = 0;
4418N/A
0N/A for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0])
0N/A {
0N/A if (j > 0)
0N/A *bp |= (png_byte)((v << j) & 0xff);
4418N/A
0N/A else
0N/A *bp |= (png_byte)((v >> (-j)) & mask);
0N/A }
0N/A }
0N/A }
4418N/A
0N/A else if (row_info->bit_depth == 8)
0N/A {
0N/A png_bytep bp = row;
0N/A png_uint_32 i;
0N/A png_uint_32 istop = channels * row_info->width;
0N/A
0N/A for (i = 0; i < istop; i++, bp++)
0N/A {
0N/A
0N/A png_uint_16 v;
0N/A int j;
0N/A int c = (int)(i%channels);
0N/A
0N/A v = *bp;
0N/A *bp = 0;
4418N/A
0N/A for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
0N/A {
0N/A if (j > 0)
0N/A *bp |= (png_byte)((v << j) & 0xff);
4418N/A
0N/A else
0N/A *bp |= (png_byte)((v >> (-j)) & 0xff);
0N/A }
0N/A }
0N/A }
4418N/A
0N/A else
0N/A {
0N/A png_bytep bp;
0N/A png_uint_32 i;
0N/A png_uint_32 istop = channels * row_info->width;
0N/A
0N/A for (bp = row, i = 0; i < istop; i++)
0N/A {
0N/A int c = (int)(i%channels);
0N/A png_uint_16 value, v;
0N/A int j;
0N/A
0N/A v = (png_uint_16)(((png_uint_16)(*bp) << 8) + *(bp + 1));
0N/A value = 0;
4418N/A
0N/A for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
0N/A {
0N/A if (j > 0)
0N/A value |= (png_uint_16)((v << j) & (png_uint_16)0xffff);
4418N/A
0N/A else
0N/A value |= (png_uint_16)((v >> (-j)) & (png_uint_16)0xffff);
0N/A }
0N/A *bp++ = (png_byte)(value >> 8);
0N/A *bp++ = (png_byte)(value & 0xff);
0N/A }
0N/A }
0N/A }
0N/A}
0N/A#endif
0N/A
4418N/A#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
0N/Avoid /* PRIVATE */
0N/Apng_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
0N/A{
4418N/A png_debug(1, "in png_do_write_swap_alpha");
4418N/A
0N/A {
0N/A if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
0N/A {
0N/A if (row_info->bit_depth == 8)
0N/A {
4418N/A /* This converts from ARGB to RGBA */
0N/A png_bytep sp, dp;
0N/A png_uint_32 i;
0N/A png_uint_32 row_width = row_info->width;
4418N/A
0N/A for (i = 0, sp = dp = row; i < row_width; i++)
0N/A {
0N/A png_byte save = *(sp++);
0N/A *(dp++) = *(sp++);
0N/A *(dp++) = *(sp++);
0N/A *(dp++) = *(sp++);
0N/A *(dp++) = save;
0N/A }
0N/A }
4418N/A
4418N/A#ifdef PNG_WRITE_16BIT_SUPPORTED
0N/A else
0N/A {
4418N/A /* This converts from AARRGGBB to RRGGBBAA */
0N/A png_bytep sp, dp;
0N/A png_uint_32 i;
0N/A png_uint_32 row_width = row_info->width;
0N/A
0N/A for (i = 0, sp = dp = row; i < row_width; i++)
0N/A {
0N/A png_byte save[2];
0N/A save[0] = *(sp++);
0N/A save[1] = *(sp++);
0N/A *(dp++) = *(sp++);
0N/A *(dp++) = *(sp++);
0N/A *(dp++) = *(sp++);
0N/A *(dp++) = *(sp++);
0N/A *(dp++) = *(sp++);
0N/A *(dp++) = *(sp++);
0N/A *(dp++) = save[0];
0N/A *(dp++) = save[1];
0N/A }
0N/A }
4418N/A#endif /* PNG_WRITE_16BIT_SUPPORTED */
0N/A }
4418N/A
0N/A else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
0N/A {
0N/A if (row_info->bit_depth == 8)
0N/A {
4418N/A /* This converts from AG to GA */
0N/A png_bytep sp, dp;
0N/A png_uint_32 i;
0N/A png_uint_32 row_width = row_info->width;
0N/A
0N/A for (i = 0, sp = dp = row; i < row_width; i++)
0N/A {
0N/A png_byte save = *(sp++);
0N/A *(dp++) = *(sp++);
0N/A *(dp++) = save;
0N/A }
0N/A }
4418N/A
4418N/A#ifdef PNG_WRITE_16BIT_SUPPORTED
0N/A else
0N/A {
4418N/A /* This converts from AAGG to GGAA */
0N/A png_bytep sp, dp;
0N/A png_uint_32 i;
0N/A png_uint_32 row_width = row_info->width;
0N/A
0N/A for (i = 0, sp = dp = row; i < row_width; i++)
0N/A {
0N/A png_byte save[2];
0N/A save[0] = *(sp++);
0N/A save[1] = *(sp++);
0N/A *(dp++) = *(sp++);
0N/A *(dp++) = *(sp++);
0N/A *(dp++) = save[0];
0N/A *(dp++) = save[1];
0N/A }
0N/A }
4418N/A#endif /* PNG_WRITE_16BIT_SUPPORTED */
0N/A }
0N/A }
0N/A}
0N/A#endif
0N/A
4418N/A#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
0N/Avoid /* PRIVATE */
0N/Apng_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
0N/A{
4418N/A png_debug(1, "in png_do_write_invert_alpha");
4418N/A
0N/A {
0N/A if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
0N/A {
0N/A if (row_info->bit_depth == 8)
0N/A {
4418N/A /* This inverts the alpha channel in RGBA */
0N/A png_bytep sp, dp;
0N/A png_uint_32 i;
0N/A png_uint_32 row_width = row_info->width;
4418N/A
0N/A for (i = 0, sp = dp = row; i < row_width; i++)
0N/A {
4418N/A /* Does nothing
0N/A *(dp++) = *(sp++);
0N/A *(dp++) = *(sp++);
0N/A *(dp++) = *(sp++);
0N/A */
0N/A sp+=3; dp = sp;
0N/A *(dp++) = (png_byte)(255 - *(sp++));
0N/A }
0N/A }
4418N/A
4418N/A#ifdef PNG_WRITE_16BIT_SUPPORTED
0N/A else
0N/A {
4418N/A /* This inverts the alpha channel in RRGGBBAA */
0N/A png_bytep sp, dp;
0N/A png_uint_32 i;
0N/A png_uint_32 row_width = row_info->width;
0N/A
0N/A for (i = 0, sp = dp = row; i < row_width; i++)
0N/A {
4418N/A /* Does nothing
0N/A *(dp++) = *(sp++);
0N/A *(dp++) = *(sp++);
0N/A *(dp++) = *(sp++);
0N/A *(dp++) = *(sp++);
0N/A *(dp++) = *(sp++);
0N/A *(dp++) = *(sp++);
0N/A */
0N/A sp+=6; dp = sp;
0N/A *(dp++) = (png_byte)(255 - *(sp++));
0N/A *(dp++) = (png_byte)(255 - *(sp++));
0N/A }
0N/A }
4418N/A#endif /* PNG_WRITE_16BIT_SUPPORTED */
0N/A }
4418N/A
0N/A else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
0N/A {
0N/A if (row_info->bit_depth == 8)
0N/A {
4418N/A /* This inverts the alpha channel in GA */
0N/A png_bytep sp, dp;
0N/A png_uint_32 i;
0N/A png_uint_32 row_width = row_info->width;
0N/A
0N/A for (i = 0, sp = dp = row; i < row_width; i++)
0N/A {
0N/A *(dp++) = *(sp++);
0N/A *(dp++) = (png_byte)(255 - *(sp++));
0N/A }
0N/A }
4418N/A
4418N/A#ifdef PNG_WRITE_16BIT_SUPPORTED
0N/A else
0N/A {
4418N/A /* This inverts the alpha channel in GGAA */
0N/A png_bytep sp, dp;
0N/A png_uint_32 i;
0N/A png_uint_32 row_width = row_info->width;
0N/A
0N/A for (i = 0, sp = dp = row; i < row_width; i++)
0N/A {
4418N/A /* Does nothing
0N/A *(dp++) = *(sp++);
0N/A *(dp++) = *(sp++);
0N/A */
0N/A sp+=2; dp = sp;
0N/A *(dp++) = (png_byte)(255 - *(sp++));
0N/A *(dp++) = (png_byte)(255 - *(sp++));
0N/A }
0N/A }
4418N/A#endif /* PNG_WRITE_16BIT_SUPPORTED */
0N/A }
0N/A }
0N/A}
0N/A#endif
4418N/A#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
0N/A
4418N/A#ifdef PNG_MNG_FEATURES_SUPPORTED
4418N/A/* Undoes intrapixel differencing */
0N/Avoid /* PRIVATE */
0N/Apng_do_write_intrapixel(png_row_infop row_info, png_bytep row)
0N/A{
4418N/A png_debug(1, "in png_do_write_intrapixel");
4418N/A
4418N/A if ((row_info->color_type & PNG_COLOR_MASK_COLOR))
0N/A {
0N/A int bytes_per_pixel;
0N/A png_uint_32 row_width = row_info->width;
0N/A if (row_info->bit_depth == 8)
0N/A {
0N/A png_bytep rp;
0N/A png_uint_32 i;
0N/A
0N/A if (row_info->color_type == PNG_COLOR_TYPE_RGB)
0N/A bytes_per_pixel = 3;
4418N/A
0N/A else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
0N/A bytes_per_pixel = 4;
4418N/A
0N/A else
0N/A return;
0N/A
0N/A for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
0N/A {
4418N/A *(rp) = (png_byte)((*rp - *(rp + 1)) & 0xff);
4418N/A *(rp + 2) = (png_byte)((*(rp + 2) - *(rp + 1)) & 0xff);
0N/A }
0N/A }
4418N/A
4418N/A#ifdef PNG_WRITE_16BIT_SUPPORTED
0N/A else if (row_info->bit_depth == 16)
0N/A {
0N/A png_bytep rp;
0N/A png_uint_32 i;
0N/A
0N/A if (row_info->color_type == PNG_COLOR_TYPE_RGB)
0N/A bytes_per_pixel = 6;
4418N/A
0N/A else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
0N/A bytes_per_pixel = 8;
4418N/A
0N/A else
0N/A return;
0N/A
0N/A for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
0N/A {
4418N/A png_uint_32 s0 = (*(rp ) << 8) | *(rp + 1);
4418N/A png_uint_32 s1 = (*(rp + 2) << 8) | *(rp + 3);
4418N/A png_uint_32 s2 = (*(rp + 4) << 8) | *(rp + 5);
4418N/A png_uint_32 red = (png_uint_32)((s0 - s1) & 0xffffL);
4418N/A png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL);
4418N/A *(rp ) = (png_byte)((red >> 8) & 0xff);
4418N/A *(rp + 1) = (png_byte)(red & 0xff);
4418N/A *(rp + 4) = (png_byte)((blue >> 8) & 0xff);
4418N/A *(rp + 5) = (png_byte)(blue & 0xff);
0N/A }
0N/A }
4418N/A#endif /* PNG_WRITE_16BIT_SUPPORTED */
0N/A }
0N/A}
0N/A#endif /* PNG_MNG_FEATURES_SUPPORTED */
0N/A#endif /* PNG_WRITE_SUPPORTED */