15 #define PNG_NO_PEDANTIC_WARNINGS 17 #ifdef PNG_WRITE_SUPPORTED 25 png_debug(1,
"in png_do_write_transformations");
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))
43 png_ptr->row_buf + 1);
45 #ifdef PNG_WRITE_FILLER_SUPPORTED 46 if (png_ptr->transformations & PNG_FILLER)
50 #ifdef PNG_WRITE_PACKSWAP_SUPPORTED 51 if (png_ptr->transformations & PNG_PACKSWAP)
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,
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);
63 #ifdef PNG_WRITE_SHIFT_SUPPORTED 64 if (png_ptr->transformations & PNG_SHIFT)
68 #ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED 69 if (png_ptr->transformations & PNG_SWAP_ALPHA)
72 #ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED 73 if (png_ptr->transformations & PNG_INVERT_ALPHA)
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);
80 #ifdef PNG_WRITE_INVERT_SUPPORTED 81 if (png_ptr->transformations & PNG_INVERT_MONO)
86 #ifdef PNG_WRITE_PACK_SUPPORTED 96 if (row_info->bit_depth == 8 &&
97 #ifdef PNG_USELESS_TESTS_SUPPORTED
100 row_info->channels == 1)
102 switch ((
int)bit_depth)
116 for (i = 0; i < row_width; i++)
146 for (i = 0; i < row_width; i++)
151 v |= (value << shift);
178 for (i = 0; i < row_width; i++)
183 v |= (value << shift);
202 row_info->bit_depth = (
png_byte)bit_depth;
203 row_info->pixel_depth = (
png_byte)(bit_depth * row_info->channels);
204 row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,
210 #ifdef PNG_WRITE_SHIFT_SUPPORTED 223 #ifdef PNG_USELESS_TESTS_SUPPORTED 224 if (row !=
NULL && row_info !=
NULL &&
230 int shift_start[4], shift_dec[4];
233 if (row_info->color_type & PNG_COLOR_MASK_COLOR)
235 shift_start[channels] = row_info->bit_depth - bit_depth->red;
236 shift_dec[channels] = bit_depth->red;
238 shift_start[channels] = row_info->bit_depth - bit_depth->green;
239 shift_dec[channels] = bit_depth->green;
241 shift_start[channels] = row_info->bit_depth - bit_depth->blue;
242 shift_dec[channels] = bit_depth->blue;
247 shift_start[channels] = row_info->bit_depth - bit_depth->gray;
248 shift_dec[channels] = bit_depth->gray;
253 shift_start[channels] = row_info->bit_depth - bit_depth->alpha;
254 shift_dec[channels] = bit_depth->alpha;
259 if (row_info->bit_depth < 8)
264 png_uint_32 row_bytes = row_info->rowbytes;
266 if (bit_depth->gray == 1 && row_info->bit_depth == 2)
268 else if (row_info->bit_depth == 4 && bit_depth->gray == 3)
273 for (i = 0; i < row_bytes; i++, bp++)
280 for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0])
283 *bp |= (png_byte)((v << j) & 0xff);
285 *bp |= (png_byte)((v >> (-j)) & mask);
289 else if (row_info->bit_depth == 8)
293 png_uint_32 istop = channels * row_info->width;
295 for (i = 0; i < istop; i++, bp++)
300 int c = (int)(i%channels);
304 for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
307 *bp |= (png_byte)((v << j) & 0xff);
309 *bp |= (png_byte)((v >> (-j)) & 0xff);
319 for (bp =
row, i = 0; i < istop; i++)
327 for (j = shift_start[c]; j > -shift_dec[
c]; j -= shift_dec[
c])
342 #ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED 346 png_debug(1,
"in png_do_write_swap_alpha");
348 #ifdef PNG_USELESS_TESTS_SUPPORTED 349 if (row !=
NULL && row_info !=
NULL)
355 if (row_info->bit_depth == 8)
360 for (i = 0, sp = dp = row; i < row_width; i++)
376 for (i = 0, sp = dp = row; i < row_width; i++)
395 if (row_info->bit_depth == 8)
401 for (i = 0, sp = dp = row; i < row_width; i++)
415 for (i = 0, sp = dp = row; i < row_width; i++)
431 #ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED 435 png_debug(1,
"in png_do_write_invert_alpha");
437 #ifdef PNG_USELESS_TESTS_SUPPORTED 438 if (row !=
NULL && row_info !=
NULL)
444 if (row_info->bit_depth == 8)
449 for (i = 0, sp = dp = row; i < row_width; i++)
457 *(dp++) = (
png_byte)(255 - *(sp++));
467 for (i = 0, sp = dp = row; i < row_width; i++)
478 *(dp++) = (
png_byte)(255 - *(sp++));
479 *(dp++) = (
png_byte)(255 - *(sp++));
486 if (row_info->bit_depth == 8)
492 for (i = 0, sp = dp = row; i < row_width; i++)
495 *(dp++) = (
png_byte)(255 - *(sp++));
505 for (i = 0, sp = dp = row; i < row_width; i++)
512 *(dp++) = (
png_byte)(255 - *(sp++));
513 *(dp++) = (
png_byte)(255 - *(sp++));
521 #ifdef PNG_MNG_FEATURES_SUPPORTED 526 png_debug(1,
"in png_do_write_intrapixel");
529 #ifdef PNG_USELESS_TESTS_SUPPORTED
536 if (row_info->bit_depth == 8)
548 for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
550 *(rp) = (
png_byte)((*rp - *(rp+1))&0xff);
551 *(rp+2) = (
png_byte)((*(rp+2) - *(rp+1))&0xff);
554 else if (row_info->bit_depth == 16)
566 for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
573 *(rp ) = (
png_byte)((red >> 8) & 0xff);
575 *(rp+4) = (
png_byte)((blue >> 8) & 0xff);
void png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
void png_do_packswap(png_row_infop row_info, png_bytep row)
void png_do_invert(png_row_infop row_info, png_bytep row)
#define PNG_COLOR_TYPE_RGB
#define PNG_COLOR_TYPE_GRAY_ALPHA
void png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
#define PNG_COLOR_TYPE_PALETTE
void png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
#define PNG_COLOR_TYPE_RGB_ALPHA
void png_do_write_transformations(png_structp png_ptr)
GLenum GLenum GLvoid * row
png_struct FAR * png_structp
#define PNG_COLOR_MASK_COLOR
unsigned short png_uint_16
void png_do_bgr(png_row_infop row_info, png_bytep row)
GLsizei const GLfloat * value
void png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
if(!abbox) return FT_THROW(Invalid_Argument)
#define PNG_COLOR_MASK_ALPHA
void png_do_swap(png_row_infop row_info, png_bytep row)
png_color_8 FAR * png_color_8p
unsigned long png_uint_32
png_row_info FAR * png_row_infop
void png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
void png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)