~random-stuff/libpng/libpng-1.6.x

« back to all changes in this revision

Viewing changes to pngwtran.c

  • Committer: Sérgio Benjamim
  • Date: 2015-10-10 23:00:20 UTC
  • Revision ID: sergio_br2@yahoo.com.br-20151010230020-gdtmmv30zn25396n
Update to 1.6.18.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
2
/* pngwtran.c - transforms the data in a row for PNG writers
3
3
 *
4
 
 * Last changed in libpng 1.4.1 [February 25, 2010]
5
 
 * Copyright (c) 1998-2010 Glenn Randers-Pehrson
 
4
 * Last changed in libpng 1.6.18 [July 23, 2015]
 
5
 * Copyright (c) 1998-2015 Glenn Randers-Pehrson
6
6
 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
7
7
 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
8
8
 *
11
11
 * and license in png.h
12
12
 */
13
13
 
14
 
#define PNG_NO_PEDANTIC_WARNINGS
15
 
#include "png.h"
 
14
#include "pngpriv.h"
 
15
 
16
16
#ifdef PNG_WRITE_SUPPORTED
17
 
#include "pngpriv.h"
18
 
 
19
 
/* Transform the data according to the user's wishes.  The order of
20
 
 * transformations is significant.
21
 
 */
22
 
void /* PRIVATE */
23
 
png_do_write_transformations(png_structp png_ptr)
24
 
{
25
 
   png_debug(1, "in png_do_write_transformations");
26
 
 
27
 
   if (png_ptr == NULL)
28
 
      return;
29
 
 
30
 
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
31
 
   if (png_ptr->transformations & PNG_USER_TRANSFORM)
32
 
      if (png_ptr->write_user_transform_fn != NULL)
33
 
        (*(png_ptr->write_user_transform_fn)) /* User write transform
34
 
                                                 function */
35
 
          (png_ptr,                    /* png_ptr */
36
 
           &(png_ptr->row_info),       /* row_info:     */
37
 
             /*  png_uint_32 width;          width of row */
38
 
             /*  png_uint_32 rowbytes;       number of bytes in row */
39
 
             /*  png_byte color_type;        color type of pixels */
40
 
             /*  png_byte bit_depth;         bit depth of samples */
41
 
             /*  png_byte channels;          number of channels (1-4) */
42
 
             /*  png_byte pixel_depth;       bits per pixel (depth*channels) */
43
 
           png_ptr->row_buf + 1);      /* start of pixel data for row */
44
 
#endif
45
 
#ifdef PNG_WRITE_FILLER_SUPPORTED
46
 
   if (png_ptr->transformations & PNG_FILLER)
47
 
      png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1,
48
 
         png_ptr->flags);
49
 
#endif
50
 
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
51
 
   if (png_ptr->transformations & PNG_PACKSWAP)
52
 
      png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1);
53
 
#endif
54
 
#ifdef PNG_WRITE_PACK_SUPPORTED
55
 
   if (png_ptr->transformations & PNG_PACK)
56
 
      png_do_pack(&(png_ptr->row_info), png_ptr->row_buf + 1,
57
 
         (png_uint_32)png_ptr->bit_depth);
58
 
#endif
59
 
#ifdef PNG_WRITE_SWAP_SUPPORTED
60
 
   if (png_ptr->transformations & PNG_SWAP_BYTES)
61
 
      png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1);
62
 
#endif
63
 
#ifdef PNG_WRITE_SHIFT_SUPPORTED
64
 
   if (png_ptr->transformations & PNG_SHIFT)
65
 
      png_do_shift(&(png_ptr->row_info), png_ptr->row_buf + 1,
66
 
         &(png_ptr->shift));
67
 
#endif
68
 
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
69
 
   if (png_ptr->transformations & PNG_SWAP_ALPHA)
70
 
      png_do_write_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
71
 
#endif
72
 
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
73
 
   if (png_ptr->transformations & PNG_INVERT_ALPHA)
74
 
      png_do_write_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
75
 
#endif
76
 
#ifdef PNG_WRITE_BGR_SUPPORTED
77
 
   if (png_ptr->transformations & PNG_BGR)
78
 
      png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1);
79
 
#endif
80
 
#ifdef PNG_WRITE_INVERT_SUPPORTED
81
 
   if (png_ptr->transformations & PNG_INVERT_MONO)
82
 
      png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1);
83
 
#endif
84
 
}
 
17
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
85
18
 
86
19
#ifdef PNG_WRITE_PACK_SUPPORTED
87
20
/* Pack pixels into bytes.  Pass the true bit depth in bit_depth.  The
88
21
 * row_info bit depth should be 8 (one pixel per byte).  The channels
89
22
 * should be 1 (this only happens on grayscale and paletted images).
90
23
 */
91
 
void /* PRIVATE */
 
24
static void
92
25
png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
93
26
{
94
27
   png_debug(1, "in png_do_pack");
114
47
            {
115
48
               if (*sp != 0)
116
49
                  v |= mask;
 
50
 
117
51
               sp++;
 
52
 
118
53
               if (mask > 1)
119
54
                  mask >>= 1;
 
55
 
120
56
               else
121
57
               {
122
58
                  mask = 0x80;
125
61
                  v = 0;
126
62
               }
127
63
            }
 
64
 
128
65
            if (mask != 0x80)
129
66
               *dp = (png_byte)v;
 
67
 
130
68
            break;
131
69
         }
 
70
 
132
71
         case 2:
133
72
         {
134
73
            png_bytep sp, dp;
135
 
            int shift, v;
 
74
            unsigned int shift;
 
75
            int v;
136
76
            png_uint_32 i;
137
77
            png_uint_32 row_width = row_info->width;
138
78
 
140
80
            dp = row;
141
81
            shift = 6;
142
82
            v = 0;
 
83
 
143
84
            for (i = 0; i < row_width; i++)
144
85
            {
145
86
               png_byte value;
146
87
 
147
88
               value = (png_byte)(*sp & 0x03);
148
89
               v |= (value << shift);
 
90
 
149
91
               if (shift == 0)
150
92
               {
151
93
                  shift = 6;
153
95
                  dp++;
154
96
                  v = 0;
155
97
               }
 
98
 
156
99
               else
157
100
                  shift -= 2;
 
101
 
158
102
               sp++;
159
103
            }
 
104
 
160
105
            if (shift != 6)
161
106
               *dp = (png_byte)v;
 
107
 
162
108
            break;
163
109
         }
 
110
 
164
111
         case 4:
165
112
         {
166
113
            png_bytep sp, dp;
167
 
            int shift, v;
 
114
            unsigned int shift;
 
115
            int v;
168
116
            png_uint_32 i;
169
117
            png_uint_32 row_width = row_info->width;
170
118
 
172
120
            dp = row;
173
121
            shift = 4;
174
122
            v = 0;
 
123
 
175
124
            for (i = 0; i < row_width; i++)
176
125
            {
177
126
               png_byte value;
186
135
                  dp++;
187
136
                  v = 0;
188
137
               }
 
138
 
189
139
               else
190
140
                  shift -= 4;
191
141
 
192
142
               sp++;
193
143
            }
 
144
 
194
145
            if (shift != 4)
195
146
               *dp = (png_byte)v;
 
147
 
196
148
            break;
197
149
         }
198
150
 
199
151
         default:
200
152
            break;
201
153
      }
 
154
 
202
155
      row_info->bit_depth = (png_byte)bit_depth;
203
156
      row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels);
204
157
      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,
205
 
         row_info->width);
 
158
          row_info->width);
206
159
   }
207
160
}
208
161
#endif
215
168
 * would pass 3 as bit_depth, and this routine would translate the
216
169
 * data to 0 to 15.
217
170
 */
218
 
void /* PRIVATE */
219
 
png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
 
171
static void
 
172
png_do_shift(png_row_infop row_info, png_bytep row,
 
173
    png_const_color_8p bit_depth)
220
174
{
221
175
   png_debug(1, "in png_do_shift");
222
176
 
223
 
   if (
224
 
      row_info->color_type != PNG_COLOR_TYPE_PALETTE)
 
177
   if (row_info->color_type != PNG_COLOR_TYPE_PALETTE)
225
178
   {
226
179
      int shift_start[4], shift_dec[4];
227
180
      int channels = 0;
228
181
 
229
 
      if (row_info->color_type & PNG_COLOR_MASK_COLOR)
 
182
      if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
230
183
      {
231
184
         shift_start[channels] = row_info->bit_depth - bit_depth->red;
232
185
         shift_dec[channels] = bit_depth->red;
233
186
         channels++;
 
187
 
234
188
         shift_start[channels] = row_info->bit_depth - bit_depth->green;
235
189
         shift_dec[channels] = bit_depth->green;
236
190
         channels++;
 
191
 
237
192
         shift_start[channels] = row_info->bit_depth - bit_depth->blue;
238
193
         shift_dec[channels] = bit_depth->blue;
239
194
         channels++;
240
195
      }
 
196
 
241
197
      else
242
198
      {
243
199
         shift_start[channels] = row_info->bit_depth - bit_depth->gray;
244
200
         shift_dec[channels] = bit_depth->gray;
245
201
         channels++;
246
202
      }
247
 
      if (row_info->color_type & PNG_COLOR_MASK_ALPHA)
 
203
 
 
204
      if ((row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0)
248
205
      {
249
206
         shift_start[channels] = row_info->bit_depth - bit_depth->alpha;
250
207
         shift_dec[channels] = bit_depth->alpha;
255
212
      if (row_info->bit_depth < 8)
256
213
      {
257
214
         png_bytep bp = row;
258
 
         png_uint_32 i;
259
 
         png_byte mask;
260
 
         png_uint_32 row_bytes = row_info->rowbytes;
 
215
         png_size_t i;
 
216
         unsigned int mask;
 
217
         png_size_t row_bytes = row_info->rowbytes;
261
218
 
262
219
         if (bit_depth->gray == 1 && row_info->bit_depth == 2)
263
220
            mask = 0x55;
 
221
 
264
222
         else if (row_info->bit_depth == 4 && bit_depth->gray == 3)
265
223
            mask = 0x11;
 
224
 
266
225
         else
267
226
            mask = 0xff;
268
227
 
269
228
         for (i = 0; i < row_bytes; i++, bp++)
270
229
         {
271
 
            png_uint_16 v;
272
230
            int j;
 
231
            unsigned int v, out;
273
232
 
274
233
            v = *bp;
275
 
            *bp = 0;
 
234
            out = 0;
 
235
 
276
236
            for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0])
277
237
            {
278
238
               if (j > 0)
279
 
                  *bp |= (png_byte)((v << j) & 0xff);
 
239
                  out |= v << j;
 
240
 
280
241
               else
281
 
                  *bp |= (png_byte)((v >> (-j)) & mask);
 
242
                  out |= (v >> (-j)) & mask;
282
243
            }
 
244
 
 
245
            *bp = (png_byte)(out & 0xff);
283
246
         }
284
247
      }
 
248
 
285
249
      else if (row_info->bit_depth == 8)
286
250
      {
287
251
         png_bytep bp = row;
291
255
         for (i = 0; i < istop; i++, bp++)
292
256
         {
293
257
 
294
 
            png_uint_16 v;
 
258
            const unsigned int c = i%channels;
295
259
            int j;
296
 
            int c = (int)(i%channels);
 
260
            unsigned int v, out;
297
261
 
298
262
            v = *bp;
299
 
            *bp = 0;
 
263
            out = 0;
 
264
 
300
265
            for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
301
266
            {
302
267
               if (j > 0)
303
 
                  *bp |= (png_byte)((v << j) & 0xff);
 
268
                  out |= v << j;
 
269
 
304
270
               else
305
 
                  *bp |= (png_byte)((v >> (-j)) & 0xff);
 
271
                  out |= v >> (-j);
306
272
            }
 
273
 
 
274
            *bp = (png_byte)(out & 0xff);
307
275
         }
308
276
      }
 
277
 
309
278
      else
310
279
      {
311
280
         png_bytep bp;
314
283
 
315
284
         for (bp = row, i = 0; i < istop; i++)
316
285
         {
317
 
            int c = (int)(i%channels);
318
 
            png_uint_16 value, v;
 
286
            const unsigned int c = i%channels;
319
287
            int j;
 
288
            unsigned int value, v;
320
289
 
321
 
            v = (png_uint_16)(((png_uint_16)(*bp) << 8) + *(bp + 1));
 
290
            v = png_get_uint_16(bp);
322
291
            value = 0;
 
292
 
323
293
            for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
324
294
            {
325
295
               if (j > 0)
326
 
                  value |= (png_uint_16)((v << j) & (png_uint_16)0xffff);
 
296
                  value |= v << j;
 
297
 
327
298
               else
328
 
                  value |= (png_uint_16)((v >> (-j)) & (png_uint_16)0xffff);
 
299
                  value |= v >> (-j);
329
300
            }
330
 
            *bp++ = (png_byte)(value >> 8);
 
301
            *bp++ = (png_byte)((value >> 8) & 0xff);
331
302
            *bp++ = (png_byte)(value & 0xff);
332
303
         }
333
304
      }
336
307
#endif
337
308
 
338
309
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
339
 
void /* PRIVATE */
 
310
static void
340
311
png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
341
312
{
342
313
   png_debug(1, "in png_do_write_swap_alpha");
344
315
   {
345
316
      if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
346
317
      {
347
 
         /* This converts from ARGB to RGBA */
348
318
         if (row_info->bit_depth == 8)
349
319
         {
 
320
            /* This converts from ARGB to RGBA */
350
321
            png_bytep sp, dp;
351
322
            png_uint_32 i;
352
323
            png_uint_32 row_width = row_info->width;
 
324
 
353
325
            for (i = 0, sp = dp = row; i < row_width; i++)
354
326
            {
355
327
               png_byte save = *(sp++);
359
331
               *(dp++) = save;
360
332
            }
361
333
         }
362
 
         /* This converts from AARRGGBB to RRGGBBAA */
 
334
 
 
335
#ifdef PNG_WRITE_16BIT_SUPPORTED
363
336
         else
364
337
         {
 
338
            /* This converts from AARRGGBB to RRGGBBAA */
365
339
            png_bytep sp, dp;
366
340
            png_uint_32 i;
367
341
            png_uint_32 row_width = row_info->width;
381
355
               *(dp++) = save[1];
382
356
            }
383
357
         }
 
358
#endif /* WRITE_16BIT */
384
359
      }
 
360
 
385
361
      else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
386
362
      {
387
 
         /* This converts from AG to GA */
388
363
         if (row_info->bit_depth == 8)
389
364
         {
 
365
            /* This converts from AG to GA */
390
366
            png_bytep sp, dp;
391
367
            png_uint_32 i;
392
368
            png_uint_32 row_width = row_info->width;
398
374
               *(dp++) = save;
399
375
            }
400
376
         }
401
 
         /* This converts from AAGG to GGAA */
 
377
 
 
378
#ifdef PNG_WRITE_16BIT_SUPPORTED
402
379
         else
403
380
         {
 
381
            /* This converts from AAGG to GGAA */
404
382
            png_bytep sp, dp;
405
383
            png_uint_32 i;
406
384
            png_uint_32 row_width = row_info->width;
416
394
               *(dp++) = save[1];
417
395
            }
418
396
         }
 
397
#endif /* WRITE_16BIT */
419
398
      }
420
399
   }
421
400
}
422
401
#endif
423
402
 
424
403
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
425
 
void /* PRIVATE */
 
404
static void
426
405
png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
427
406
{
428
407
   png_debug(1, "in png_do_write_invert_alpha");
430
409
   {
431
410
      if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
432
411
      {
433
 
         /* This inverts the alpha channel in RGBA */
434
412
         if (row_info->bit_depth == 8)
435
413
         {
 
414
            /* This inverts the alpha channel in RGBA */
436
415
            png_bytep sp, dp;
437
416
            png_uint_32 i;
438
417
            png_uint_32 row_width = row_info->width;
 
418
 
439
419
            for (i = 0, sp = dp = row; i < row_width; i++)
440
420
            {
441
421
               /* Does nothing
444
424
               *(dp++) = *(sp++);
445
425
               */
446
426
               sp+=3; dp = sp;
447
 
               *(dp++) = (png_byte)(255 - *(sp++));
 
427
               *dp = (png_byte)(255 - *(sp++));
448
428
            }
449
429
         }
450
 
         /* This inverts the alpha channel in RRGGBBAA */
 
430
 
 
431
#ifdef PNG_WRITE_16BIT_SUPPORTED
451
432
         else
452
433
         {
 
434
            /* This inverts the alpha channel in RRGGBBAA */
453
435
            png_bytep sp, dp;
454
436
            png_uint_32 i;
455
437
            png_uint_32 row_width = row_info->width;
466
448
               */
467
449
               sp+=6; dp = sp;
468
450
               *(dp++) = (png_byte)(255 - *(sp++));
469
 
               *(dp++) = (png_byte)(255 - *(sp++));
 
451
               *dp     = (png_byte)(255 - *(sp++));
470
452
            }
471
453
         }
 
454
#endif /* WRITE_16BIT */
472
455
      }
 
456
 
473
457
      else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
474
458
      {
475
 
         /* This inverts the alpha channel in GA */
476
459
         if (row_info->bit_depth == 8)
477
460
         {
 
461
            /* This inverts the alpha channel in GA */
478
462
            png_bytep sp, dp;
479
463
            png_uint_32 i;
480
464
            png_uint_32 row_width = row_info->width;
485
469
               *(dp++) = (png_byte)(255 - *(sp++));
486
470
            }
487
471
         }
488
 
         /* This inverts the alpha channel in GGAA */
 
472
 
 
473
#ifdef PNG_WRITE_16BIT_SUPPORTED
489
474
         else
490
475
         {
 
476
            /* This inverts the alpha channel in GGAA */
491
477
            png_bytep sp, dp;
492
478
            png_uint_32 i;
493
479
            png_uint_32 row_width = row_info->width;
500
486
               */
501
487
               sp+=2; dp = sp;
502
488
               *(dp++) = (png_byte)(255 - *(sp++));
503
 
               *(dp++) = (png_byte)(255 - *(sp++));
 
489
               *dp     = (png_byte)(255 - *(sp++));
504
490
            }
505
491
         }
 
492
#endif /* WRITE_16BIT */
506
493
      }
507
494
   }
508
495
}
509
496
#endif
510
497
 
511
 
#ifdef PNG_MNG_FEATURES_SUPPORTED
512
 
/* Undoes intrapixel differencing  */
 
498
/* Transform the data according to the user's wishes.  The order of
 
499
 * transformations is significant.
 
500
 */
513
501
void /* PRIVATE */
514
 
png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
 
502
png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info)
515
503
{
516
 
   png_debug(1, "in png_do_write_intrapixel");
517
 
 
518
 
   if (
519
 
       (row_info->color_type & PNG_COLOR_MASK_COLOR))
520
 
   {
521
 
      int bytes_per_pixel;
522
 
      png_uint_32 row_width = row_info->width;
523
 
      if (row_info->bit_depth == 8)
524
 
      {
525
 
         png_bytep rp;
526
 
         png_uint_32 i;
527
 
 
528
 
         if (row_info->color_type == PNG_COLOR_TYPE_RGB)
529
 
            bytes_per_pixel = 3;
530
 
         else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
531
 
            bytes_per_pixel = 4;
532
 
         else
533
 
            return;
534
 
 
535
 
         for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
536
 
         {
537
 
            *(rp)   = (png_byte)((*rp     - *(rp+1))&0xff);
538
 
            *(rp+2) = (png_byte)((*(rp+2) - *(rp+1))&0xff);
539
 
         }
540
 
      }
541
 
      else if (row_info->bit_depth == 16)
542
 
      {
543
 
         png_bytep rp;
544
 
         png_uint_32 i;
545
 
 
546
 
         if (row_info->color_type == PNG_COLOR_TYPE_RGB)
547
 
            bytes_per_pixel = 6;
548
 
         else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
549
 
            bytes_per_pixel = 8;
550
 
         else
551
 
            return;
552
 
 
553
 
         for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
554
 
         {
555
 
            png_uint_32 s0   = (*(rp  ) << 8) | *(rp+1);
556
 
            png_uint_32 s1   = (*(rp+2) << 8) | *(rp+3);
557
 
            png_uint_32 s2   = (*(rp+4) << 8) | *(rp+5);
558
 
            png_uint_32 red  = (png_uint_32)((s0 - s1) & 0xffffL);
559
 
            png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL);
560
 
            *(rp  ) = (png_byte)((red >> 8) & 0xff);
561
 
            *(rp+1) = (png_byte)(red & 0xff);
562
 
            *(rp+4) = (png_byte)((blue >> 8) & 0xff);
563
 
            *(rp+5) = (png_byte)(blue & 0xff);
564
 
         }
565
 
      }
566
 
   }
 
504
   png_debug(1, "in png_do_write_transformations");
 
505
 
 
506
   if (png_ptr == NULL)
 
507
      return;
 
508
 
 
509
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
 
510
   if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
 
511
      if (png_ptr->write_user_transform_fn != NULL)
 
512
         (*(png_ptr->write_user_transform_fn)) /* User write transform
 
513
                                                 function */
 
514
             (png_ptr,  /* png_ptr */
 
515
             row_info,  /* row_info: */
 
516
                /*  png_uint_32 width;       width of row */
 
517
                /*  png_size_t rowbytes;     number of bytes in row */
 
518
                /*  png_byte color_type;     color type of pixels */
 
519
                /*  png_byte bit_depth;      bit depth of samples */
 
520
                /*  png_byte channels;       number of channels (1-4) */
 
521
                /*  png_byte pixel_depth;    bits per pixel (depth*channels) */
 
522
             png_ptr->row_buf + 1);      /* start of pixel data for row */
 
523
#endif
 
524
 
 
525
#ifdef PNG_WRITE_FILLER_SUPPORTED
 
526
   if ((png_ptr->transformations & PNG_FILLER) != 0)
 
527
      png_do_strip_channel(row_info, png_ptr->row_buf + 1,
 
528
         !(png_ptr->flags & PNG_FLAG_FILLER_AFTER));
 
529
#endif
 
530
 
 
531
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
 
532
   if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
 
533
      png_do_packswap(row_info, png_ptr->row_buf + 1);
 
534
#endif
 
535
 
 
536
#ifdef PNG_WRITE_PACK_SUPPORTED
 
537
   if ((png_ptr->transformations & PNG_PACK) != 0)
 
538
      png_do_pack(row_info, png_ptr->row_buf + 1,
 
539
          (png_uint_32)png_ptr->bit_depth);
 
540
#endif
 
541
 
 
542
#ifdef PNG_WRITE_SWAP_SUPPORTED
 
543
#  ifdef PNG_16BIT_SUPPORTED
 
544
   if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0)
 
545
      png_do_swap(row_info, png_ptr->row_buf + 1);
 
546
#  endif
 
547
#endif
 
548
 
 
549
#ifdef PNG_WRITE_SHIFT_SUPPORTED
 
550
   if ((png_ptr->transformations & PNG_SHIFT) != 0)
 
551
      png_do_shift(row_info, png_ptr->row_buf + 1,
 
552
          &(png_ptr->shift));
 
553
#endif
 
554
 
 
555
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
 
556
   if ((png_ptr->transformations & PNG_SWAP_ALPHA) != 0)
 
557
      png_do_write_swap_alpha(row_info, png_ptr->row_buf + 1);
 
558
#endif
 
559
 
 
560
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
 
561
   if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0)
 
562
      png_do_write_invert_alpha(row_info, png_ptr->row_buf + 1);
 
563
#endif
 
564
 
 
565
#ifdef PNG_WRITE_BGR_SUPPORTED
 
566
   if ((png_ptr->transformations & PNG_BGR) != 0)
 
567
      png_do_bgr(row_info, png_ptr->row_buf + 1);
 
568
#endif
 
569
 
 
570
#ifdef PNG_WRITE_INVERT_SUPPORTED
 
571
   if ((png_ptr->transformations & PNG_INVERT_MONO) != 0)
 
572
      png_do_invert(row_info, png_ptr->row_buf + 1);
 
573
#endif
567
574
}
568
 
#endif /* PNG_MNG_FEATURES_SUPPORTED */
569
 
#endif /* PNG_WRITE_SUPPORTED */
 
575
#endif /* WRITE_TRANSFORMS */
 
576
#endif /* WRITE */