Lines Matching refs:png_ptr
51 png_write_sig(png_structrp png_ptr) in png_write_sig() argument
57 png_ptr->io_state = PNG_IO_WRITING | PNG_IO_SIGNATURE; in png_write_sig()
61 png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes], in png_write_sig()
62 (size_t)(8 - png_ptr->sig_bytes)); in png_write_sig()
64 if (png_ptr->sig_bytes < 3) in png_write_sig()
65 png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; in png_write_sig()
73 png_write_chunk_header(png_structrp png_ptr, png_uint_32 chunk_name, in png_write_chunk_header() argument
83 if (png_ptr == NULL) in png_write_chunk_header()
90 png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_HDR; in png_write_chunk_header()
96 png_write_data(png_ptr, buf, 8); in png_write_chunk_header()
99 png_ptr->chunk_name = chunk_name; in png_write_chunk_header()
102 png_reset_crc(png_ptr); in png_write_chunk_header()
104 png_calculate_crc(png_ptr, buf + 4, 4); in png_write_chunk_header()
110 png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_DATA; in png_write_chunk_header()
115 png_write_chunk_start(png_structrp png_ptr, png_const_bytep chunk_string, in png_write_chunk_start() argument
118 png_write_chunk_header(png_ptr, PNG_CHUNK_FROM_STRING(chunk_string), length); in png_write_chunk_start()
127 png_write_chunk_data(png_structrp png_ptr, png_const_bytep data, size_t length) in png_write_chunk_data() argument
130 if (png_ptr == NULL) in png_write_chunk_data()
135 png_write_data(png_ptr, data, length); in png_write_chunk_data()
140 png_calculate_crc(png_ptr, data, length); in png_write_chunk_data()
146 png_write_chunk_end(png_structrp png_ptr) in png_write_chunk_end() argument
150 if (png_ptr == NULL) return; in png_write_chunk_end()
156 png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_CRC; in png_write_chunk_end()
160 png_save_uint_32(buf, png_ptr->crc); in png_write_chunk_end()
162 png_write_data(png_ptr, buf, 4); in png_write_chunk_end()
175 png_write_complete_chunk(png_structrp png_ptr, png_uint_32 chunk_name, in png_write_complete_chunk() argument
178 if (png_ptr == NULL) in png_write_complete_chunk()
183 png_error(png_ptr, "length exceeds PNG maximum"); in png_write_complete_chunk()
185 png_write_chunk_header(png_ptr, chunk_name, (png_uint_32)length); in png_write_complete_chunk()
186 png_write_chunk_data(png_ptr, data, length); in png_write_complete_chunk()
187 png_write_chunk_end(png_ptr); in png_write_complete_chunk()
192 png_write_chunk(png_structrp png_ptr, png_const_bytep chunk_string, in png_write_chunk() argument
195 png_write_complete_chunk(png_ptr, PNG_CHUNK_FROM_STRING(chunk_string), data, in png_write_chunk()
204 png_image_size(png_structrp png_ptr) in png_image_size() argument
209 png_uint_32 h = png_ptr->height; in png_image_size()
211 if (png_ptr->rowbytes < 32768 && h < 32768) in png_image_size()
213 if (png_ptr->interlaced != 0) in png_image_size()
218 png_uint_32 w = png_ptr->width; in png_image_size()
219 unsigned int pd = png_ptr->pixel_depth; in png_image_size()
235 return (png_ptr->rowbytes+1) * h; in png_image_size()
292 png_deflate_claim(png_structrp png_ptr, png_uint_32 owner, in png_deflate_claim() argument
295 if (png_ptr->zowner != 0) in png_deflate_claim()
303 PNG_STRING_FROM_CHUNK(msg+6, png_ptr->zowner); in png_deflate_claim()
311 png_warning(png_ptr, msg); in png_deflate_claim()
314 if (png_ptr->zowner == png_IDAT) /* don't steal from IDAT */ in png_deflate_claim()
316 png_ptr->zstream.msg = PNGZ_MSG_CAST("in use by IDAT"); in png_deflate_claim()
320 png_ptr->zowner = 0; in png_deflate_claim()
322 png_error(png_ptr, msg); in png_deflate_claim()
327 int level = png_ptr->zlib_level; in png_deflate_claim()
328 int method = png_ptr->zlib_method; in png_deflate_claim()
329 int windowBits = png_ptr->zlib_window_bits; in png_deflate_claim()
330 int memLevel = png_ptr->zlib_mem_level; in png_deflate_claim()
336 if ((png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_STRATEGY) != 0) in png_deflate_claim()
337 strategy = png_ptr->zlib_strategy; in png_deflate_claim()
339 else if (png_ptr->do_filter != PNG_FILTER_NONE) in png_deflate_claim()
349 level = png_ptr->zlib_text_level; in png_deflate_claim()
350 method = png_ptr->zlib_text_method; in png_deflate_claim()
351 windowBits = png_ptr->zlib_text_window_bits; in png_deflate_claim()
352 memLevel = png_ptr->zlib_text_mem_level; in png_deflate_claim()
353 strategy = png_ptr->zlib_text_strategy; in png_deflate_claim()
388 if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0 && in png_deflate_claim()
389 (png_ptr->zlib_set_level != level || in png_deflate_claim()
390 png_ptr->zlib_set_method != method || in png_deflate_claim()
391 png_ptr->zlib_set_window_bits != windowBits || in png_deflate_claim()
392 png_ptr->zlib_set_mem_level != memLevel || in png_deflate_claim()
393 png_ptr->zlib_set_strategy != strategy)) in png_deflate_claim()
395 if (deflateEnd(&png_ptr->zstream) != Z_OK) in png_deflate_claim()
396 png_warning(png_ptr, "deflateEnd failed (ignored)"); in png_deflate_claim()
398 png_ptr->flags &= ~PNG_FLAG_ZSTREAM_INITIALIZED; in png_deflate_claim()
404 png_ptr->zstream.next_in = NULL; in png_deflate_claim()
405 png_ptr->zstream.avail_in = 0; in png_deflate_claim()
406 png_ptr->zstream.next_out = NULL; in png_deflate_claim()
407 png_ptr->zstream.avail_out = 0; in png_deflate_claim()
412 if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0) in png_deflate_claim()
413 ret = deflateReset(&png_ptr->zstream); in png_deflate_claim()
417 ret = deflateInit2(&png_ptr->zstream, level, method, windowBits, in png_deflate_claim()
421 png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED; in png_deflate_claim()
428 png_ptr->zowner = owner; in png_deflate_claim()
431 png_zstream_error(png_ptr, ret); in png_deflate_claim()
439 png_free_buffer_list(png_structrp png_ptr, png_compression_bufferp *listp) in png_free_buffer_list() argument
451 png_free(png_ptr, list); in png_free_buffer_list()
488 png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name, in png_text_compress() argument
503 ret = png_deflate_claim(png_ptr, chunk_name, comp->input_len); in png_text_compress()
515 png_compression_bufferp *end = &png_ptr->zbuffer_list; in png_text_compress()
520 png_ptr->zstream.next_in = PNGZ_INPUT_CAST(comp->input); in png_text_compress()
521 png_ptr->zstream.avail_in = 0; /* Set below */ in png_text_compress()
522 png_ptr->zstream.next_out = comp->output; in png_text_compress()
523 png_ptr->zstream.avail_out = (sizeof comp->output); in png_text_compress()
525 output_len = png_ptr->zstream.avail_out; in png_text_compress()
536 png_ptr->zstream.avail_in = avail_in; in png_text_compress()
538 if (png_ptr->zstream.avail_out == 0) in png_text_compress()
558 (png_ptr, PNG_COMPRESSION_BUFFER_SIZE(png_ptr))); in png_text_compress()
571 png_ptr->zstream.next_out = next->output; in png_text_compress()
572 png_ptr->zstream.avail_out = png_ptr->zbuffer_size; in png_text_compress()
573 output_len += png_ptr->zstream.avail_out; in png_text_compress()
580 ret = deflate(&png_ptr->zstream, in png_text_compress()
586 input_len += png_ptr->zstream.avail_in; in png_text_compress()
587 png_ptr->zstream.avail_in = 0; /* safety */ in png_text_compress()
594 output_len -= png_ptr->zstream.avail_out; in png_text_compress()
595 png_ptr->zstream.avail_out = 0; /* safety */ in png_text_compress()
604 png_ptr->zstream.msg = PNGZ_MSG_CAST("compressed data too long"); in png_text_compress()
609 png_zstream_error(png_ptr, ret); in png_text_compress()
612 png_ptr->zowner = 0; in png_text_compress()
637 png_write_compressed_data_out(png_structrp png_ptr, compression_state *comp) in png_write_compressed_data_out() argument
642 png_compression_buffer *next = png_ptr->zbuffer_list; in png_write_compressed_data_out()
649 png_write_chunk_data(png_ptr, output, avail); in png_write_compressed_data_out()
656 avail = png_ptr->zbuffer_size; in png_write_compressed_data_out()
663 png_error(png_ptr, "error writing ancillary chunked compressed data"); in png_write_compressed_data_out()
672 png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height, in png_write_IHDR() argument
694 png_ptr->channels = 1; break; in png_write_IHDR()
697 png_error(png_ptr, in png_write_IHDR()
708 png_error(png_ptr, "Invalid bit depth for RGB image"); in png_write_IHDR()
710 png_ptr->channels = 3; in png_write_IHDR()
720 png_ptr->channels = 1; in png_write_IHDR()
724 png_error(png_ptr, "Invalid bit depth for paletted image"); in png_write_IHDR()
734 png_error(png_ptr, "Invalid bit depth for grayscale+alpha image"); in png_write_IHDR()
736 png_ptr->channels = 2; in png_write_IHDR()
745 png_error(png_ptr, "Invalid bit depth for RGBA image"); in png_write_IHDR()
747 png_ptr->channels = 4; in png_write_IHDR()
751 png_error(png_ptr, "Invalid image color type specified"); in png_write_IHDR()
756 png_warning(png_ptr, "Invalid compression type specified"); in png_write_IHDR()
771 !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 && in png_write_IHDR()
772 ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) == 0) && in png_write_IHDR()
779 png_warning(png_ptr, "Invalid filter type specified"); in png_write_IHDR()
787 png_warning(png_ptr, "Invalid interlace type specified"); in png_write_IHDR()
795 png_ptr->bit_depth = (png_byte)bit_depth; in png_write_IHDR()
796 png_ptr->color_type = (png_byte)color_type; in png_write_IHDR()
797 png_ptr->interlaced = (png_byte)interlace_type; in png_write_IHDR()
799 png_ptr->filter_type = (png_byte)filter_type; in png_write_IHDR()
801 png_ptr->compression_type = (png_byte)compression_type; in png_write_IHDR()
802 png_ptr->width = width; in png_write_IHDR()
803 png_ptr->height = height; in png_write_IHDR()
805 png_ptr->pixel_depth = (png_byte)(bit_depth * png_ptr->channels); in png_write_IHDR()
806 png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width); in png_write_IHDR()
808 png_ptr->usr_width = png_ptr->width; in png_write_IHDR()
809 png_ptr->usr_bit_depth = png_ptr->bit_depth; in png_write_IHDR()
810 png_ptr->usr_channels = png_ptr->channels; in png_write_IHDR()
822 png_write_complete_chunk(png_ptr, png_IHDR, buf, 13); in png_write_IHDR()
824 if ((png_ptr->do_filter) == PNG_NO_FILTERS) in png_write_IHDR()
826 if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE || in png_write_IHDR()
827 png_ptr->bit_depth < 8) in png_write_IHDR()
828 png_ptr->do_filter = PNG_FILTER_NONE; in png_write_IHDR()
831 png_ptr->do_filter = PNG_ALL_FILTERS; in png_write_IHDR()
834 png_ptr->mode = PNG_HAVE_IHDR; /* not READY_FOR_ZTXT */ in png_write_IHDR()
842 png_write_PLTE(png_structrp png_ptr, png_const_colorp palette, in png_write_PLTE() argument
851 max_palette_length = (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ? in png_write_PLTE()
852 (1 << png_ptr->bit_depth) : PNG_MAX_PALETTE_LENGTH; in png_write_PLTE()
856 (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0 && in png_write_PLTE()
860 if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) in png_write_PLTE()
862 png_error(png_ptr, "Invalid number of colors in palette"); in png_write_PLTE()
867 png_warning(png_ptr, "Invalid number of colors in palette"); in png_write_PLTE()
872 if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0) in png_write_PLTE()
874 png_warning(png_ptr, in png_write_PLTE()
880 png_ptr->num_palette = (png_uint_16)num_pal; in png_write_PLTE()
881 png_debug1(3, "num_palette = %d", png_ptr->num_palette); in png_write_PLTE()
883 png_write_chunk_header(png_ptr, png_PLTE, (png_uint_32)(num_pal * 3)); in png_write_PLTE()
891 png_write_chunk_data(png_ptr, buf, 3); in png_write_PLTE()
905 png_write_chunk_data(png_ptr, buf, 3); in png_write_PLTE()
909 png_write_chunk_end(png_ptr); in png_write_PLTE()
910 png_ptr->mode |= PNG_HAVE_PLTE; in png_write_PLTE()
931 png_compress_IDAT(png_structrp png_ptr, png_const_bytep input, in png_compress_IDAT() argument
934 if (png_ptr->zowner != png_IDAT) in png_compress_IDAT()
941 if (png_ptr->zbuffer_list == NULL) in png_compress_IDAT()
943 png_ptr->zbuffer_list = png_voidcast(png_compression_bufferp, in png_compress_IDAT()
944 png_malloc(png_ptr, PNG_COMPRESSION_BUFFER_SIZE(png_ptr))); in png_compress_IDAT()
945 png_ptr->zbuffer_list->next = NULL; in png_compress_IDAT()
949 png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list->next); in png_compress_IDAT()
952 if (png_deflate_claim(png_ptr, png_IDAT, png_image_size(png_ptr)) != Z_OK) in png_compress_IDAT()
953 png_error(png_ptr, png_ptr->zstream.msg); in png_compress_IDAT()
958 png_ptr->zstream.next_out = png_ptr->zbuffer_list->output; in png_compress_IDAT()
959 png_ptr->zstream.avail_out = png_ptr->zbuffer_size; in png_compress_IDAT()
966 png_ptr->zstream.next_in = PNGZ_INPUT_CAST(input); in png_compress_IDAT()
967 png_ptr->zstream.avail_in = 0; /* set below */ in png_compress_IDAT()
978 png_ptr->zstream.avail_in = avail; in png_compress_IDAT()
981 ret = deflate(&png_ptr->zstream, input_len > 0 ? Z_NO_FLUSH : flush); in png_compress_IDAT()
984 input_len += png_ptr->zstream.avail_in; in png_compress_IDAT()
985 png_ptr->zstream.avail_in = 0; in png_compress_IDAT()
991 if (png_ptr->zstream.avail_out == 0) in png_compress_IDAT()
993 png_bytep data = png_ptr->zbuffer_list->output; in png_compress_IDAT()
994 uInt size = png_ptr->zbuffer_size; in png_compress_IDAT()
1000 if ((png_ptr->mode & PNG_HAVE_IDAT) == 0 && in png_compress_IDAT()
1001 png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE) in png_compress_IDAT()
1002 optimize_cmf(data, png_image_size(png_ptr)); in png_compress_IDAT()
1006 png_write_complete_chunk(png_ptr, png_IDAT, data, size); in png_compress_IDAT()
1007 png_ptr->mode |= PNG_HAVE_IDAT; in png_compress_IDAT()
1009 png_ptr->zstream.next_out = data; in png_compress_IDAT()
1010 png_ptr->zstream.avail_out = size; in png_compress_IDAT()
1032 png_error(png_ptr, "Z_OK on Z_FINISH with output space"); in png_compress_IDAT()
1043 png_bytep data = png_ptr->zbuffer_list->output; in png_compress_IDAT()
1044 uInt size = png_ptr->zbuffer_size - png_ptr->zstream.avail_out; in png_compress_IDAT()
1047 if ((png_ptr->mode & PNG_HAVE_IDAT) == 0 && in png_compress_IDAT()
1048 png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE) in png_compress_IDAT()
1049 optimize_cmf(data, png_image_size(png_ptr)); in png_compress_IDAT()
1053 png_write_complete_chunk(png_ptr, png_IDAT, data, size); in png_compress_IDAT()
1054 png_ptr->zstream.avail_out = 0; in png_compress_IDAT()
1055 png_ptr->zstream.next_out = NULL; in png_compress_IDAT()
1056 png_ptr->mode |= PNG_HAVE_IDAT | PNG_AFTER_IDAT; in png_compress_IDAT()
1058 png_ptr->zowner = 0; /* Release the stream */ in png_compress_IDAT()
1065 png_zstream_error(png_ptr, ret); in png_compress_IDAT()
1066 png_error(png_ptr, png_ptr->zstream.msg); in png_compress_IDAT()
1073 png_write_IEND(png_structrp png_ptr) in png_write_IEND() argument
1077 png_write_complete_chunk(png_ptr, png_IEND, NULL, 0); in png_write_IEND()
1078 png_ptr->mode |= PNG_HAVE_IEND; in png_write_IEND()
1084 png_write_gAMA_fixed(png_structrp png_ptr, png_fixed_point file_gamma) in png_write_gAMA_fixed() argument
1092 png_write_complete_chunk(png_ptr, png_gAMA, buf, 4); in png_write_gAMA_fixed()
1099 png_write_sRGB(png_structrp png_ptr, int srgb_intent) in png_write_sRGB() argument
1106 png_warning(png_ptr, in png_write_sRGB()
1110 png_write_complete_chunk(png_ptr, png_sRGB, buf, 1); in png_write_sRGB()
1117 png_write_iCCP(png_structrp png_ptr, png_const_charp name, in png_write_iCCP() argument
1132 png_error(png_ptr, "No profile for iCCP chunk"); /* internal error */ in png_write_iCCP()
1137 png_error(png_ptr, "ICC profile too short"); in png_write_iCCP()
1141 png_error(png_ptr, "ICC profile length invalid (not a multiple of 4)"); in png_write_iCCP()
1147 png_error(png_ptr, "Profile length does not match profile"); in png_write_iCCP()
1150 name_len = png_check_keyword(png_ptr, name, new_name); in png_write_iCCP()
1153 png_error(png_ptr, "iCCP: invalid keyword"); in png_write_iCCP()
1163 if (png_text_compress(png_ptr, png_iCCP, &comp, name_len) != Z_OK) in png_write_iCCP()
1164 png_error(png_ptr, png_ptr->zstream.msg); in png_write_iCCP()
1166 png_write_chunk_header(png_ptr, png_iCCP, name_len + comp.output_len); in png_write_iCCP()
1168 png_write_chunk_data(png_ptr, new_name, name_len); in png_write_iCCP()
1170 png_write_compressed_data_out(png_ptr, &comp); in png_write_iCCP()
1172 png_write_chunk_end(png_ptr); in png_write_iCCP()
1179 png_write_sPLT(png_structrp png_ptr, png_const_sPLT_tp spalette) in png_write_sPLT() argument
1193 name_len = png_check_keyword(png_ptr, spalette->name, new_name); in png_write_sPLT()
1196 png_error(png_ptr, "sPLT: invalid keyword"); in png_write_sPLT()
1199 png_write_chunk_header(png_ptr, png_sPLT, in png_write_sPLT()
1202 png_write_chunk_data(png_ptr, (png_bytep)new_name, (size_t)(name_len + 1)); in png_write_sPLT()
1204 png_write_chunk_data(png_ptr, &spalette->depth, 1); in png_write_sPLT()
1228 png_write_chunk_data(png_ptr, entrybuf, entry_size); in png_write_sPLT()
1252 png_write_chunk_data(png_ptr, entrybuf, entry_size); in png_write_sPLT()
1256 png_write_chunk_end(png_ptr); in png_write_sPLT()
1263 png_write_sBIT(png_structrp png_ptr, png_const_color_8p sbit, int color_type) in png_write_sBIT() argument
1276 png_ptr->usr_bit_depth); in png_write_sBIT()
1282 png_warning(png_ptr, "Invalid sBIT depth specified"); in png_write_sBIT()
1294 if (sbit->gray == 0 || sbit->gray > png_ptr->usr_bit_depth) in png_write_sBIT()
1296 png_warning(png_ptr, "Invalid sBIT depth specified"); in png_write_sBIT()
1306 if (sbit->alpha == 0 || sbit->alpha > png_ptr->usr_bit_depth) in png_write_sBIT()
1308 png_warning(png_ptr, "Invalid sBIT depth specified"); in png_write_sBIT()
1315 png_write_complete_chunk(png_ptr, png_sBIT, buf, size); in png_write_sBIT()
1322 png_write_cHRM_fixed(png_structrp png_ptr, const png_xy *xy) in png_write_cHRM_fixed() argument
1341 png_write_complete_chunk(png_ptr, png_cHRM, buf, 32); in png_write_cHRM_fixed()
1348 png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha, in png_write_tRNS() argument
1357 if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette) in png_write_tRNS()
1359 png_app_warning(png_ptr, in png_write_tRNS()
1365 png_write_complete_chunk(png_ptr, png_tRNS, trans_alpha, in png_write_tRNS()
1372 if (tran->gray >= (1 << png_ptr->bit_depth)) in png_write_tRNS()
1374 png_app_warning(png_ptr, in png_write_tRNS()
1381 png_write_complete_chunk(png_ptr, png_tRNS, buf, 2); in png_write_tRNS()
1391 if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]) != 0) in png_write_tRNS()
1396 png_app_warning(png_ptr, in png_write_tRNS()
1401 png_write_complete_chunk(png_ptr, png_tRNS, buf, 6); in png_write_tRNS()
1406 png_app_warning(png_ptr, "Can't write tRNS with an alpha channel"); in png_write_tRNS()
1414 png_write_bKGD(png_structrp png_ptr, png_const_color_16p back, int color_type) in png_write_bKGD() argument
1424 (png_ptr->num_palette != 0 || in png_write_bKGD()
1425 (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0) && in png_write_bKGD()
1427 back->index >= png_ptr->num_palette) in png_write_bKGD()
1429 png_warning(png_ptr, "Invalid background palette index"); in png_write_bKGD()
1434 png_write_complete_chunk(png_ptr, png_bKGD, buf, 1); in png_write_bKGD()
1443 if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]) != 0) in png_write_bKGD()
1448 png_warning(png_ptr, in png_write_bKGD()
1455 png_write_complete_chunk(png_ptr, png_bKGD, buf, 6); in png_write_bKGD()
1460 if (back->gray >= (1 << png_ptr->bit_depth)) in png_write_bKGD()
1462 png_warning(png_ptr, in png_write_bKGD()
1469 png_write_complete_chunk(png_ptr, png_bKGD, buf, 2); in png_write_bKGD()
1477 png_write_eXIf(png_structrp png_ptr, png_bytep exif, int num_exif) in png_write_eXIf() argument
1484 png_write_chunk_header(png_ptr, png_eXIf, (png_uint_32)(num_exif)); in png_write_eXIf()
1489 png_write_chunk_data(png_ptr, buf, 1); in png_write_eXIf()
1492 png_write_chunk_end(png_ptr); in png_write_eXIf()
1499 png_write_hIST(png_structrp png_ptr, png_const_uint_16p hist, int num_hist) in png_write_hIST() argument
1506 if (num_hist > (int)png_ptr->num_palette) in png_write_hIST()
1509 png_ptr->num_palette); in png_write_hIST()
1511 png_warning(png_ptr, "Invalid number of histogram entries specified"); in png_write_hIST()
1515 png_write_chunk_header(png_ptr, png_hIST, (png_uint_32)(num_hist * 2)); in png_write_hIST()
1520 png_write_chunk_data(png_ptr, buf, 2); in png_write_hIST()
1523 png_write_chunk_end(png_ptr); in png_write_hIST()
1530 png_write_tEXt(png_structrp png_ptr, png_const_charp key, png_const_charp text, in png_write_tEXt() argument
1538 key_len = png_check_keyword(png_ptr, key, new_key); in png_write_tEXt()
1541 png_error(png_ptr, "tEXt: invalid keyword"); in png_write_tEXt()
1550 png_error(png_ptr, "tEXt: text too long"); in png_write_tEXt()
1553 png_write_chunk_header(png_ptr, png_tEXt, in png_write_tEXt()
1561 png_write_chunk_data(png_ptr, new_key, key_len + 1); in png_write_tEXt()
1564 png_write_chunk_data(png_ptr, (png_const_bytep)text, text_len); in png_write_tEXt()
1566 png_write_chunk_end(png_ptr); in png_write_tEXt()
1573 png_write_zTXt(png_structrp png_ptr, png_const_charp key, png_const_charp text, in png_write_zTXt() argument
1584 png_write_tEXt(png_ptr, key, text, 0); in png_write_zTXt()
1589 png_error(png_ptr, "zTXt: invalid compression type"); in png_write_zTXt()
1591 key_len = png_check_keyword(png_ptr, key, new_key); in png_write_zTXt()
1594 png_error(png_ptr, "zTXt: invalid keyword"); in png_write_zTXt()
1604 if (png_text_compress(png_ptr, png_zTXt, &comp, key_len) != Z_OK) in png_write_zTXt()
1605 png_error(png_ptr, png_ptr->zstream.msg); in png_write_zTXt()
1608 png_write_chunk_header(png_ptr, png_zTXt, key_len + comp.output_len); in png_write_zTXt()
1611 png_write_chunk_data(png_ptr, new_key, key_len); in png_write_zTXt()
1614 png_write_compressed_data_out(png_ptr, &comp); in png_write_zTXt()
1617 png_write_chunk_end(png_ptr); in png_write_zTXt()
1624 png_write_iTXt(png_structrp png_ptr, int compression, png_const_charp key, in png_write_iTXt() argument
1634 key_len = png_check_keyword(png_ptr, key, new_key); in png_write_iTXt()
1637 png_error(png_ptr, "iTXt: invalid keyword"); in png_write_iTXt()
1653 png_error(png_ptr, "iTXt: invalid compression"); in png_write_iTXt()
1690 if (png_text_compress(png_ptr, png_iTXt, &comp, prefix_len) != Z_OK) in png_write_iTXt()
1691 png_error(png_ptr, png_ptr->zstream.msg); in png_write_iTXt()
1697 png_error(png_ptr, "iTXt: uncompressed text too long"); in png_write_iTXt()
1703 png_write_chunk_header(png_ptr, png_iTXt, comp.output_len + prefix_len); in png_write_iTXt()
1705 png_write_chunk_data(png_ptr, new_key, key_len); in png_write_iTXt()
1707 png_write_chunk_data(png_ptr, (png_const_bytep)lang, lang_len); in png_write_iTXt()
1709 png_write_chunk_data(png_ptr, (png_const_bytep)lang_key, lang_key_len); in png_write_iTXt()
1712 png_write_compressed_data_out(png_ptr, &comp); in png_write_iTXt()
1715 png_write_chunk_data(png_ptr, (png_const_bytep)text, comp.output_len); in png_write_iTXt()
1717 png_write_chunk_end(png_ptr); in png_write_iTXt()
1724 png_write_oFFs(png_structrp png_ptr, png_int_32 x_offset, png_int_32 y_offset, in png_write_oFFs() argument
1732 png_warning(png_ptr, "Unrecognized unit type for oFFs chunk"); in png_write_oFFs()
1738 png_write_complete_chunk(png_ptr, png_oFFs, buf, 9); in png_write_oFFs()
1744 png_write_pCAL(png_structrp png_ptr, png_charp purpose, png_int_32 X0, in png_write_pCAL() argument
1758 png_error(png_ptr, "Unrecognized equation type for pCAL chunk"); in png_write_pCAL()
1760 purpose_len = png_check_keyword(png_ptr, purpose, new_purpose); in png_write_pCAL()
1763 png_error(png_ptr, "pCAL: invalid keyword"); in png_write_pCAL()
1772 params_len = (png_size_tp)png_malloc(png_ptr, in png_write_pCAL()
1787 png_write_chunk_header(png_ptr, png_pCAL, (png_uint_32)total_len); in png_write_pCAL()
1788 png_write_chunk_data(png_ptr, new_purpose, purpose_len); in png_write_pCAL()
1793 png_write_chunk_data(png_ptr, buf, 10); in png_write_pCAL()
1794 png_write_chunk_data(png_ptr, (png_const_bytep)units, (size_t)units_len); in png_write_pCAL()
1798 png_write_chunk_data(png_ptr, (png_const_bytep)params[i], params_len[i]); in png_write_pCAL()
1801 png_free(png_ptr, params_len); in png_write_pCAL()
1802 png_write_chunk_end(png_ptr); in png_write_pCAL()
1809 png_write_sCAL_s(png_structrp png_ptr, int unit, png_const_charp width, in png_write_sCAL_s() argument
1823 png_warning(png_ptr, "Can't write sCAL (buffer too small)"); in png_write_sCAL_s()
1832 png_write_complete_chunk(png_ptr, png_sCAL, buf, total_len); in png_write_sCAL_s()
1839 png_write_pHYs(png_structrp png_ptr, png_uint_32 x_pixels_per_unit, in png_write_pHYs() argument
1848 png_warning(png_ptr, "Unrecognized unit type for pHYs chunk"); in png_write_pHYs()
1854 png_write_complete_chunk(png_ptr, png_pHYs, buf, 9); in png_write_pHYs()
1863 png_write_tIME(png_structrp png_ptr, png_const_timep mod_time) in png_write_tIME() argument
1873 png_warning(png_ptr, "Invalid time specified for tIME chunk"); in png_write_tIME()
1884 png_write_complete_chunk(png_ptr, png_tIME, buf, 7); in png_write_tIME()
1890 png_write_start_row(png_structrp png_ptr) in png_write_start_row() argument
1917 usr_pixel_depth = png_ptr->usr_channels * png_ptr->usr_bit_depth; in png_write_start_row()
1918 buf_size = PNG_ROWBYTES(usr_pixel_depth, png_ptr->width) + 1; in png_write_start_row()
1921 png_ptr->transformed_pixel_depth = png_ptr->pixel_depth; in png_write_start_row()
1922 png_ptr->maximum_pixel_depth = (png_byte)usr_pixel_depth; in png_write_start_row()
1925 png_ptr->row_buf = png_voidcast(png_bytep, png_malloc(png_ptr, buf_size)); in png_write_start_row()
1927 png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE; in png_write_start_row()
1930 filters = png_ptr->do_filter; in png_write_start_row()
1932 if (png_ptr->height == 1) in png_write_start_row()
1935 if (png_ptr->width == 1) in png_write_start_row()
1941 png_ptr->do_filter = filters; in png_write_start_row()
1944 PNG_FILTER_PAETH)) != 0) && png_ptr->try_row == NULL) in png_write_start_row()
1948 png_ptr->try_row = png_voidcast(png_bytep, png_malloc(png_ptr, buf_size)); in png_write_start_row()
1963 png_ptr->tst_row = png_voidcast(png_bytep, png_malloc(png_ptr, in png_write_start_row()
1971 png_ptr->prev_row = png_voidcast(png_bytep, in png_write_start_row()
1972 png_calloc(png_ptr, buf_size)); in png_write_start_row()
1977 if (png_ptr->interlaced != 0) in png_write_start_row()
1979 if ((png_ptr->transformations & PNG_INTERLACE) == 0) in png_write_start_row()
1981 png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 - in png_write_start_row()
1984 png_ptr->usr_width = (png_ptr->width + png_pass_inc[0] - 1 - in png_write_start_row()
1990 png_ptr->num_rows = png_ptr->height; in png_write_start_row()
1991 png_ptr->usr_width = png_ptr->width; in png_write_start_row()
1998 png_ptr->num_rows = png_ptr->height; in png_write_start_row()
1999 png_ptr->usr_width = png_ptr->width; in png_write_start_row()
2005 png_write_finish_row(png_structrp png_ptr) in png_write_finish_row() argument
2026 png_ptr->row_number++; in png_write_finish_row()
2029 if (png_ptr->row_number < png_ptr->num_rows) in png_write_finish_row()
2034 if (png_ptr->interlaced != 0) in png_write_finish_row()
2036 png_ptr->row_number = 0; in png_write_finish_row()
2037 if ((png_ptr->transformations & PNG_INTERLACE) != 0) in png_write_finish_row()
2039 png_ptr->pass++; in png_write_finish_row()
2047 png_ptr->pass++; in png_write_finish_row()
2049 if (png_ptr->pass >= 7) in png_write_finish_row()
2052 png_ptr->usr_width = (png_ptr->width + in png_write_finish_row()
2053 png_pass_inc[png_ptr->pass] - 1 - in png_write_finish_row()
2054 png_pass_start[png_ptr->pass]) / in png_write_finish_row()
2055 png_pass_inc[png_ptr->pass]; in png_write_finish_row()
2057 png_ptr->num_rows = (png_ptr->height + in png_write_finish_row()
2058 png_pass_yinc[png_ptr->pass] - 1 - in png_write_finish_row()
2059 png_pass_ystart[png_ptr->pass]) / in png_write_finish_row()
2060 png_pass_yinc[png_ptr->pass]; in png_write_finish_row()
2062 if ((png_ptr->transformations & PNG_INTERLACE) != 0) in png_write_finish_row()
2065 } while (png_ptr->usr_width == 0 || png_ptr->num_rows == 0); in png_write_finish_row()
2070 if (png_ptr->pass < 7) in png_write_finish_row()
2072 if (png_ptr->prev_row != NULL) in png_write_finish_row()
2073 memset(png_ptr->prev_row, 0, in png_write_finish_row()
2074 PNG_ROWBYTES(png_ptr->usr_channels * in png_write_finish_row()
2075 png_ptr->usr_bit_depth, png_ptr->width) + 1); in png_write_finish_row()
2084 png_compress_IDAT(png_ptr, NULL, 0, Z_FINISH); in png_write_finish_row()
2274 png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
2279 png_setup_sub_row(png_structrp png_ptr, png_uint_32 bpp, in png_setup_sub_row() argument
2287 png_ptr->try_row[0] = PNG_FILTER_VALUE_SUB; in png_setup_sub_row()
2289 for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1; i < bpp; in png_setup_sub_row()
2300 for (lp = png_ptr->row_buf + 1; i < row_bytes; in png_setup_sub_row()
2318 png_setup_sub_row_only(png_structrp png_ptr, png_uint_32 bpp, in png_setup_sub_row_only() argument
2324 png_ptr->try_row[0] = PNG_FILTER_VALUE_SUB; in png_setup_sub_row_only()
2326 for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1; i < bpp; in png_setup_sub_row_only()
2332 for (lp = png_ptr->row_buf + 1; i < row_bytes; in png_setup_sub_row_only()
2340 png_setup_up_row(png_structrp png_ptr, size_t row_bytes, size_t lmins) in png_setup_up_row() argument
2347 png_ptr->try_row[0] = PNG_FILTER_VALUE_UP; in png_setup_up_row()
2349 for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, in png_setup_up_row()
2350 pp = png_ptr->prev_row + 1; i < row_bytes; in png_setup_up_row()
2367 png_setup_up_row_only(png_structrp png_ptr, size_t row_bytes) in png_setup_up_row_only() argument
2372 png_ptr->try_row[0] = PNG_FILTER_VALUE_UP; in png_setup_up_row_only()
2374 for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, in png_setup_up_row_only()
2375 pp = png_ptr->prev_row + 1; i < row_bytes; in png_setup_up_row_only()
2383 png_setup_avg_row(png_structrp png_ptr, png_uint_32 bpp, in png_setup_avg_row() argument
2391 png_ptr->try_row[0] = PNG_FILTER_VALUE_AVG; in png_setup_avg_row()
2393 for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, in png_setup_avg_row()
2394 pp = png_ptr->prev_row + 1; i < bpp; i++) in png_setup_avg_row()
2405 for (lp = png_ptr->row_buf + 1; i < row_bytes; i++) in png_setup_avg_row()
2423 png_setup_avg_row_only(png_structrp png_ptr, png_uint_32 bpp, in png_setup_avg_row_only() argument
2429 png_ptr->try_row[0] = PNG_FILTER_VALUE_AVG; in png_setup_avg_row_only()
2431 for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, in png_setup_avg_row_only()
2432 pp = png_ptr->prev_row + 1; i < bpp; i++) in png_setup_avg_row_only()
2437 for (lp = png_ptr->row_buf + 1; i < row_bytes; i++) in png_setup_avg_row_only()
2445 png_setup_paeth_row(png_structrp png_ptr, png_uint_32 bpp, in png_setup_paeth_row() argument
2453 png_ptr->try_row[0] = PNG_FILTER_VALUE_PAETH; in png_setup_paeth_row()
2455 for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, in png_setup_paeth_row()
2456 pp = png_ptr->prev_row + 1; i < bpp; i++) in png_setup_paeth_row()
2467 for (lp = png_ptr->row_buf + 1, cp = png_ptr->prev_row + 1; i < row_bytes; in png_setup_paeth_row()
2506 png_setup_paeth_row_only(png_structrp png_ptr, png_uint_32 bpp, in png_setup_paeth_row_only() argument
2512 png_ptr->try_row[0] = PNG_FILTER_VALUE_PAETH; in png_setup_paeth_row_only()
2514 for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, in png_setup_paeth_row_only()
2515 pp = png_ptr->prev_row + 1; i < bpp; i++) in png_setup_paeth_row_only()
2520 for (lp = png_ptr->row_buf + 1, cp = png_ptr->prev_row + 1; i < row_bytes; in png_setup_paeth_row_only()
2550 png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) in png_write_find_filter() argument
2553 png_write_filtered_row(png_ptr, png_ptr->row_buf, row_info->rowbytes+1); in png_write_find_filter()
2555 unsigned int filter_to_do = png_ptr->do_filter; in png_write_find_filter()
2567 row_buf = png_ptr->row_buf; in png_write_find_filter()
2599 best_row = png_ptr->row_buf; in png_write_find_filter()
2638 png_setup_sub_row_only(png_ptr, bpp, row_bytes); in png_write_find_filter()
2639 best_row = png_ptr->try_row; in png_write_find_filter()
2647 sum = png_setup_sub_row(png_ptr, bpp, row_bytes, lmins); in png_write_find_filter()
2652 best_row = png_ptr->try_row; in png_write_find_filter()
2653 if (png_ptr->tst_row != NULL) in png_write_find_filter()
2655 png_ptr->try_row = png_ptr->tst_row; in png_write_find_filter()
2656 png_ptr->tst_row = best_row; in png_write_find_filter()
2664 png_setup_up_row_only(png_ptr, row_bytes); in png_write_find_filter()
2665 best_row = png_ptr->try_row; in png_write_find_filter()
2673 sum = png_setup_up_row(png_ptr, row_bytes, lmins); in png_write_find_filter()
2678 best_row = png_ptr->try_row; in png_write_find_filter()
2679 if (png_ptr->tst_row != NULL) in png_write_find_filter()
2681 png_ptr->try_row = png_ptr->tst_row; in png_write_find_filter()
2682 png_ptr->tst_row = best_row; in png_write_find_filter()
2690 png_setup_avg_row_only(png_ptr, bpp, row_bytes); in png_write_find_filter()
2691 best_row = png_ptr->try_row; in png_write_find_filter()
2699 sum= png_setup_avg_row(png_ptr, bpp, row_bytes, lmins); in png_write_find_filter()
2704 best_row = png_ptr->try_row; in png_write_find_filter()
2705 if (png_ptr->tst_row != NULL) in png_write_find_filter()
2707 png_ptr->try_row = png_ptr->tst_row; in png_write_find_filter()
2708 png_ptr->tst_row = best_row; in png_write_find_filter()
2716 png_setup_paeth_row_only(png_ptr, bpp, row_bytes); in png_write_find_filter()
2717 best_row = png_ptr->try_row; in png_write_find_filter()
2725 sum = png_setup_paeth_row(png_ptr, bpp, row_bytes, lmins); in png_write_find_filter()
2729 best_row = png_ptr->try_row; in png_write_find_filter()
2730 if (png_ptr->tst_row != NULL) in png_write_find_filter()
2732 png_ptr->try_row = png_ptr->tst_row; in png_write_find_filter()
2733 png_ptr->tst_row = best_row; in png_write_find_filter()
2739 png_write_filtered_row(png_ptr, best_row, row_info->rowbytes+1); in png_write_find_filter()
2747 png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row, in png_write_filtered_row() argument
2754 png_compress_IDAT(png_ptr, filtered_row, full_row_length, Z_NO_FLUSH); in png_write_filtered_row()
2758 if (png_ptr->prev_row != NULL) in png_write_filtered_row()
2762 tptr = png_ptr->prev_row; in png_write_filtered_row()
2763 png_ptr->prev_row = png_ptr->row_buf; in png_write_filtered_row()
2764 png_ptr->row_buf = tptr; in png_write_filtered_row()
2769 png_write_finish_row(png_ptr); in png_write_filtered_row()
2772 png_ptr->flush_rows++; in png_write_filtered_row()
2774 if (png_ptr->flush_dist > 0 && in png_write_filtered_row()
2775 png_ptr->flush_rows >= png_ptr->flush_dist) in png_write_filtered_row()
2777 png_write_flush(png_ptr); in png_write_filtered_row()