fukasawa e60969
fukasawa e60969
/* pngwtran.c - transforms the data in a row for PNG writers
fukasawa e60969
 *
fukasawa e60969
 * Last changed in libpng 1.6.18 [July 23, 2015]
fukasawa e60969
 * Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
fukasawa e60969
 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
fukasawa e60969
 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
fukasawa e60969
 *
fukasawa e60969
 * This code is released under the libpng license.
fukasawa e60969
 * For conditions of distribution and use, see the disclaimer
fukasawa e60969
 * and license in png.h
fukasawa e60969
 */
fukasawa e60969
fukasawa e60969
#include "pngpriv.h"
fukasawa e60969
fukasawa e60969
#ifdef PNG_WRITE_SUPPORTED
fukasawa e60969
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
fukasawa e60969
fukasawa e60969
#ifdef PNG_WRITE_PACK_SUPPORTED
fukasawa e60969
/* Pack pixels into bytes.  Pass the true bit depth in bit_depth.  The
fukasawa e60969
 * row_info bit depth should be 8 (one pixel per byte).  The channels
fukasawa e60969
 * should be 1 (this only happens on grayscale and paletted images).
fukasawa e60969
 */
fukasawa e60969
static void
fukasawa e60969
png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
fukasawa e60969
{
fukasawa e60969
   png_debug(1, "in png_do_pack");
fukasawa e60969
fukasawa e60969
   if (row_info->bit_depth == 8 &&
fukasawa e60969
      row_info->channels == 1)
fukasawa e60969
   {
fukasawa e60969
      switch ((int)bit_depth)
fukasawa e60969
      {
fukasawa e60969
         case 1:
fukasawa e60969
         {
fukasawa e60969
            png_bytep sp, dp;
fukasawa e60969
            int mask, v;
fukasawa e60969
            png_uint_32 i;
fukasawa e60969
            png_uint_32 row_width = row_info->width;
fukasawa e60969
fukasawa e60969
            sp = row;
fukasawa e60969
            dp = row;
fukasawa e60969
            mask = 0x80;
fukasawa e60969
            v = 0;
fukasawa e60969
fukasawa e60969
            for (i = 0; i < row_width; i++)
fukasawa e60969
            {
fukasawa e60969
               if (*sp != 0)
fukasawa e60969
                  v |= mask;
fukasawa e60969
fukasawa e60969
               sp++;
fukasawa e60969
fukasawa e60969
               if (mask > 1)
fukasawa e60969
                  mask >>= 1;
fukasawa e60969
fukasawa e60969
               else
fukasawa e60969
               {
fukasawa e60969
                  mask = 0x80;
fukasawa e60969
                  *dp = (png_byte)v;
fukasawa e60969
                  dp++;
fukasawa e60969
                  v = 0;
fukasawa e60969
               }
fukasawa e60969
            }
fukasawa e60969
fukasawa e60969
            if (mask != 0x80)
fukasawa e60969
               *dp = (png_byte)v;
fukasawa e60969
fukasawa e60969
            break;
fukasawa e60969
         }
fukasawa e60969
fukasawa e60969
         case 2:
fukasawa e60969
         {
fukasawa e60969
            png_bytep sp, dp;
fukasawa e60969
            unsigned int shift;
fukasawa e60969
            int v;
fukasawa e60969
            png_uint_32 i;
fukasawa e60969
            png_uint_32 row_width = row_info->width;
fukasawa e60969
fukasawa e60969
            sp = row;
fukasawa e60969
            dp = row;
fukasawa e60969
            shift = 6;
fukasawa e60969
            v = 0;
fukasawa e60969
fukasawa e60969
            for (i = 0; i < row_width; i++)
fukasawa e60969
            {
fukasawa e60969
               png_byte value;
fukasawa e60969
fukasawa e60969
               value = (png_byte)(*sp & 0x03);
fukasawa e60969
               v |= (value << shift);
fukasawa e60969
fukasawa e60969
               if (shift == 0)
fukasawa e60969
               {
fukasawa e60969
                  shift = 6;
fukasawa e60969
                  *dp = (png_byte)v;
fukasawa e60969
                  dp++;
fukasawa e60969
                  v = 0;
fukasawa e60969
               }
fukasawa e60969
fukasawa e60969
               else
fukasawa e60969
                  shift -= 2;
fukasawa e60969
fukasawa e60969
               sp++;
fukasawa e60969
            }
fukasawa e60969
fukasawa e60969
            if (shift != 6)
fukasawa e60969
               *dp = (png_byte)v;
fukasawa e60969
fukasawa e60969
            break;
fukasawa e60969
         }
fukasawa e60969
fukasawa e60969
         case 4:
fukasawa e60969
         {
fukasawa e60969
            png_bytep sp, dp;
fukasawa e60969
            unsigned int shift;
fukasawa e60969
            int v;
fukasawa e60969
            png_uint_32 i;
fukasawa e60969
            png_uint_32 row_width = row_info->width;
fukasawa e60969
fukasawa e60969
            sp = row;
fukasawa e60969
            dp = row;
fukasawa e60969
            shift = 4;
fukasawa e60969
            v = 0;
fukasawa e60969
fukasawa e60969
            for (i = 0; i < row_width; i++)
fukasawa e60969
            {
fukasawa e60969
               png_byte value;
fukasawa e60969
fukasawa e60969
               value = (png_byte)(*sp & 0x0f);
fukasawa e60969
               v |= (value << shift);
fukasawa e60969
fukasawa e60969
               if (shift == 0)
fukasawa e60969
               {
fukasawa e60969
                  shift = 4;
fukasawa e60969
                  *dp = (png_byte)v;
fukasawa e60969
                  dp++;
fukasawa e60969
                  v = 0;
fukasawa e60969
               }
fukasawa e60969
fukasawa e60969
               else
fukasawa e60969
                  shift -= 4;
fukasawa e60969
fukasawa e60969
               sp++;
fukasawa e60969
            }
fukasawa e60969
fukasawa e60969
            if (shift != 4)
fukasawa e60969
               *dp = (png_byte)v;
fukasawa e60969
fukasawa e60969
            break;
fukasawa e60969
         }
fukasawa e60969
fukasawa e60969
         default:
fukasawa e60969
            break;
fukasawa e60969
      }
fukasawa e60969
fukasawa e60969
      row_info->bit_depth = (png_byte)bit_depth;
fukasawa e60969
      row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels);
fukasawa e60969
      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,
fukasawa e60969
          row_info->width);
fukasawa e60969
   }
fukasawa e60969
}
fukasawa e60969
#endif
fukasawa e60969
fukasawa e60969
#ifdef PNG_WRITE_SHIFT_SUPPORTED
fukasawa e60969
/* Shift pixel values to take advantage of whole range.  Pass the
fukasawa e60969
 * true number of bits in bit_depth.  The row should be packed
fukasawa e60969
 * according to row_info->bit_depth.  Thus, if you had a row of
fukasawa e60969
 * bit depth 4, but the pixels only had values from 0 to 7, you
fukasawa e60969
 * would pass 3 as bit_depth, and this routine would translate the
fukasawa e60969
 * data to 0 to 15.
fukasawa e60969
 */
fukasawa e60969
static void
fukasawa e60969
png_do_shift(png_row_infop row_info, png_bytep row,
fukasawa e60969
    png_const_color_8p bit_depth)
fukasawa e60969
{
fukasawa e60969
   png_debug(1, "in png_do_shift");
fukasawa e60969
fukasawa e60969
   if (row_info->color_type != PNG_COLOR_TYPE_PALETTE)
fukasawa e60969
   {
fukasawa e60969
      int shift_start[4], shift_dec[4];
fukasawa e60969
      int channels = 0;
fukasawa e60969
fukasawa e60969
      if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
fukasawa e60969
      {
fukasawa e60969
         shift_start[channels] = row_info->bit_depth - bit_depth->red;
fukasawa e60969
         shift_dec[channels] = bit_depth->red;
fukasawa e60969
         channels++;
fukasawa e60969
fukasawa e60969
         shift_start[channels] = row_info->bit_depth - bit_depth->green;
fukasawa e60969
         shift_dec[channels] = bit_depth->green;
fukasawa e60969
         channels++;
fukasawa e60969
fukasawa e60969
         shift_start[channels] = row_info->bit_depth - bit_depth->blue;
fukasawa e60969
         shift_dec[channels] = bit_depth->blue;
fukasawa e60969
         channels++;
fukasawa e60969
      }
fukasawa e60969
fukasawa e60969
      else
fukasawa e60969
      {
fukasawa e60969
         shift_start[channels] = row_info->bit_depth - bit_depth->gray;
fukasawa e60969
         shift_dec[channels] = bit_depth->gray;
fukasawa e60969
         channels++;
fukasawa e60969
      }
fukasawa e60969
fukasawa e60969
      if ((row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0)
fukasawa e60969
      {
fukasawa e60969
         shift_start[channels] = row_info->bit_depth - bit_depth->alpha;
fukasawa e60969
         shift_dec[channels] = bit_depth->alpha;
fukasawa e60969
         channels++;
fukasawa e60969
      }
fukasawa e60969
fukasawa e60969
      /* With low row depths, could only be grayscale, so one channel */
fukasawa e60969
      if (row_info->bit_depth < 8)
fukasawa e60969
      {
fukasawa e60969
         png_bytep bp = row;
fukasawa e60969
         png_size_t i;
fukasawa e60969
         unsigned int mask;
fukasawa e60969
         png_size_t row_bytes = row_info->rowbytes;
fukasawa e60969
fukasawa e60969
         if (bit_depth->gray == 1 && row_info->bit_depth == 2)
fukasawa e60969
            mask = 0x55;
fukasawa e60969
fukasawa e60969
         else if (row_info->bit_depth == 4 && bit_depth->gray == 3)
fukasawa e60969
            mask = 0x11;
fukasawa e60969
fukasawa e60969
         else
fukasawa e60969
            mask = 0xff;
fukasawa e60969
fukasawa e60969
         for (i = 0; i < row_bytes; i++, bp++)
fukasawa e60969
         {
fukasawa e60969
            int j;
fukasawa e60969
            unsigned int v, out;
fukasawa e60969
fukasawa e60969
            v = *bp;
fukasawa e60969
            out = 0;
fukasawa e60969
fukasawa e60969
            for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0])
fukasawa e60969
            {
fukasawa e60969
               if (j > 0)
fukasawa e60969
                  out |= v << j;
fukasawa e60969
fukasawa e60969
               else
fukasawa e60969
                  out |= (v >> (-j)) & mask;
fukasawa e60969
            }
fukasawa e60969
fukasawa e60969
            *bp = (png_byte)(out & 0xff);
fukasawa e60969
         }
fukasawa e60969
      }
fukasawa e60969
fukasawa e60969
      else if (row_info->bit_depth == 8)
fukasawa e60969
      {
fukasawa e60969
         png_bytep bp = row;
fukasawa e60969
         png_uint_32 i;
fukasawa e60969
         png_uint_32 istop = channels * row_info->width;
fukasawa e60969
fukasawa e60969
         for (i = 0; i < istop; i++, bp++)
fukasawa e60969
         {
fukasawa e60969
fukasawa e60969
            const unsigned int c = i%channels;
fukasawa e60969
            int j;
fukasawa e60969
            unsigned int v, out;
fukasawa e60969
fukasawa e60969
            v = *bp;
fukasawa e60969
            out = 0;
fukasawa e60969
fukasawa e60969
            for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
fukasawa e60969
            {
fukasawa e60969
               if (j > 0)
fukasawa e60969
                  out |= v << j;
fukasawa e60969
fukasawa e60969
               else
fukasawa e60969
                  out |= v >> (-j);
fukasawa e60969
            }
fukasawa e60969
fukasawa e60969
            *bp = (png_byte)(out & 0xff);
fukasawa e60969
         }
fukasawa e60969
      }
fukasawa e60969
fukasawa e60969
      else
fukasawa e60969
      {
fukasawa e60969
         png_bytep bp;
fukasawa e60969
         png_uint_32 i;
fukasawa e60969
         png_uint_32 istop = channels * row_info->width;
fukasawa e60969
fukasawa e60969
         for (bp = row, i = 0; i < istop; i++)
fukasawa e60969
         {
fukasawa e60969
            const unsigned int c = i%channels;
fukasawa e60969
            int j;
fukasawa e60969
            unsigned int value, v;
fukasawa e60969
fukasawa e60969
            v = png_get_uint_16(bp);
fukasawa e60969
            value = 0;
fukasawa e60969
fukasawa e60969
            for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
fukasawa e60969
            {
fukasawa e60969
               if (j > 0)
fukasawa e60969
                  value |= v << j;
fukasawa e60969
fukasawa e60969
               else
fukasawa e60969
                  value |= v >> (-j);
fukasawa e60969
            }
fukasawa e60969
            *bp++ = (png_byte)((value >> 8) & 0xff);
fukasawa e60969
            *bp++ = (png_byte)(value & 0xff);
fukasawa e60969
         }
fukasawa e60969
      }
fukasawa e60969
   }
fukasawa e60969
}
fukasawa e60969
#endif
fukasawa e60969
fukasawa e60969
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
fukasawa e60969
static void
fukasawa e60969
png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
fukasawa e60969
{
fukasawa e60969
   png_debug(1, "in png_do_write_swap_alpha");
fukasawa e60969
fukasawa e60969
   {
fukasawa e60969
      if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
fukasawa e60969
      {
fukasawa e60969
         if (row_info->bit_depth == 8)
fukasawa e60969
         {
fukasawa e60969
            /* This converts from ARGB to RGBA */
fukasawa e60969
            png_bytep sp, dp;
fukasawa e60969
            png_uint_32 i;
fukasawa e60969
            png_uint_32 row_width = row_info->width;
fukasawa e60969
fukasawa e60969
            for (i = 0, sp = dp = row; i < row_width; i++)
fukasawa e60969
            {
fukasawa e60969
               png_byte save = *(sp++);
fukasawa e60969
               *(dp++) = *(sp++);
fukasawa e60969
               *(dp++) = *(sp++);
fukasawa e60969
               *(dp++) = *(sp++);
fukasawa e60969
               *(dp++) = save;
fukasawa e60969
            }
fukasawa e60969
         }
fukasawa e60969
fukasawa e60969
#ifdef PNG_WRITE_16BIT_SUPPORTED
fukasawa e60969
         else
fukasawa e60969
         {
fukasawa e60969
            /* This converts from AARRGGBB to RRGGBBAA */
fukasawa e60969
            png_bytep sp, dp;
fukasawa e60969
            png_uint_32 i;
fukasawa e60969
            png_uint_32 row_width = row_info->width;
fukasawa e60969
fukasawa e60969
            for (i = 0, sp = dp = row; i < row_width; i++)
fukasawa e60969
            {
fukasawa e60969
               png_byte save[2];
fukasawa e60969
               save[0] = *(sp++);
fukasawa e60969
               save[1] = *(sp++);
fukasawa e60969
               *(dp++) = *(sp++);
fukasawa e60969
               *(dp++) = *(sp++);
fukasawa e60969
               *(dp++) = *(sp++);
fukasawa e60969
               *(dp++) = *(sp++);
fukasawa e60969
               *(dp++) = *(sp++);
fukasawa e60969
               *(dp++) = *(sp++);
fukasawa e60969
               *(dp++) = save[0];
fukasawa e60969
               *(dp++) = save[1];
fukasawa e60969
            }
fukasawa e60969
         }
fukasawa e60969
#endif /* WRITE_16BIT */
fukasawa e60969
      }
fukasawa e60969
fukasawa e60969
      else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
fukasawa e60969
      {
fukasawa e60969
         if (row_info->bit_depth == 8)
fukasawa e60969
         {
fukasawa e60969
            /* This converts from AG to GA */
fukasawa e60969
            png_bytep sp, dp;
fukasawa e60969
            png_uint_32 i;
fukasawa e60969
            png_uint_32 row_width = row_info->width;
fukasawa e60969
fukasawa e60969
            for (i = 0, sp = dp = row; i < row_width; i++)
fukasawa e60969
            {
fukasawa e60969
               png_byte save = *(sp++);
fukasawa e60969
               *(dp++) = *(sp++);
fukasawa e60969
               *(dp++) = save;
fukasawa e60969
            }
fukasawa e60969
         }
fukasawa e60969
fukasawa e60969
#ifdef PNG_WRITE_16BIT_SUPPORTED
fukasawa e60969
         else
fukasawa e60969
         {
fukasawa e60969
            /* This converts from AAGG to GGAA */
fukasawa e60969
            png_bytep sp, dp;
fukasawa e60969
            png_uint_32 i;
fukasawa e60969
            png_uint_32 row_width = row_info->width;
fukasawa e60969
fukasawa e60969
            for (i = 0, sp = dp = row; i < row_width; i++)
fukasawa e60969
            {
fukasawa e60969
               png_byte save[2];
fukasawa e60969
               save[0] = *(sp++);
fukasawa e60969
               save[1] = *(sp++);
fukasawa e60969
               *(dp++) = *(sp++);
fukasawa e60969
               *(dp++) = *(sp++);
fukasawa e60969
               *(dp++) = save[0];
fukasawa e60969
               *(dp++) = save[1];
fukasawa e60969
            }
fukasawa e60969
         }
fukasawa e60969
#endif /* WRITE_16BIT */
fukasawa e60969
      }
fukasawa e60969
   }
fukasawa e60969
}
fukasawa e60969
#endif
fukasawa e60969
fukasawa e60969
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
fukasawa e60969
static void
fukasawa e60969
png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
fukasawa e60969
{
fukasawa e60969
   png_debug(1, "in png_do_write_invert_alpha");
fukasawa e60969
fukasawa e60969
   {
fukasawa e60969
      if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
fukasawa e60969
      {
fukasawa e60969
         if (row_info->bit_depth == 8)
fukasawa e60969
         {
fukasawa e60969
            /* This inverts the alpha channel in RGBA */
fukasawa e60969
            png_bytep sp, dp;
fukasawa e60969
            png_uint_32 i;
fukasawa e60969
            png_uint_32 row_width = row_info->width;
fukasawa e60969
fukasawa e60969
            for (i = 0, sp = dp = row; i < row_width; i++)
fukasawa e60969
            {
fukasawa e60969
               /* Does nothing
fukasawa e60969
               *(dp++) = *(sp++);
fukasawa e60969
               *(dp++) = *(sp++);
fukasawa e60969
               *(dp++) = *(sp++);
fukasawa e60969
               */
fukasawa e60969
               sp+=3; dp = sp;
fukasawa e60969
               *dp = (png_byte)(255 - *(sp++));
fukasawa e60969
            }
fukasawa e60969
         }
fukasawa e60969
fukasawa e60969
#ifdef PNG_WRITE_16BIT_SUPPORTED
fukasawa e60969
         else
fukasawa e60969
         {
fukasawa e60969
            /* This inverts the alpha channel in RRGGBBAA */
fukasawa e60969
            png_bytep sp, dp;
fukasawa e60969
            png_uint_32 i;
fukasawa e60969
            png_uint_32 row_width = row_info->width;
fukasawa e60969
fukasawa e60969
            for (i = 0, sp = dp = row; i < row_width; i++)
fukasawa e60969
            {
fukasawa e60969
               /* Does nothing
fukasawa e60969
               *(dp++) = *(sp++);
fukasawa e60969
               *(dp++) = *(sp++);
fukasawa e60969
               *(dp++) = *(sp++);
fukasawa e60969
               *(dp++) = *(sp++);
fukasawa e60969
               *(dp++) = *(sp++);
fukasawa e60969
               *(dp++) = *(sp++);
fukasawa e60969
               */
fukasawa e60969
               sp+=6; dp = sp;
fukasawa e60969
               *(dp++) = (png_byte)(255 - *(sp++));
fukasawa e60969
               *dp     = (png_byte)(255 - *(sp++));
fukasawa e60969
            }
fukasawa e60969
         }
fukasawa e60969
#endif /* WRITE_16BIT */
fukasawa e60969
      }
fukasawa e60969
fukasawa e60969
      else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
fukasawa e60969
      {
fukasawa e60969
         if (row_info->bit_depth == 8)
fukasawa e60969
         {
fukasawa e60969
            /* This inverts the alpha channel in GA */
fukasawa e60969
            png_bytep sp, dp;
fukasawa e60969
            png_uint_32 i;
fukasawa e60969
            png_uint_32 row_width = row_info->width;
fukasawa e60969
fukasawa e60969
            for (i = 0, sp = dp = row; i < row_width; i++)
fukasawa e60969
            {
fukasawa e60969
               *(dp++) = *(sp++);
fukasawa e60969
               *(dp++) = (png_byte)(255 - *(sp++));
fukasawa e60969
            }
fukasawa e60969
         }
fukasawa e60969
fukasawa e60969
#ifdef PNG_WRITE_16BIT_SUPPORTED
fukasawa e60969
         else
fukasawa e60969
         {
fukasawa e60969
            /* This inverts the alpha channel in GGAA */
fukasawa e60969
            png_bytep sp, dp;
fukasawa e60969
            png_uint_32 i;
fukasawa e60969
            png_uint_32 row_width = row_info->width;
fukasawa e60969
fukasawa e60969
            for (i = 0, sp = dp = row; i < row_width; i++)
fukasawa e60969
            {
fukasawa e60969
               /* Does nothing
fukasawa e60969
               *(dp++) = *(sp++);
fukasawa e60969
               *(dp++) = *(sp++);
fukasawa e60969
               */
fukasawa e60969
               sp+=2; dp = sp;
fukasawa e60969
               *(dp++) = (png_byte)(255 - *(sp++));
fukasawa e60969
               *dp     = (png_byte)(255 - *(sp++));
fukasawa e60969
            }
fukasawa e60969
         }
fukasawa e60969
#endif /* WRITE_16BIT */
fukasawa e60969
      }
fukasawa e60969
   }
fukasawa e60969
}
fukasawa e60969
#endif
fukasawa e60969
fukasawa e60969
/* Transform the data according to the user's wishes.  The order of
fukasawa e60969
 * transformations is significant.
fukasawa e60969
 */
fukasawa e60969
void /* PRIVATE */
fukasawa e60969
png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info)
fukasawa e60969
{
fukasawa e60969
   png_debug(1, "in png_do_write_transformations");
fukasawa e60969
fukasawa e60969
   if (png_ptr == NULL)
fukasawa e60969
      return;
fukasawa e60969
fukasawa e60969
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
fukasawa e60969
   if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
fukasawa e60969
      if (png_ptr->write_user_transform_fn != NULL)
fukasawa e60969
         (*(png_ptr->write_user_transform_fn)) /* User write transform
fukasawa e60969
                                                 function */
fukasawa e60969
             (png_ptr,  /* png_ptr */
fukasawa e60969
             row_info,  /* row_info: */
fukasawa e60969
                /*  png_uint_32 width;       width of row */
fukasawa e60969
                /*  png_size_t rowbytes;     number of bytes in row */
fukasawa e60969
                /*  png_byte color_type;     color type of pixels */
fukasawa e60969
                /*  png_byte bit_depth;      bit depth of samples */
fukasawa e60969
                /*  png_byte channels;       number of channels (1-4) */
fukasawa e60969
                /*  png_byte pixel_depth;    bits per pixel (depth*channels) */
fukasawa e60969
             png_ptr->row_buf + 1);      /* start of pixel data for row */
fukasawa e60969
#endif
fukasawa e60969
fukasawa e60969
#ifdef PNG_WRITE_FILLER_SUPPORTED
fukasawa e60969
   if ((png_ptr->transformations & PNG_FILLER) != 0)
fukasawa e60969
      png_do_strip_channel(row_info, png_ptr->row_buf + 1,
fukasawa e60969
         !(png_ptr->flags & PNG_FLAG_FILLER_AFTER));
fukasawa e60969
#endif
fukasawa e60969
fukasawa e60969
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
fukasawa e60969
   if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
fukasawa e60969
      png_do_packswap(row_info, png_ptr->row_buf + 1);
fukasawa e60969
#endif
fukasawa e60969
fukasawa e60969
#ifdef PNG_WRITE_PACK_SUPPORTED
fukasawa e60969
   if ((png_ptr->transformations & PNG_PACK) != 0)
fukasawa e60969
      png_do_pack(row_info, png_ptr->row_buf + 1,
fukasawa e60969
          (png_uint_32)png_ptr->bit_depth);
fukasawa e60969
#endif
fukasawa e60969
fukasawa e60969
#ifdef PNG_WRITE_SWAP_SUPPORTED
fukasawa e60969
#  ifdef PNG_16BIT_SUPPORTED
fukasawa e60969
   if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0)
fukasawa e60969
      png_do_swap(row_info, png_ptr->row_buf + 1);
fukasawa e60969
#  endif
fukasawa e60969
#endif
fukasawa e60969
fukasawa e60969
#ifdef PNG_WRITE_SHIFT_SUPPORTED
fukasawa e60969
   if ((png_ptr->transformations & PNG_SHIFT) != 0)
fukasawa e60969
      png_do_shift(row_info, png_ptr->row_buf + 1,
fukasawa e60969
          &(png_ptr->shift));
fukasawa e60969
#endif
fukasawa e60969
fukasawa e60969
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
fukasawa e60969
   if ((png_ptr->transformations & PNG_SWAP_ALPHA) != 0)
fukasawa e60969
      png_do_write_swap_alpha(row_info, png_ptr->row_buf + 1);
fukasawa e60969
#endif
fukasawa e60969
fukasawa e60969
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
fukasawa e60969
   if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0)
fukasawa e60969
      png_do_write_invert_alpha(row_info, png_ptr->row_buf + 1);
fukasawa e60969
#endif
fukasawa e60969
fukasawa e60969
#ifdef PNG_WRITE_BGR_SUPPORTED
fukasawa e60969
   if ((png_ptr->transformations & PNG_BGR) != 0)
fukasawa e60969
      png_do_bgr(row_info, png_ptr->row_buf + 1);
fukasawa e60969
#endif
fukasawa e60969
fukasawa e60969
#ifdef PNG_WRITE_INVERT_SUPPORTED
fukasawa e60969
   if ((png_ptr->transformations & PNG_INVERT_MONO) != 0)
fukasawa e60969
      png_do_invert(row_info, png_ptr->row_buf + 1);
fukasawa e60969
#endif
fukasawa e60969
}
fukasawa e60969
#endif /* WRITE_TRANSFORMS */
fukasawa e60969
#endif /* WRITE */