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