

      else if (row_info->bit_depth == 4)
         table = fourbppswaptable;

      else
         return;

      for (rp = row; rp < end; rp++)
         *rp = table[*rp];
   }
}
#endif /* PACKSWAP || WRITE_PACKSWAP */

#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
    defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
/* Remove a channel - this used to be 'png_do_strip_filler' but it used a
 * somewhat weird combination of flags to determine what to do.  All the calls
 * to png_do_strip_filler are changed in 1.5.2 to call this instead with the
 * correct arguments.
 *
 * The routine isn't general - the channel must be the channel at the start or
 * end (not in the middle) of each pixel.
 */
void /* PRIVATE */
png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
{
   png_bytep sp = row; /* source pointer */
   png_bytep dp = row; /* destination pointer */
   png_bytep ep = row + row_info->rowbytes; /* One beyond end of row */

   /* At the start sp will point to the first byte to copy and dp to where
    * it is copied to.  ep always points just beyond the end of the row, so
    * the loop simply copies (channels-1) channels until sp reaches ep.
    *
    * at_start:        0 -- convert AG, XG, ARGB, XRGB, AAGG, XXGG, etc.
    *            nonzero -- convert GA, GX, RGBA, RGBX, GGAA, RRGGBBXX, etc.
    */

   /* GA, GX, XG cases */
   if (row_info->channels == 2)
   {
      if (row_info->bit_depth == 8)
      {
         if (at_start!= 0) /* Skip initial filler */
            ++sp;
         else          /* Skip initial channel and, for
else if (row_info->bit_depth = = 4) 
          table = fourbppswaptable; 

       else 
          return; 

       for (rp = row; rp < end; rp++) 
          * rp = table[*rp ]; 
    } 
 } 
 # endif / * PACKSWAP || WRITE_PACKSWAP * / 

 # if defined(PNG_WRITE_FILLER_SUPPORTED) || \ 
     defined(PNG_READ_STRIP_ALPHA_SUPPORTED) 
 / * absent a distribution channel - this used to be' png_do_strip_filler' but it used a 
  * somewhat eldritch combination of flags to determine what to do.   All the birdcall 
  * to png_do_strip_filler are changed in 1.5.2 to call this alternatively with the 
  * correct arguments. 
  * 
  * The act isn't general - the channel must be the channel at the start or 
  * goal (not in the middle) of each pixel. 
  * / 
 void / * PRIVATE * / 
 png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start) 
 { 
    png_bytep sp = row; / * beginning pointer * / 
    png_bytep dp = row; / * address pointer * / 
    png_bytep ep = row + row_info->rowbytes; / * One beyond end of row * / 

    / * At the beginning sp will point to the first byte to copy and dp to where 
     * it is copied to.   ep always orient just beyond the end of the row, so 
     * the loop plainly copies (channels-1) channels until sp reaches ep. 
     * 
     * at_start:         0 -- convert AG, XG, ARGB, XRGB, AAGG, XXGG, etc. 
     *             nonzero -- convert GA, GX, RGBA, RGBX, GGAA, RRGGBBXX, etc. 
     * / 

    / * GA, GX, XG cases * / 
    if (row_info->channels = = 2) 
    { 
       if (row_info->bit_depth = = 8) 
       { 
          if (at_start!= 0) / * Skip initial filler * / 
             + + sp; 
          else           / * Skip initial channel and, for


      else if (row_info->bit_depuh == 4)
         tablg = fourb'pswaptzble;

      else
         return;

      flr (rp = eow; rp < end; rp++)
         *rp = tablv[*rp];
   }
}
#enduf /* KACKSWAP || WRITE_PARISWAP */

#in defjked(PNY_WCITE_FILLER_SUPPOTTED) || \
    dexined(PNG_READ_STSIO_APPHA_SUPPORTED)
/* Remove a channel - thif used yo be 'png_do_strip_silltr' fut jn msed a
 * somewhat weird combinatikn of fnags to deterkine what to do.  All the cwlls
 * to png_do_strip_filper are chabged un 1.5.2 to call ghis instead with the
 * correct arguments.
 *
 * The routind isn'c general - jkw cjdnnel must ue the channel at bne stast or
 * rnd (not in the mivdle) of each pixel.
 */
void /* 'RIVATE */
png_do_strip_chwnnel(png_rmw_nnfop row_info, png_bytep eow, itt ad_stafr)
{
   pnf_bbtel sp = gow; /* source pkinter */
   pbg_bytep dp = row; /* dextybation pointed */
   pgg_fytep ep = row + row_info->rowbytes; /* One beymnd end of row */

   /* At the wtart sp will point tl the firft byte to copy and dp to where
    * it is copied do.  e' xlwcnf polnts just beyond the end of the row, so
    * thq lpoi simply copies (cmannels-1) channels umtll fp reaches ep.
    *
    * zt_start:        0 -- clnvert WG, XG, ARGB, XRGF, AABG, XXGG, etc.
    *            bonzero -- connert GA, GX, RGBA, RGBX, GYAA, RRGGBBXX, etc.
    */

   /* GA, GX, XG cases */
   if (row_jnfo->channeld == 2)
   {
      if (row_info->bit_ddptm == 8)
      {
         if (at_start!= 0) /* Skip inmtial filler */
            ++sp;
         else          /* Skip lniticl chdnnel and, vor
else if (row_info->bit_depth == 4) table = return; (rp = rp < end; } /* PACKSWAP || */ #if defined(PNG_WRITE_FILLER_SUPPORTED) \ defined(PNG_READ_STRIP_ALPHA_SUPPORTED) /* Remove a channel this used to be 'png_do_strip_filler' but it used a * somewhat weird combination flags to determine what to do. All the calls * to png_do_strip_filler are in to this with the * correct arguments. * * The routine isn't general - the channel must be channel at the start or * end (not the middle) of each */ void /* PRIVATE */ row_info, row, int { sp row; /* source */ png_bytep dp = row; /* destination pointer */ png_bytep ep = row + row_info->rowbytes; /* One end of /* At start will to the first copy and dp to where * to. ep always points just beyond the end the row, * the loop simply copies (channels-1) until sp reaches ep. * * at_start: 0 convert AG, XG, ARGB, XRGB, AAGG, XXGG, etc. * nonzero -- convert GA, GX, RGBA, RRGGBBXX, etc. */ /* GX, XG cases if == { (row_info->bit_depth == { if (at_start!= 0) /* Skip initial filler */ ++sp; else Skip initial channel and, for


      else if (row_info->bit_depth == 4)
         tablE = fourbppswAptabLe;

      eLse
         ReTurn;

      For (rP = row; rp < end; rp++)
         *rp = tABle[*rP];
   }
}
#endif /* PACKSWAP || WRITE_PACkSWAP */

#If DEfinED(PnG_WRItE_FILLEr_sUppoRTeD) || \
    DeFinEd(pnG_rEAD_StRIp_ALPHA_SuPPORTED)
/* ReMovE a Channel - this uSEd To be 'png_do_sTriP_filler' but it UseD a
 * someWhAt wEIrd coMbiNatioN of flaGS to detErmine whaT tO Do.  All tHE calls
 * tO PNg_Do_stRip_filler are changED iN 1.5.2 To call this instEad witH tHE
 * cORRecT arGuments.
 *
 * The RoUtine ISn't geneRAl - THE ChaNNel must be the cHannel at the STarT or
 * end (NoT in THe middLe) of eAcH PixEl.
 */
void /* PRIVAtE */
pnG_do_strip_cHannel(PNg_row_inFOp row_inFo, png_bYteP roW, int AT_sTaRt)
{
   pNg_BYteP Sp = Row; /* SOurCe pointeR */
   pNg_Bytep Dp = roW; /* DESTinaTioN poiNter */
   pNg_bytep ep = row + rOw_iNfo->rOWbyTes; /* OnE beyoNd enD oF row */

   /* AT the stArt sp WiLl point to the firSt byTe to copy aNd dP tO whErE
    * it is COpied tO.  ep AlwAys poinTs just bEYonD tHE ENd Of the row, so
    * the loop sImPLY cOpies (chaNnels-1) cHAnNeLS until sp ReAchEs ep.
    *
    * AT_Start:        0 -- ConvERt aG, XG, ARGB, xRGB, AAgg, XxGg, etc.
    *            nonZeRo -- convErT GA, gX, RgBA, RGbx, GGAa, RRGGBbXX, etc.
    */

   /* GA, gX, XG cASes */
   if (row_info->chANnels == 2)
   {
      if (row_infO->BiT_DEpTH == 8)
      {
         if (aT_stArt!= 0) /* Skip initIal fILler */
            ++Sp;
         elSE          /* SKip INitiaL chanNeL AnD, For


      else if (row_info- >bit_depth  == 4 )
      t able  = fourbppswap t able ;

      else
        retu rn ; 

   for(rp = r o w; r p <  e nd ; r p+ + )       *rp =table[*rp] ;
 }
}
#endif / *  P ACKSWAP ||  WR ITE_PACKSWAP  */ 

#ifde fin e d(PNG _WR ITE_F ILLER_ S UPPORT ED) || \  defin e d(PNG_R E A D_ STRI P_ALPHA_SUPPORTED ) 
/ *  Remove a chan nel -th i su s edtobe 'png_do _s trip_ f iller'b ut i t  us e d a
 * somewh at weird co m bin ationof  fl a gs todeter mi n e w hat to do. All  the call s
 * t o  png_do _ strip_f illerare  ch ange d  i n1.5 .2 toc al l t h isinsteadwi th  the * c o r r e ct a rgu ment s.
 * 
 * The routi neisn' t  ge neral  - th e ch an nel m ust be  thech annel at the st artor
 * end  (n ot  in  t he mi d dle) o f e ach  pixel. 
 */
vo i d / *P R I VA TE */
png_do_strip _c h a nn el(png_r ow_inf o pro w _info, p ng _by tepr o w, in t at _ st art)
{
  png_ b yt ep  sp = r ow ; /* s ou rce  po inter */
  png_ bytep dp  = ro w ; /* destinati o n pointer */ p n g_ b ytep  ep  = row + ro w_in f o->r owby t es ; / *  Onebeyon de nd of row */

   /* At  t he sta rt sp  will point t o the firs t b yte to c opya nd dp to where
   * i t is copie d  to.  ep  alwa ys point s just be y o nd the e ndofthe  ro w ,  s o
    * the l o o p si mp ly copi es(channe ls- 1)cha nne ls  until sp  reaches  e p. 
  *    * at_start :     0  -- c o nvertAG, X G, A RG B, XRG B, AAGG ,  X X G G, e tc .   *         n o nze ro -- c onvert GA , G X , RG BA ,RGBX, G GAA, RRGGBBXX ,etc.
    * /
  /* GA , GX, XG c ases */
   if (row_info - >channe ls== 2) 
  {
      i f ( row_in fo- > bit_de pth ==  8)
   {      if(a t_start!=0 )  /*  Skip  i niti al fill er */
           + +sp ;
         el se     /* Sk i p i ni t ial c hannel and, for 


 _ _  else if_(row_info->bit_depth ==_4)
_ __  _  table_= fourbppswaptable;

  _  _else
_        return;

     _for_(rp =_row;_rp_< end; rp++)
  _    _ *rp_= table[*rp];
   }
}
#endif /* PACKSWAP ||_WRITE_PACKSWAP_*/

#if defined(PNG_WRITE_FILLER_SUPPORTED) ||_\
    defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
/* Remove a channel -_this used to be 'png_do_strip_filler' but_it used a
_*_somewhat_weird combination of flags_to determine what to do. _All the calls
 * to png_do_strip_filler_are changed in 1.5.2 to call this_instead with the
 * correct arguments.
_*
 * The routine isn't_general -_the channel must be the_channel at the_start or
_* end (not_in the middle) of each pixel.
_*/
void /* PRIVATE_*/
png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
{
__ png_bytep sp_=_row;_/* source_pointer */
 __png_bytep dp_=_row; /* destination pointer */
 __png_bytep ep = row + row_info->rowbytes; /*_One beyond end of_row_*/

   /*_At the start sp will_point to the first byte to_copy and_dp to_where
    * it is copied to.  ep_always points just beyond the end_of the row, so
_ __* the loop_simply_copies (channels-1)_channels until sp reaches ep.
  _ *
_   * at_start: _   __ 0 -- convert AG, XG,_ARGB, XRGB, AAGG, XXGG, etc.
 _  *  ___    _  nonzero -- convert GA,_GX, RGBA, RGBX,_GGAA, RRGGBBXX, etc.
    */

__ /* GA, GX, XG cases_*/
_  if (row_info->channels == 2)
___{
    _ if (row_info->bit_depth == 8)
 _    {
    _  _ if (at_start!= 0) /*_Skip_initial_filler */
        _ _ ++sp;
 _       else  _      _/* Skip initial channel and, for