nuclear@14: nuclear@14: /* pngwtran.c - transforms the data in a row for PNG writers nuclear@14: * nuclear@14: * Last changed in libpng 1.2.9 April 14, 2006 nuclear@14: * For conditions of distribution and use, see copyright notice in png.h nuclear@14: * Copyright (c) 1998-2006 Glenn Randers-Pehrson nuclear@14: * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) nuclear@14: * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) nuclear@14: */ nuclear@14: nuclear@14: #define PNG_INTERNAL nuclear@14: #include "png.h" nuclear@14: #ifdef PNG_WRITE_SUPPORTED nuclear@14: nuclear@14: /* Transform the data according to the user's wishes. The order of nuclear@14: * transformations is significant. nuclear@14: */ nuclear@14: void /* PRIVATE */ nuclear@14: png_do_write_transformations(png_structp png_ptr) nuclear@14: { nuclear@14: png_debug(1, "in png_do_write_transformations\n"); nuclear@14: nuclear@14: if (png_ptr == NULL) nuclear@14: return; nuclear@14: nuclear@14: #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) nuclear@14: if (png_ptr->transformations & PNG_USER_TRANSFORM) nuclear@14: if (png_ptr->write_user_transform_fn != NULL) nuclear@14: (*(png_ptr->write_user_transform_fn)) /* user write transform function */ nuclear@14: (png_ptr, /* png_ptr */ nuclear@14: &(png_ptr->row_info), /* row_info: */ nuclear@14: /* png_uint_32 width; width of row */ nuclear@14: /* png_uint_32 rowbytes; number of bytes in row */ nuclear@14: /* png_byte color_type; color type of pixels */ nuclear@14: /* png_byte bit_depth; bit depth of samples */ nuclear@14: /* png_byte channels; number of channels (1-4) */ nuclear@14: /* png_byte pixel_depth; bits per pixel (depth*channels) */ nuclear@14: png_ptr->row_buf + 1); /* start of pixel data for row */ nuclear@14: #endif nuclear@14: #if defined(PNG_WRITE_FILLER_SUPPORTED) nuclear@14: if (png_ptr->transformations & PNG_FILLER) nuclear@14: png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, nuclear@14: png_ptr->flags); nuclear@14: #endif nuclear@14: #if defined(PNG_WRITE_PACKSWAP_SUPPORTED) nuclear@14: if (png_ptr->transformations & PNG_PACKSWAP) nuclear@14: png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1); nuclear@14: #endif nuclear@14: #if defined(PNG_WRITE_PACK_SUPPORTED) nuclear@14: if (png_ptr->transformations & PNG_PACK) nuclear@14: png_do_pack(&(png_ptr->row_info), png_ptr->row_buf + 1, nuclear@14: (png_uint_32)png_ptr->bit_depth); nuclear@14: #endif nuclear@14: #if defined(PNG_WRITE_SWAP_SUPPORTED) nuclear@14: if (png_ptr->transformations & PNG_SWAP_BYTES) nuclear@14: png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1); nuclear@14: #endif nuclear@14: #if defined(PNG_WRITE_SHIFT_SUPPORTED) nuclear@14: if (png_ptr->transformations & PNG_SHIFT) nuclear@14: png_do_shift(&(png_ptr->row_info), png_ptr->row_buf + 1, nuclear@14: &(png_ptr->shift)); nuclear@14: #endif nuclear@14: #if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) nuclear@14: if (png_ptr->transformations & PNG_SWAP_ALPHA) nuclear@14: png_do_write_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); nuclear@14: #endif nuclear@14: #if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) nuclear@14: if (png_ptr->transformations & PNG_INVERT_ALPHA) nuclear@14: png_do_write_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); nuclear@14: #endif nuclear@14: #if defined(PNG_WRITE_BGR_SUPPORTED) nuclear@14: if (png_ptr->transformations & PNG_BGR) nuclear@14: png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1); nuclear@14: #endif nuclear@14: #if defined(PNG_WRITE_INVERT_SUPPORTED) nuclear@14: if (png_ptr->transformations & PNG_INVERT_MONO) nuclear@14: png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1); nuclear@14: #endif nuclear@14: } nuclear@14: nuclear@14: #if defined(PNG_WRITE_PACK_SUPPORTED) nuclear@14: /* Pack pixels into bytes. Pass the true bit depth in bit_depth. The nuclear@14: * row_info bit depth should be 8 (one pixel per byte). The channels nuclear@14: * should be 1 (this only happens on grayscale and paletted images). nuclear@14: */ nuclear@14: void /* PRIVATE */ nuclear@14: png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) nuclear@14: { nuclear@14: png_debug(1, "in png_do_pack\n"); nuclear@14: if (row_info->bit_depth == 8 && nuclear@14: #if defined(PNG_USELESS_TESTS_SUPPORTED) nuclear@14: row != NULL && row_info != NULL && nuclear@14: #endif nuclear@14: row_info->channels == 1) nuclear@14: { nuclear@14: switch ((int)bit_depth) nuclear@14: { nuclear@14: case 1: nuclear@14: { nuclear@14: png_bytep sp, dp; nuclear@14: int mask, v; nuclear@14: png_uint_32 i; nuclear@14: png_uint_32 row_width = row_info->width; nuclear@14: nuclear@14: sp = row; nuclear@14: dp = row; nuclear@14: mask = 0x80; nuclear@14: v = 0; nuclear@14: nuclear@14: for (i = 0; i < row_width; i++) nuclear@14: { nuclear@14: if (*sp != 0) nuclear@14: v |= mask; nuclear@14: sp++; nuclear@14: if (mask > 1) nuclear@14: mask >>= 1; nuclear@14: else nuclear@14: { nuclear@14: mask = 0x80; nuclear@14: *dp = (png_byte)v; nuclear@14: dp++; nuclear@14: v = 0; nuclear@14: } nuclear@14: } nuclear@14: if (mask != 0x80) nuclear@14: *dp = (png_byte)v; nuclear@14: break; nuclear@14: } nuclear@14: case 2: nuclear@14: { nuclear@14: png_bytep sp, dp; nuclear@14: int shift, v; nuclear@14: png_uint_32 i; nuclear@14: png_uint_32 row_width = row_info->width; nuclear@14: nuclear@14: sp = row; nuclear@14: dp = row; nuclear@14: shift = 6; nuclear@14: v = 0; nuclear@14: for (i = 0; i < row_width; i++) nuclear@14: { nuclear@14: png_byte value; nuclear@14: nuclear@14: value = (png_byte)(*sp & 0x03); nuclear@14: v |= (value << shift); nuclear@14: if (shift == 0) nuclear@14: { nuclear@14: shift = 6; nuclear@14: *dp = (png_byte)v; nuclear@14: dp++; nuclear@14: v = 0; nuclear@14: } nuclear@14: else nuclear@14: shift -= 2; nuclear@14: sp++; nuclear@14: } nuclear@14: if (shift != 6) nuclear@14: *dp = (png_byte)v; nuclear@14: break; nuclear@14: } nuclear@14: case 4: nuclear@14: { nuclear@14: png_bytep sp, dp; nuclear@14: int shift, v; nuclear@14: png_uint_32 i; nuclear@14: png_uint_32 row_width = row_info->width; nuclear@14: nuclear@14: sp = row; nuclear@14: dp = row; nuclear@14: shift = 4; nuclear@14: v = 0; nuclear@14: for (i = 0; i < row_width; i++) nuclear@14: { nuclear@14: png_byte value; nuclear@14: nuclear@14: value = (png_byte)(*sp & 0x0f); nuclear@14: v |= (value << shift); nuclear@14: nuclear@14: if (shift == 0) nuclear@14: { nuclear@14: shift = 4; nuclear@14: *dp = (png_byte)v; nuclear@14: dp++; nuclear@14: v = 0; nuclear@14: } nuclear@14: else nuclear@14: shift -= 4; nuclear@14: nuclear@14: sp++; nuclear@14: } nuclear@14: if (shift != 4) nuclear@14: *dp = (png_byte)v; nuclear@14: break; nuclear@14: } nuclear@14: } nuclear@14: row_info->bit_depth = (png_byte)bit_depth; nuclear@14: row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels); nuclear@14: row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, nuclear@14: row_info->width); nuclear@14: } nuclear@14: } nuclear@14: #endif nuclear@14: nuclear@14: #if defined(PNG_WRITE_SHIFT_SUPPORTED) nuclear@14: /* Shift pixel values to take advantage of whole range. Pass the nuclear@14: * true number of bits in bit_depth. The row should be packed nuclear@14: * according to row_info->bit_depth. Thus, if you had a row of nuclear@14: * bit depth 4, but the pixels only had values from 0 to 7, you nuclear@14: * would pass 3 as bit_depth, and this routine would translate the nuclear@14: * data to 0 to 15. nuclear@14: */ nuclear@14: void /* PRIVATE */ nuclear@14: png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth) nuclear@14: { nuclear@14: png_debug(1, "in png_do_shift\n"); nuclear@14: #if defined(PNG_USELESS_TESTS_SUPPORTED) nuclear@14: if (row != NULL && row_info != NULL && nuclear@14: #else nuclear@14: if ( nuclear@14: #endif nuclear@14: row_info->color_type != PNG_COLOR_TYPE_PALETTE) nuclear@14: { nuclear@14: int shift_start[4], shift_dec[4]; nuclear@14: int channels = 0; nuclear@14: nuclear@14: if (row_info->color_type & PNG_COLOR_MASK_COLOR) nuclear@14: { nuclear@14: shift_start[channels] = row_info->bit_depth - bit_depth->red; nuclear@14: shift_dec[channels] = bit_depth->red; nuclear@14: channels++; nuclear@14: shift_start[channels] = row_info->bit_depth - bit_depth->green; nuclear@14: shift_dec[channels] = bit_depth->green; nuclear@14: channels++; nuclear@14: shift_start[channels] = row_info->bit_depth - bit_depth->blue; nuclear@14: shift_dec[channels] = bit_depth->blue; nuclear@14: channels++; nuclear@14: } nuclear@14: else nuclear@14: { nuclear@14: shift_start[channels] = row_info->bit_depth - bit_depth->gray; nuclear@14: shift_dec[channels] = bit_depth->gray; nuclear@14: channels++; nuclear@14: } nuclear@14: if (row_info->color_type & PNG_COLOR_MASK_ALPHA) nuclear@14: { nuclear@14: shift_start[channels] = row_info->bit_depth - bit_depth->alpha; nuclear@14: shift_dec[channels] = bit_depth->alpha; nuclear@14: channels++; nuclear@14: } nuclear@14: nuclear@14: /* with low row depths, could only be grayscale, so one channel */ nuclear@14: if (row_info->bit_depth < 8) nuclear@14: { nuclear@14: png_bytep bp = row; nuclear@14: png_uint_32 i; nuclear@14: png_byte mask; nuclear@14: png_uint_32 row_bytes = row_info->rowbytes; nuclear@14: nuclear@14: if (bit_depth->gray == 1 && row_info->bit_depth == 2) nuclear@14: mask = 0x55; nuclear@14: else if (row_info->bit_depth == 4 && bit_depth->gray == 3) nuclear@14: mask = 0x11; nuclear@14: else nuclear@14: mask = 0xff; nuclear@14: nuclear@14: for (i = 0; i < row_bytes; i++, bp++) nuclear@14: { nuclear@14: png_uint_16 v; nuclear@14: int j; nuclear@14: nuclear@14: v = *bp; nuclear@14: *bp = 0; nuclear@14: for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0]) nuclear@14: { nuclear@14: if (j > 0) nuclear@14: *bp |= (png_byte)((v << j) & 0xff); nuclear@14: else nuclear@14: *bp |= (png_byte)((v >> (-j)) & mask); nuclear@14: } nuclear@14: } nuclear@14: } nuclear@14: else if (row_info->bit_depth == 8) nuclear@14: { nuclear@14: png_bytep bp = row; nuclear@14: png_uint_32 i; nuclear@14: png_uint_32 istop = channels * row_info->width; nuclear@14: nuclear@14: for (i = 0; i < istop; i++, bp++) nuclear@14: { nuclear@14: nuclear@14: png_uint_16 v; nuclear@14: int j; nuclear@14: int c = (int)(i%channels); nuclear@14: nuclear@14: v = *bp; nuclear@14: *bp = 0; nuclear@14: for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c]) nuclear@14: { nuclear@14: if (j > 0) nuclear@14: *bp |= (png_byte)((v << j) & 0xff); nuclear@14: else nuclear@14: *bp |= (png_byte)((v >> (-j)) & 0xff); nuclear@14: } nuclear@14: } nuclear@14: } nuclear@14: else nuclear@14: { nuclear@14: png_bytep bp; nuclear@14: png_uint_32 i; nuclear@14: png_uint_32 istop = channels * row_info->width; nuclear@14: nuclear@14: for (bp = row, i = 0; i < istop; i++) nuclear@14: { nuclear@14: int c = (int)(i%channels); nuclear@14: png_uint_16 value, v; nuclear@14: int j; nuclear@14: nuclear@14: v = (png_uint_16)(((png_uint_16)(*bp) << 8) + *(bp + 1)); nuclear@14: value = 0; nuclear@14: for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c]) nuclear@14: { nuclear@14: if (j > 0) nuclear@14: value |= (png_uint_16)((v << j) & (png_uint_16)0xffff); nuclear@14: else nuclear@14: value |= (png_uint_16)((v >> (-j)) & (png_uint_16)0xffff); nuclear@14: } nuclear@14: *bp++ = (png_byte)(value >> 8); nuclear@14: *bp++ = (png_byte)(value & 0xff); nuclear@14: } nuclear@14: } nuclear@14: } nuclear@14: } nuclear@14: #endif nuclear@14: nuclear@14: #if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) nuclear@14: void /* PRIVATE */ nuclear@14: png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) nuclear@14: { nuclear@14: png_debug(1, "in png_do_write_swap_alpha\n"); nuclear@14: #if defined(PNG_USELESS_TESTS_SUPPORTED) nuclear@14: if (row != NULL && row_info != NULL) nuclear@14: #endif nuclear@14: { nuclear@14: if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) nuclear@14: { nuclear@14: /* This converts from ARGB to RGBA */ nuclear@14: if (row_info->bit_depth == 8) nuclear@14: { nuclear@14: png_bytep sp, dp; nuclear@14: png_uint_32 i; nuclear@14: png_uint_32 row_width = row_info->width; nuclear@14: for (i = 0, sp = dp = row; i < row_width; i++) nuclear@14: { nuclear@14: png_byte save = *(sp++); nuclear@14: *(dp++) = *(sp++); nuclear@14: *(dp++) = *(sp++); nuclear@14: *(dp++) = *(sp++); nuclear@14: *(dp++) = save; nuclear@14: } nuclear@14: } nuclear@14: /* This converts from AARRGGBB to RRGGBBAA */ nuclear@14: else nuclear@14: { nuclear@14: png_bytep sp, dp; nuclear@14: png_uint_32 i; nuclear@14: png_uint_32 row_width = row_info->width; nuclear@14: nuclear@14: for (i = 0, sp = dp = row; i < row_width; i++) nuclear@14: { nuclear@14: png_byte save[2]; nuclear@14: save[0] = *(sp++); nuclear@14: save[1] = *(sp++); nuclear@14: *(dp++) = *(sp++); nuclear@14: *(dp++) = *(sp++); nuclear@14: *(dp++) = *(sp++); nuclear@14: *(dp++) = *(sp++); nuclear@14: *(dp++) = *(sp++); nuclear@14: *(dp++) = *(sp++); nuclear@14: *(dp++) = save[0]; nuclear@14: *(dp++) = save[1]; nuclear@14: } nuclear@14: } nuclear@14: } nuclear@14: else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) nuclear@14: { nuclear@14: /* This converts from AG to GA */ nuclear@14: if (row_info->bit_depth == 8) nuclear@14: { nuclear@14: png_bytep sp, dp; nuclear@14: png_uint_32 i; nuclear@14: png_uint_32 row_width = row_info->width; nuclear@14: nuclear@14: for (i = 0, sp = dp = row; i < row_width; i++) nuclear@14: { nuclear@14: png_byte save = *(sp++); nuclear@14: *(dp++) = *(sp++); nuclear@14: *(dp++) = save; nuclear@14: } nuclear@14: } nuclear@14: /* This converts from AAGG to GGAA */ nuclear@14: else nuclear@14: { nuclear@14: png_bytep sp, dp; nuclear@14: png_uint_32 i; nuclear@14: png_uint_32 row_width = row_info->width; nuclear@14: nuclear@14: for (i = 0, sp = dp = row; i < row_width; i++) nuclear@14: { nuclear@14: png_byte save[2]; nuclear@14: save[0] = *(sp++); nuclear@14: save[1] = *(sp++); nuclear@14: *(dp++) = *(sp++); nuclear@14: *(dp++) = *(sp++); nuclear@14: *(dp++) = save[0]; nuclear@14: *(dp++) = save[1]; nuclear@14: } nuclear@14: } nuclear@14: } nuclear@14: } nuclear@14: } nuclear@14: #endif nuclear@14: nuclear@14: #if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) nuclear@14: void /* PRIVATE */ nuclear@14: png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) nuclear@14: { nuclear@14: png_debug(1, "in png_do_write_invert_alpha\n"); nuclear@14: #if defined(PNG_USELESS_TESTS_SUPPORTED) nuclear@14: if (row != NULL && row_info != NULL) nuclear@14: #endif nuclear@14: { nuclear@14: if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) nuclear@14: { nuclear@14: /* This inverts the alpha channel in RGBA */ nuclear@14: if (row_info->bit_depth == 8) nuclear@14: { nuclear@14: png_bytep sp, dp; nuclear@14: png_uint_32 i; nuclear@14: png_uint_32 row_width = row_info->width; nuclear@14: for (i = 0, sp = dp = row; i < row_width; i++) nuclear@14: { nuclear@14: /* does nothing nuclear@14: *(dp++) = *(sp++); nuclear@14: *(dp++) = *(sp++); nuclear@14: *(dp++) = *(sp++); nuclear@14: */ nuclear@14: sp+=3; dp = sp; nuclear@14: *(dp++) = (png_byte)(255 - *(sp++)); nuclear@14: } nuclear@14: } nuclear@14: /* This inverts the alpha channel in RRGGBBAA */ nuclear@14: else nuclear@14: { nuclear@14: png_bytep sp, dp; nuclear@14: png_uint_32 i; nuclear@14: png_uint_32 row_width = row_info->width; nuclear@14: nuclear@14: for (i = 0, sp = dp = row; i < row_width; i++) nuclear@14: { nuclear@14: /* does nothing nuclear@14: *(dp++) = *(sp++); nuclear@14: *(dp++) = *(sp++); nuclear@14: *(dp++) = *(sp++); nuclear@14: *(dp++) = *(sp++); nuclear@14: *(dp++) = *(sp++); nuclear@14: *(dp++) = *(sp++); nuclear@14: */ nuclear@14: sp+=6; dp = sp; nuclear@14: *(dp++) = (png_byte)(255 - *(sp++)); nuclear@14: *(dp++) = (png_byte)(255 - *(sp++)); nuclear@14: } nuclear@14: } nuclear@14: } nuclear@14: else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) nuclear@14: { nuclear@14: /* This inverts the alpha channel in GA */ nuclear@14: if (row_info->bit_depth == 8) nuclear@14: { nuclear@14: png_bytep sp, dp; nuclear@14: png_uint_32 i; nuclear@14: png_uint_32 row_width = row_info->width; nuclear@14: nuclear@14: for (i = 0, sp = dp = row; i < row_width; i++) nuclear@14: { nuclear@14: *(dp++) = *(sp++); nuclear@14: *(dp++) = (png_byte)(255 - *(sp++)); nuclear@14: } nuclear@14: } nuclear@14: /* This inverts the alpha channel in GGAA */ nuclear@14: else nuclear@14: { nuclear@14: png_bytep sp, dp; nuclear@14: png_uint_32 i; nuclear@14: png_uint_32 row_width = row_info->width; nuclear@14: nuclear@14: for (i = 0, sp = dp = row; i < row_width; i++) nuclear@14: { nuclear@14: /* does nothing nuclear@14: *(dp++) = *(sp++); nuclear@14: *(dp++) = *(sp++); nuclear@14: */ nuclear@14: sp+=2; dp = sp; nuclear@14: *(dp++) = (png_byte)(255 - *(sp++)); nuclear@14: *(dp++) = (png_byte)(255 - *(sp++)); nuclear@14: } nuclear@14: } nuclear@14: } nuclear@14: } nuclear@14: } nuclear@14: #endif nuclear@14: nuclear@14: #if defined(PNG_MNG_FEATURES_SUPPORTED) nuclear@14: /* undoes intrapixel differencing */ nuclear@14: void /* PRIVATE */ nuclear@14: png_do_write_intrapixel(png_row_infop row_info, png_bytep row) nuclear@14: { nuclear@14: png_debug(1, "in png_do_write_intrapixel\n"); nuclear@14: if ( nuclear@14: #if defined(PNG_USELESS_TESTS_SUPPORTED) nuclear@14: row != NULL && row_info != NULL && nuclear@14: #endif nuclear@14: (row_info->color_type & PNG_COLOR_MASK_COLOR)) nuclear@14: { nuclear@14: int bytes_per_pixel; nuclear@14: png_uint_32 row_width = row_info->width; nuclear@14: if (row_info->bit_depth == 8) nuclear@14: { nuclear@14: png_bytep rp; nuclear@14: png_uint_32 i; nuclear@14: nuclear@14: if (row_info->color_type == PNG_COLOR_TYPE_RGB) nuclear@14: bytes_per_pixel = 3; nuclear@14: else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) nuclear@14: bytes_per_pixel = 4; nuclear@14: else nuclear@14: return; nuclear@14: nuclear@14: for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) nuclear@14: { nuclear@14: *(rp) = (png_byte)((*rp - *(rp+1))&0xff); nuclear@14: *(rp+2) = (png_byte)((*(rp+2) - *(rp+1))&0xff); nuclear@14: } nuclear@14: } nuclear@14: else if (row_info->bit_depth == 16) nuclear@14: { nuclear@14: png_bytep rp; nuclear@14: png_uint_32 i; nuclear@14: nuclear@14: if (row_info->color_type == PNG_COLOR_TYPE_RGB) nuclear@14: bytes_per_pixel = 6; nuclear@14: else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) nuclear@14: bytes_per_pixel = 8; nuclear@14: else nuclear@14: return; nuclear@14: nuclear@14: for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) nuclear@14: { nuclear@14: png_uint_32 s0 = (*(rp ) << 8) | *(rp+1); nuclear@14: png_uint_32 s1 = (*(rp+2) << 8) | *(rp+3); nuclear@14: png_uint_32 s2 = (*(rp+4) << 8) | *(rp+5); nuclear@14: png_uint_32 red = (png_uint_32)((s0 - s1) & 0xffffL); nuclear@14: png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL); nuclear@14: *(rp ) = (png_byte)((red >> 8) & 0xff); nuclear@14: *(rp+1) = (png_byte)(red & 0xff); nuclear@14: *(rp+4) = (png_byte)((blue >> 8) & 0xff); nuclear@14: *(rp+5) = (png_byte)(blue & 0xff); nuclear@14: } nuclear@14: } nuclear@14: } nuclear@14: } nuclear@14: #endif /* PNG_MNG_FEATURES_SUPPORTED */ nuclear@14: #endif /* PNG_WRITE_SUPPORTED */