/* pngwtran.c - transforms the data in a row for PNG writers
*
* libpng version 1.2.8 - December 3, 2004
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2004 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.)
*/
#define PNG_INTERNAL
#include "png.h"
#ifdef PNG_WRITE_SUPPORTED
/* Transform the data according to the user's wishes. The order of
* transformations is significant.
*/
void /* PRIVATE */
{
return;
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
(png_ptr, /* png_ptr */
/* 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) */
#endif
#if defined(PNG_WRITE_FILLER_SUPPORTED)
#endif
#if defined(PNG_WRITE_PACKSWAP_SUPPORTED)
#endif
#if defined(PNG_WRITE_PACK_SUPPORTED)
#endif
#if defined(PNG_WRITE_SWAP_SUPPORTED)
#endif
#if defined(PNG_WRITE_SHIFT_SUPPORTED)
#endif
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
#endif
#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
#endif
#if defined(PNG_WRITE_BGR_SUPPORTED)
#endif
#if defined(PNG_WRITE_INVERT_SUPPORTED)
#endif
}
#if defined(PNG_WRITE_PACK_SUPPORTED)
/* Pack pixels into bytes. Pass the true bit depth in bit_depth. The
* row_info bit depth should be 8 (one pixel per byte). The channels
* should be 1 (this only happens on grayscale and paletted images).
*/
void /* PRIVATE */
{
#if defined(PNG_USELESS_TESTS_SUPPORTED)
#endif
{
switch ((int)bit_depth)
{
case 1:
{
int mask, v;
png_uint_32 i;
mask = 0x80;
v = 0;
for (i = 0; i < row_width; i++)
{
if (*sp != 0)
v |= mask;
sp++;
if (mask > 1)
mask >>= 1;
else
{
mask = 0x80;
dp++;
v = 0;
}
}
if (mask != 0x80)
break;
}
case 2:
{
int shift, v;
png_uint_32 i;
shift = 6;
v = 0;
for (i = 0; i < row_width; i++)
{
if (shift == 0)
{
shift = 6;
dp++;
v = 0;
}
else
shift -= 2;
sp++;
}
if (shift != 6)
break;
}
case 4:
{
int shift, v;
png_uint_32 i;
shift = 4;
v = 0;
for (i = 0; i < row_width; i++)
{
if (shift == 0)
{
shift = 4;
dp++;
v = 0;
}
else
shift -= 4;
sp++;
}
if (shift != 4)
break;
}
}
}
}
#endif
#if defined(PNG_WRITE_SHIFT_SUPPORTED)
/* Shift pixel values to take advantage of whole range. Pass the
* true number of bits in bit_depth. The row should be packed
* according to row_info->bit_depth. Thus, if you had a row of
* bit depth 4, but the pixels only had values from 0 to 7, you
* would pass 3 as bit_depth, and this routine would translate the
* data to 0 to 15.
*/
void /* PRIVATE */
{
#if defined(PNG_USELESS_TESTS_SUPPORTED)
#else
if (
#endif
{
int channels = 0;
{
channels++;
channels++;
channels++;
}
else
{
channels++;
}
{
channels++;
}
/* with low row depths, could only be grayscale, so one channel */
{
png_uint_32 i;
mask = 0x55;
mask = 0x11;
else
mask = 0xff;
{
png_uint_16 v;
int j;
v = *bp;
*bp = 0;
{
if (j > 0)
else
}
}
}
{
png_uint_32 i;
{
png_uint_16 v;
int j;
int c = (int)(i%channels);
v = *bp;
*bp = 0;
{
if (j > 0)
else
}
}
}
else
{
png_uint_32 i;
{
int c = (int)(i%channels);
png_uint_16 value, v;
int j;
value = 0;
{
if (j > 0)
else
}
}
}
}
}
#endif
#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
void /* PRIVATE */
{
#if defined(PNG_USELESS_TESTS_SUPPORTED)
#endif
{
{
/* This converts from ARGB to RGBA */
{
png_uint_32 i;
{
}
}
/* This converts from AARRGGBB to RRGGBBAA */
else
{
png_uint_32 i;
{
}
}
}
{
/* This converts from AG to GA */
{
png_uint_32 i;
{
}
}
/* This converts from AAGG to GGAA */
else
{
png_uint_32 i;
{
}
}
}
}
}
#endif
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
void /* PRIVATE */
{
#if defined(PNG_USELESS_TESTS_SUPPORTED)
#endif
{
{
/* This inverts the alpha channel in RGBA */
{
png_uint_32 i;
{
}
}
/* This inverts the alpha channel in RRGGBBAA */
else
{
png_uint_32 i;
{
}
}
}
{
/* This inverts the alpha channel in GA */
{
png_uint_32 i;
{
}
}
/* This inverts the alpha channel in GGAA */
else
{
png_uint_32 i;
{
}
}
}
}
}
#endif
#if defined(PNG_MNG_FEATURES_SUPPORTED)
/* undoes intrapixel differencing */
void /* PRIVATE */
{
if (
#if defined(PNG_USELESS_TESTS_SUPPORTED)
#endif
{
int bytes_per_pixel;
{
png_uint_32 i;
bytes_per_pixel = 3;
bytes_per_pixel = 4;
else
return;
{
}
}
{
png_uint_32 i;
bytes_per_pixel = 6;
bytes_per_pixel = 8;
else
return;
{
}
}
}
}
#endif /* PNG_MNG_FEATURES_SUPPORTED */
#endif /* PNG_WRITE_SUPPORTED */