Lines Matching refs:png_ptr
28 png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
32 if (png_ptr == NULL || info_ptr == NULL)
35 if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE))
38 png_write_sig(png_ptr);
41 if ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) && \
42 (png_ptr->mng_features_permitted))
44 png_warning(png_ptr, "MNG features are not allowed in a PNG datastream");
45 png_ptr->mng_features_permitted = 0;
50 png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height,
63 png_write_gAMA_fixed(png_ptr, info_ptr->gamma);
67 png_write_sRGB(png_ptr, (int)info_ptr->srgb_intent);
72 png_write_iCCP(png_ptr, info_ptr->iccp_name, PNG_COMPRESSION_TYPE_BASE,
77 png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type);
81 png_write_cHRM_fixed(png_ptr,
99 int keep = png_handle_as_unknown(png_ptr, up->name);
107 (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
110 png_warning(png_ptr, "Writing zero-length unknown chunk");
112 png_write_chunk(png_ptr, up->name, up->data, up->size);
117 png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE;
122 png_write_info(png_structp png_ptr, png_infop info_ptr)
130 if (png_ptr == NULL || info_ptr == NULL)
133 png_write_info_before_PLTE(png_ptr, info_ptr);
136 png_write_PLTE(png_ptr, info_ptr->palette,
140 png_error(png_ptr, "Valid palette required for paletted images");
147 if ((png_ptr->transformations & PNG_INVERT_ALPHA) &&
156 png_write_tRNS(png_ptr, info_ptr->trans_alpha, &(info_ptr->trans_color),
162 png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type);
167 png_write_hIST(png_ptr, info_ptr->hist, info_ptr->num_palette);
172 png_write_oFFs(png_ptr, info_ptr->x_offset, info_ptr->y_offset,
178 png_write_pCAL(png_ptr, info_ptr->pcal_purpose, info_ptr->pcal_X0,
185 png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit,
191 png_write_pHYs(png_ptr, info_ptr->x_pixels_per_unit,
198 png_write_tIME(png_ptr, &(info_ptr->mod_time));
199 png_ptr->mode |= PNG_WROTE_tIME;
206 png_write_sPLT(png_ptr, info_ptr->splt_palettes + i);
220 png_write_iTXt(png_ptr,
227 png_warning(png_ptr, "Unable to write international text");
238 png_write_zTXt(png_ptr, info_ptr->text[i].key,
242 png_warning(png_ptr, "Unable to write compressed text");
252 png_write_tEXt(png_ptr, info_ptr->text[i].key,
259 png_warning(png_ptr, "Unable to write uncompressed text");
276 int keep = png_handle_as_unknown(png_ptr, up->name);
283 (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
285 png_write_chunk(png_ptr, up->name, up->data, up->size);
298 png_write_end(png_structp png_ptr, png_infop info_ptr)
302 if (png_ptr == NULL)
305 if (!(png_ptr->mode & PNG_HAVE_IDAT))
306 png_error(png_ptr, "No IDATs written into file");
309 if (png_ptr->num_palette_max > png_ptr->num_palette)
310 png_benign_error(png_ptr, "Wrote palette index exceeding num_palette");
322 !(png_ptr->mode & PNG_WROTE_tIME))
323 png_write_tIME(png_ptr, &(info_ptr->mod_time));
337 png_write_iTXt(png_ptr,
344 png_warning(png_ptr, "Unable to write international text");
354 png_write_zTXt(png_ptr, info_ptr->text[i].key,
358 png_warning(png_ptr, "Unable to write compressed text");
368 png_write_tEXt(png_ptr, info_ptr->text[i].key,
371 png_warning(png_ptr, "Unable to write uncompressed text");
390 int keep = png_handle_as_unknown(png_ptr, up->name);
395 (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
397 png_write_chunk(png_ptr, up->name, up->data, up->size);
404 png_ptr->mode |= PNG_AFTER_IDAT;
407 png_write_IEND(png_ptr);
410 * do not set png_ptr->output_flush_fn to crash. If your application
417 png_flush(png_ptr);
449 /* Initialize png_ptr structure, and allocate any memory needed */
459 /* Alternate initialize png_ptr structure, and allocate any memory needed */
460 static void png_reset_filter_heuristics(png_structp png_ptr); /* forward decl */
472 png_structp png_ptr;
482 png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
485 png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG);
487 if (png_ptr == NULL)
492 png_ptr->user_width_max = PNG_USER_WIDTH_MAX;
493 png_ptr->user_height_max = PNG_USER_HEIGHT_MAX;
504 if (setjmp(png_jmpbuf(png_ptr))) /* sets longjmp to match setjmp */
507 png_memcpy(png_jmpbuf(png_ptr), tmp_jmpbuf, png_sizeof(jmp_buf));
513 png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn);
515 png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
517 if (!png_user_version_check(png_ptr, user_png_ver))
521 png_ptr->zbuf_size = PNG_ZBUF_SIZE;
525 png_ptr->zbuf = (png_bytep)png_malloc_warn(png_ptr,
526 png_ptr->zbuf_size);
527 if (png_ptr->zbuf == NULL)
534 png_free(png_ptr, png_ptr->zbuf);
535 png_ptr->zbuf = NULL;
537 png_destroy_struct_2((png_voidp)png_ptr,
540 png_destroy_struct((png_voidp)png_ptr);
545 png_set_write_fn(png_ptr, NULL, NULL, NULL);
548 png_reset_filter_heuristics(png_ptr);
551 return (png_ptr);
561 png_write_rows(png_structp png_ptr, png_bytepp row,
569 if (png_ptr == NULL)
575 png_write_row(png_ptr, *rp);
583 png_write_image(png_structp png_ptr, png_bytepp image)
589 if (png_ptr == NULL)
598 num_pass = png_set_interlace_handling(png_ptr);
606 for (i = 0, rp = image; i < png_ptr->height; i++, rp++)
608 png_write_row(png_ptr, *rp);
615 png_write_row(png_structp png_ptr, png_const_bytep row)
620 if (png_ptr == NULL)
624 png_ptr->row_number, png_ptr->pass);
627 if (png_ptr->row_number == 0 && png_ptr->pass == 0)
630 if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE))
631 png_error(png_ptr,
636 if (png_ptr->transformations & PNG_INVERT_MONO)
637 png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined");
641 if (png_ptr->transformations & PNG_FILLER)
642 png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined");
646 if (png_ptr->transformations & PNG_PACKSWAP)
647 png_warning(png_ptr,
652 if (png_ptr->transformations & PNG_PACK)
653 png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined");
657 if (png_ptr->transformations & PNG_SHIFT)
658 png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined");
662 if (png_ptr->transformations & PNG_BGR)
663 png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined");
667 if (png_ptr->transformations & PNG_SWAP_BYTES)
668 png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined");
671 png_write_start_row(png_ptr);
676 if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))
678 switch (png_ptr->pass)
681 if (png_ptr->row_number & 0x07)
683 png_write_finish_row(png_ptr);
689 if ((png_ptr->row_number & 0x07) || png_ptr->width < 5)
691 png_write_finish_row(png_ptr);
697 if ((png_ptr->row_number & 0x07) != 4)
699 png_write_finish_row(png_ptr);
705 if ((png_ptr->row_number & 0x03) || png_ptr->width < 3)
707 png_write_finish_row(png_ptr);
713 if ((png_ptr->row_number & 0x03) != 2)
715 png_write_finish_row(png_ptr);
721 if ((png_ptr->row_number & 0x01) || png_ptr->width < 2)
723 png_write_finish_row(png_ptr);
729 if (!(png_ptr->row_number & 0x01))
731 png_write_finish_row(png_ptr);
743 row_info.color_type = png_ptr->color_type;
744 row_info.width = png_ptr->usr_width;
745 row_info.channels = png_ptr->usr_channels;
746 row_info.bit_depth = png_ptr->usr_bit_depth;
758 png_memcpy(png_ptr->row_buf + 1, row, row_info.rowbytes);
762 if (png_ptr->interlaced && png_ptr->pass < 6 &&
763 (png_ptr->transformations & PNG_INTERLACE))
765 png_do_write_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass);
769 png_write_finish_row(png_ptr);
777 if (png_ptr->transformations)
778 png_do_write_transformations(png_ptr, &row_info);
784 if (row_info.pixel_depth != png_ptr->pixel_depth ||
785 row_info.pixel_depth != png_ptr->transformed_pixel_depth)
786 png_error(png_ptr, "internal write transform logic error");
798 if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
799 (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
802 png_do_write_intrapixel(&row_info, png_ptr->row_buf + 1);
810 png_ptr->num_palette_max >= 0)
811 png_do_check_palette_indexes(png_ptr, &row_info);
815 png_write_find_filter(png_ptr, &row_info);
817 if (png_ptr->write_row_fn != NULL)
818 (*(png_ptr->write_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass);
824 png_set_flush(png_structp png_ptr, int nrows)
828 if (png_ptr == NULL)
831 png_ptr->flush_dist = (nrows < 0 ? 0 : nrows);
836 png_write_flush(png_structp png_ptr)
842 if (png_ptr == NULL)
846 if (png_ptr->row_number >= png_ptr->num_rows)
854 ret = deflate(&png_ptr->zstream, Z_SYNC_FLUSH);
860 if (png_ptr->zstream.msg != NULL)
861 png_error(png_ptr, png_ptr->zstream.msg);
864 png_error(png_ptr, "zlib error");
867 if (!(png_ptr->zstream.avail_out))
870 png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size);
876 if (png_ptr->zbuf_size != png_ptr->zstream.avail_out)
879 png_write_IDAT(png_ptr, png_ptr->zbuf,
880 png_ptr->zbuf_size - png_ptr->zstream.avail_out);
882 png_ptr->flush_rows = 0;
883 png_flush(png_ptr);
891 png_structp png_ptr = NULL;
901 png_ptr = *png_ptr_ptr;
904 if (png_ptr != NULL)
906 free_fn = png_ptr->free_fn;
907 mem_ptr = png_ptr->mem_ptr;
916 if (png_ptr != NULL)
918 png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
921 if (png_ptr->num_chunk_list)
923 png_free(png_ptr, png_ptr->chunk_list);
924 png_ptr->num_chunk_list = 0;
938 if (png_ptr != NULL)
940 png_write_destroy(png_ptr);
942 png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn,
945 png_destroy_struct((png_voidp)png_ptr);
952 /* Free any memory used in png_ptr struct (old method) */
954 png_write_destroy(png_structp png_ptr)
971 if (png_ptr->zlib_state != PNG_ZLIB_UNINITIALIZED)
972 deflateEnd(&png_ptr->zstream);
975 png_free(png_ptr, png_ptr->zbuf);
976 png_free(png_ptr, png_ptr->row_buf);
978 png_free(png_ptr, png_ptr->prev_row);
979 png_free(png_ptr, png_ptr->sub_row);
980 png_free(png_ptr, png_ptr->up_row);
981 png_free(png_ptr, png_ptr->avg_row);
982 png_free(png_ptr, png_ptr->paeth_row);
987 png_reset_filter_heuristics(png_ptr);
988 png_free(png_ptr, png_ptr->filter_costs);
989 png_free(png_ptr, png_ptr->inv_filter_costs);
994 png_memcpy(tmp_jmp, png_ptr->longjmp_buffer, png_sizeof(jmp_buf));
997 error_fn = png_ptr->error_fn;
999 warning_fn = png_ptr->warning_fn;
1001 error_ptr = png_ptr->error_ptr;
1003 free_fn = png_ptr->free_fn;
1006 png_memset(png_ptr, 0, png_sizeof(png_struct));
1008 png_ptr->error_fn = error_fn;
1010 png_ptr->warning_fn = warning_fn;
1012 png_ptr->error_ptr = error_ptr;
1014 png_ptr->free_fn = free_fn;
1018 png_memcpy(png_ptr->longjmp_buffer, tmp_jmp, png_sizeof(jmp_buf));
1024 png_set_filter(png_structp png_ptr, int method, int filters)
1028 if (png_ptr == NULL)
1032 if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
1044 case 7: png_warning(png_ptr, "Unknown row filter for method 0");
1047 png_ptr->do_filter = PNG_FILTER_NONE; break;
1051 png_ptr->do_filter = PNG_FILTER_SUB; break;
1054 png_ptr->do_filter = PNG_FILTER_UP; break;
1057 png_ptr->do_filter = PNG_FILTER_AVG; break;
1060 png_ptr->do_filter = PNG_FILTER_PAETH; break;
1063 png_ptr->do_filter = (png_byte)filters; break;
1066 png_warning(png_ptr, "Unknown row filter for method 0");
1079 if (png_ptr->row_buf != NULL)
1082 if ((png_ptr->do_filter & PNG_FILTER_SUB) && png_ptr->sub_row == NULL)
1084 png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,
1085 (png_ptr->rowbytes + 1));
1086 png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
1089 if ((png_ptr->do_filter & PNG_FILTER_UP) && png_ptr->up_row == NULL)
1091 if (png_ptr->prev_row == NULL)
1093 png_warning(png_ptr, "Can't add Up filter after starting");
1094 png_ptr->do_filter = (png_byte)(png_ptr->do_filter &
1100 png_ptr->up_row = (png_bytep)png_malloc(png_ptr,
1101 (png_ptr->rowbytes + 1));
1102 png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
1106 if ((png_ptr->do_filter & PNG_FILTER_AVG) && png_ptr->avg_row == NULL)
1108 if (png_ptr->prev_row == NULL)
1110 png_warning(png_ptr, "Can't add Average filter after starting");
1111 png_ptr->do_filter = (png_byte)(png_ptr->do_filter &
1117 png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,
1118 (png_ptr->rowbytes + 1));
1119 png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
1123 if ((png_ptr->do_filter & PNG_FILTER_PAETH) &&
1124 png_ptr->paeth_row == NULL)
1126 if (png_ptr->prev_row == NULL)
1128 png_warning(png_ptr, "Can't add Paeth filter after starting");
1129 png_ptr->do_filter &= (png_byte)(~PNG_FILTER_PAETH);
1134 png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,
1135 (png_ptr->rowbytes + 1));
1136 png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
1140 if (png_ptr->do_filter == PNG_NO_FILTERS)
1142 png_ptr->do_filter = PNG_FILTER_NONE;
1146 png_error(png_ptr, "Unknown custom filter method");
1159 png_reset_filter_heuristics(png_structp png_ptr)
1166 png_ptr->num_prev_filters = 0;
1167 png_ptr->heuristic_method = PNG_FILTER_HEURISTIC_UNWEIGHTED;
1168 if (png_ptr->prev_filters != NULL)
1170 png_bytep old = png_ptr->prev_filters;
1171 png_ptr->prev_filters = NULL;
1172 png_free(png_ptr, old);
1174 if (png_ptr->filter_weights != NULL)
1176 png_uint_16p old = png_ptr->filter_weights;
1177 png_ptr->filter_weights = NULL;
1178 png_free(png_ptr, old);
1181 if (png_ptr->inv_filter_weights != NULL)
1183 png_uint_16p old = png_ptr->inv_filter_weights;
1184 png_ptr->inv_filter_weights = NULL;
1185 png_free(png_ptr, old);
1192 png_init_filter_heuristics(png_structp png_ptr, int heuristic_method,
1195 if (png_ptr == NULL)
1199 png_reset_filter_heuristics(png_ptr);
1211 png_ptr->prev_filters = (png_bytep)png_malloc(png_ptr,
1217 png_ptr->prev_filters[i] = 255;
1220 png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr,
1223 png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr,
1228 png_ptr->inv_filter_weights[i] =
1229 png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR;
1233 png_ptr->num_prev_filters = (png_byte)num_weights;
1237 * need to be based on png_ptr->filter.
1239 if (png_ptr->filter_costs == NULL)
1241 png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr,
1244 png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr,
1250 png_ptr->inv_filter_costs[i] =
1251 png_ptr->filter_costs[i] = PNG_COST_FACTOR;
1255 png_ptr->heuristic_method = PNG_FILTER_HEURISTIC_WEIGHTED;
1267 png_warning(png_ptr, "Unknown filter heuristic method");
1275 png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
1284 if (!png_init_filter_heuristics(png_ptr, heuristic_method, num_weights))
1295 png_ptr->inv_filter_weights[i] =
1296 png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR;
1301 png_ptr->inv_filter_weights[i] =
1304 png_ptr->filter_weights[i] =
1318 png_ptr->inv_filter_costs[i] =
1321 png_ptr->filter_costs[i] =
1330 png_set_filter_heuristics_fixed(png_structp png_ptr, int heuristic_method,
1339 if (!png_init_filter_heuristics(png_ptr, heuristic_method, num_weights))
1350 png_ptr->inv_filter_weights[i] =
1351 png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR;
1356 png_ptr->inv_filter_weights[i] = (png_uint_16)
1359 png_ptr->filter_weights[i] = (png_uint_16)((PNG_WEIGHT_FACTOR*
1383 png_ptr->inv_filter_costs[i] = (png_uint_16)tmp;
1388 png_ptr->filter_costs[i] = (png_uint_16)tmp;
1396 png_set_compression_level(png_structp png_ptr, int level)
1400 if (png_ptr == NULL)
1403 png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_LEVEL;
1404 png_ptr->zlib_level = level;
1408 png_set_compression_mem_level(png_structp png_ptr, int mem_level)
1412 if (png_ptr == NULL)
1415 png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL;
1416 png_ptr->zlib_mem_level = mem_level;
1420 png_set_compression_strategy(png_structp png_ptr, int strategy)
1424 if (png_ptr == NULL)
1427 png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_STRATEGY;
1428 png_ptr->zlib_strategy = strategy;
1435 png_set_compression_window_bits(png_structp png_ptr, int window_bits)
1437 if (png_ptr == NULL)
1441 png_warning(png_ptr, "Only compression windows <= 32k supported by PNG");
1444 png_warning(png_ptr, "Only compression windows >= 256 supported by PNG");
1450 png_warning(png_ptr, "Compression window is being reset to 512");
1455 png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS;
1456 png_ptr->zlib_window_bits = window_bits;
1460 png_set_compression_method(png_structp png_ptr, int method)
1464 if (png_ptr == NULL)
1468 png_warning(png_ptr, "Only compression method 8 is supported by PNG");
1470 png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_METHOD;
1471 png_ptr->zlib_method = method;
1477 png_set_text_compression_level(png_structp png_ptr, int level)
1481 if (png_ptr == NULL)
1484 png_ptr->flags |= PNG_FLAG_ZTXT_CUSTOM_LEVEL;
1485 png_ptr->zlib_text_level = level;
1489 png_set_text_compression_mem_level(png_structp png_ptr, int mem_level)
1493 if (png_ptr == NULL)
1496 png_ptr->flags |= PNG_FLAG_ZTXT_CUSTOM_MEM_LEVEL;
1497 png_ptr->zlib_text_mem_level = mem_level;
1501 png_set_text_compression_strategy(png_structp png_ptr, int strategy)
1505 if (png_ptr == NULL)
1508 png_ptr->flags |= PNG_FLAG_ZTXT_CUSTOM_STRATEGY;
1509 png_ptr->zlib_text_strategy = strategy;
1516 png_set_text_compression_window_bits(png_structp png_ptr, int window_bits)
1518 if (png_ptr == NULL)
1522 png_warning(png_ptr, "Only compression windows <= 32k supported by PNG");
1525 png_warning(png_ptr, "Only compression windows >= 256 supported by PNG");
1531 png_warning(png_ptr, "Text compression window is being reset to 512");
1536 png_ptr->flags |= PNG_FLAG_ZTXT_CUSTOM_WINDOW_BITS;
1537 png_ptr->zlib_text_window_bits = window_bits;
1541 png_set_text_compression_method(png_structp png_ptr, int method)
1545 if (png_ptr == NULL)
1549 png_warning(png_ptr, "Only compression method 8 is supported by PNG");
1551 png_ptr->flags |= PNG_FLAG_ZTXT_CUSTOM_METHOD;
1552 png_ptr->zlib_text_method = method;
1558 png_set_write_status_fn(png_structp png_ptr, png_write_status_ptr write_row_fn)
1560 if (png_ptr == NULL)
1563 png_ptr->write_row_fn = write_row_fn;
1568 png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
1573 if (png_ptr == NULL)
1576 png_ptr->transformations |= PNG_USER_TRANSFORM;
1577 png_ptr->write_user_transform_fn = write_user_transform_fn;
1584 png_write_png(png_structp png_ptr, png_infop info_ptr,
1587 if (png_ptr == NULL || info_ptr == NULL)
1591 png_write_info(png_ptr, info_ptr);
1598 png_set_invert_mono(png_ptr);
1607 png_set_shift(png_ptr, &info_ptr->sig_bit);
1613 png_set_packing(png_ptr);
1619 png_set_swap_alpha(png_ptr);
1625 png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
1628 png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
1634 png_set_bgr(png_ptr);
1640 png_set_swap(png_ptr);
1646 png_set_packswap(png_ptr);
1652 png_set_invert_alpha(png_ptr);
1659 png_write_image(png_ptr, info_ptr->row_pointers);
1662 png_write_end(png_ptr, info_ptr);