14 #ifdef PNG_WRITE_SUPPORTED 28 png_debug(1,
"in png_write_info_before_PLTE\n");
29 if (png_ptr == NULL || info_ptr == NULL)
31 if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE))
34 #if defined(PNG_MNG_FEATURES_SUPPORTED) 35 if ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&(png_ptr->mng_features_permitted))
37 png_warning(png_ptr,
"MNG features are not allowed in a PNG datastream");
38 png_ptr->mng_features_permitted=0;
43 info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type,
44 info_ptr->filter_type,
46 info_ptr->interlace_type);
52 #if defined(PNG_WRITE_gAMA_SUPPORTED) 55 # ifdef PNG_FLOATING_POINT_SUPPORTED 58 #ifdef PNG_FIXED_POINT_SUPPORTED 64 #if defined(PNG_WRITE_sRGB_SUPPORTED) 68 #if defined(PNG_WRITE_iCCP_SUPPORTED) 71 info_ptr->iccp_profile, (
int)info_ptr->iccp_proflen);
73 #if defined(PNG_WRITE_sBIT_SUPPORTED) 75 png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type);
77 #if defined(PNG_WRITE_cHRM_SUPPORTED) 80 #ifdef PNG_FLOATING_POINT_SUPPORTED 82 info_ptr->x_white, info_ptr->y_white,
83 info_ptr->x_red, info_ptr->y_red,
84 info_ptr->x_green, info_ptr->y_green,
85 info_ptr->x_blue, info_ptr->y_blue);
87 # ifdef PNG_FIXED_POINT_SUPPORTED 89 info_ptr->int_x_white, info_ptr->int_y_white,
90 info_ptr->int_x_red, info_ptr->int_y_red,
91 info_ptr->int_x_green, info_ptr->int_y_green,
92 info_ptr->int_x_blue, info_ptr->int_y_blue);
97 #if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) 98 if (info_ptr->unknown_chunks_num)
104 for (up = info_ptr->unknown_chunks;
105 up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
113 (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
116 png_warning(png_ptr,
"Writing zero-length unknown chunk");
122 png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE;
129 #if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) 135 if (png_ptr == NULL || info_ptr == NULL)
144 png_error(png_ptr,
"Valid palette required for paletted images");
146 #if defined(PNG_WRITE_tRNS_SUPPORTED) 149 #if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) 151 if ((png_ptr->transformations & PNG_INVERT_ALPHA) &&
155 for (j=0; j<(
int)info_ptr->num_trans; j++)
156 info_ptr->trans[j] = (
png_byte)(255 - info_ptr->trans[j]);
159 png_write_tRNS(png_ptr, info_ptr->trans, &(info_ptr->trans_values),
160 info_ptr->num_trans, info_ptr->color_type);
163 #if defined(PNG_WRITE_bKGD_SUPPORTED) 165 png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type);
167 #if defined(PNG_WRITE_hIST_SUPPORTED) 171 #if defined(PNG_WRITE_oFFs_SUPPORTED) 174 info_ptr->offset_unit_type);
176 #if defined(PNG_WRITE_pCAL_SUPPORTED) 178 png_write_pCAL(png_ptr, info_ptr->pcal_purpose, info_ptr->pcal_X0,
179 info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams,
180 info_ptr->pcal_units, info_ptr->pcal_params);
182 #if defined(PNG_WRITE_sCAL_SUPPORTED) 184 #if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) 186 info_ptr->scal_pixel_width, info_ptr->scal_pixel_height);
188 #ifdef PNG_FIXED_POINT_SUPPORTED 189 png_write_sCAL_s(png_ptr, (
int)info_ptr->scal_unit,
190 info_ptr->scal_s_width, info_ptr->scal_s_height);
193 "png_write_sCAL not supported; sCAL chunk not written.");
197 #if defined(PNG_WRITE_pHYs_SUPPORTED) 200 info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type);
202 #if defined(PNG_WRITE_tIME_SUPPORTED) 206 png_ptr->mode |= PNG_WROTE_tIME;
209 #if defined(PNG_WRITE_sPLT_SUPPORTED) 211 for (i = 0; i < (
int)info_ptr->splt_palettes_num; i++)
214 #if defined(PNG_WRITE_TEXT_SUPPORTED) 216 for (i = 0; i < info_ptr->num_text; i++)
218 png_debug2(2,
"Writing header text chunk %d, type %d\n", i,
219 info_ptr->text[i].compression);
221 if (info_ptr->text[i].compression > 0)
223 #if defined(PNG_WRITE_iTXt_SUPPORTED) 225 png_write_iTXt(png_ptr,
226 info_ptr->text[i].compression,
227 info_ptr->text[i].key,
228 info_ptr->text[i].lang,
229 info_ptr->text[i].lang_key,
230 info_ptr->text[i].text);
232 png_warning(png_ptr,
"Unable to write international text");
240 #if defined(PNG_WRITE_zTXt_SUPPORTED) 243 info_ptr->text[i].text, 0,
244 info_ptr->text[i].compression);
246 png_warning(png_ptr,
"Unable to write compressed text");
253 #if defined(PNG_WRITE_tEXt_SUPPORTED) 256 info_ptr->text[i].text,
259 png_warning(png_ptr,
"Unable to write uncompressed text");
266 #if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) 267 if (info_ptr->unknown_chunks_num)
273 for (up = info_ptr->unknown_chunks;
274 up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
282 (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
303 png_error(png_ptr,
"No IDATs written into file");
306 if (info_ptr != NULL)
308 #if defined(PNG_WRITE_TEXT_SUPPORTED) 311 #if defined(PNG_WRITE_tIME_SUPPORTED) 314 !(png_ptr->mode & PNG_WROTE_tIME))
317 #if defined(PNG_WRITE_TEXT_SUPPORTED) 319 for (i = 0; i < info_ptr->num_text; i++)
321 png_debug2(2,
"Writing trailer text chunk %d, type %d\n", i,
322 info_ptr->text[i].compression);
324 if (info_ptr->text[i].compression > 0)
326 #if defined(PNG_WRITE_iTXt_SUPPORTED) 328 png_write_iTXt(png_ptr,
329 info_ptr->text[i].compression,
330 info_ptr->text[i].key,
331 info_ptr->text[i].lang,
332 info_ptr->text[i].lang_key,
333 info_ptr->text[i].text);
335 png_warning(png_ptr,
"Unable to write international text");
342 #if defined(PNG_WRITE_zTXt_SUPPORTED) 345 info_ptr->text[i].text, 0,
346 info_ptr->text[i].compression);
348 png_warning(png_ptr,
"Unable to write compressed text");
355 #if defined(PNG_WRITE_tEXt_SUPPORTED) 358 info_ptr->text[i].text, 0);
360 png_warning(png_ptr,
"Unable to write uncompressed text");
368 #if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) 369 if (info_ptr->unknown_chunks_num)
375 for (up = info_ptr->unknown_chunks;
376 up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
383 (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
404 #if defined(PNG_WRITE_FLUSH_SUPPORTED) && \ 405 defined(PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED) 410 #if defined(PNG_WRITE_tIME_SUPPORTED) 411 #if !defined(_WIN32_WCE) 416 png_debug(1,
"in png_convert_from_struct_tm\n");
417 ptime->year = (
png_uint_16)(1900 + ttime->tm_year);
418 ptime->month = (
png_byte)(ttime->tm_mon + 1);
419 ptime->day = (
png_byte)ttime->tm_mday;
420 ptime->hour = (
png_byte)ttime->tm_hour;
421 ptime->minute = (
png_byte)ttime->tm_min;
422 ptime->second = (
png_byte)ttime->tm_sec;
430 png_debug(1,
"in png_convert_from_time_t\n");
431 tbuf = gmtime(&ttime);
442 #ifdef PNG_USER_MEM_SUPPORTED 454 #ifdef PNG_SETJMP_SUPPORTED 458 #ifdef PNG_SETJMP_SUPPORTED 459 #ifdef USE_FAR_KEYWORD 464 png_debug(1,
"in png_create_write_struct\n");
465 #ifdef PNG_USER_MEM_SUPPORTED 475 #ifdef PNG_SET_USER_LIMITS_SUPPORTED 480 #ifdef PNG_SETJMP_SUPPORTED 481 #ifdef USE_FAR_KEYWORD 484 if (setjmp(png_ptr->jmpbuf))
492 #ifdef USE_FAR_KEYWORD 497 #ifdef PNG_USER_MEM_SUPPORTED 508 png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
512 if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
519 if (user_png_ver == NULL || user_png_ver[0] !=
png_libpng_ver[0] ||
520 (user_png_ver[0] ==
'1' && user_png_ver[2] !=
png_libpng_ver[2]) ||
521 (user_png_ver[0] ==
'0' && user_png_ver[2] <
'9'))
523 #if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) 528 "Application was compiled with png.h from libpng-%.20s",
533 "Application is running with png.c from libpng-%.20s",
537 #ifdef PNG_ERROR_NUMBERS_SUPPORTED 541 "Incompatible libpng version in application and library");
553 #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) 558 #ifdef PNG_SETJMP_SUPPORTED 562 #ifdef USE_FAR_KEYWORD 567 if (setjmp(png_ptr->jmpbuf))
575 #if defined(PNG_1_0_X) || defined(PNG_1_2_X) 577 #undef png_write_init 590 if (png_ptr == NULL)
return;
591 #if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) 596 png_ptr->warning_fn=NULL;
600 "Application was compiled with png.h from libpng-%.20s",
605 "Application is running with png.c from libpng-%.20s",
612 png_ptr->error_fn=NULL;
613 #ifdef PNG_ERROR_NUMBERS_SUPPORTED 617 "The png struct allocated by the application for writing is too small.");
621 png_ptr->error_fn=NULL;
622 #ifdef PNG_ERROR_NUMBERS_SUPPORTED 626 "The info struct allocated by the application for writing is too small.");
638 #ifdef PNG_SETJMP_SUPPORTED 651 #ifdef PNG_LEGACY_SUPPORTED 652 png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
654 png_ptr->warning_fn=NULL;
656 "Application uses deprecated png_write_init() and should be recompiled.");
664 #ifdef PNG_SETJMP_SUPPORTED 680 #ifdef PNG_SET_USER_LIMITS_SUPPORTED 685 #ifdef PNG_SETJMP_SUPPORTED 698 #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) 722 for (i = 0, rp = row; i <
num_rows; i++, rp++)
742 #if defined(PNG_WRITE_INTERLACING_SUPPORTED) 750 for (pass = 0; pass < num_pass; pass++)
753 for (i = 0, rp = image; i < png_ptr->height; i++, rp++)
766 png_debug2(1,
"in png_write_row (row %ld, pass %d)\n",
767 png_ptr->row_number, png_ptr->pass);
770 if (png_ptr->row_number == 0 && png_ptr->pass == 0)
773 if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE))
775 "png_write_info was never called before png_write_row.");
778 #if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED) 779 if (png_ptr->transformations & PNG_INVERT_MONO)
780 png_warning(png_ptr,
"PNG_WRITE_INVERT_SUPPORTED is not defined.");
782 #if !defined(PNG_WRITE_FILLER_SUPPORTED) && defined(PNG_READ_FILLER_SUPPORTED) 783 if (png_ptr->transformations & PNG_FILLER)
784 png_warning(png_ptr,
"PNG_WRITE_FILLER_SUPPORTED is not defined.");
786 #if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && defined(PNG_READ_PACKSWAP_SUPPORTED) 787 if (png_ptr->transformations & PNG_PACKSWAP)
788 png_warning(png_ptr,
"PNG_WRITE_PACKSWAP_SUPPORTED is not defined.");
790 #if !defined(PNG_WRITE_PACK_SUPPORTED) && defined(PNG_READ_PACK_SUPPORTED) 791 if (png_ptr->transformations & PNG_PACK)
792 png_warning(png_ptr,
"PNG_WRITE_PACK_SUPPORTED is not defined.");
794 #if !defined(PNG_WRITE_SHIFT_SUPPORTED) && defined(PNG_READ_SHIFT_SUPPORTED) 795 if (png_ptr->transformations & PNG_SHIFT)
796 png_warning(png_ptr,
"PNG_WRITE_SHIFT_SUPPORTED is not defined.");
798 #if !defined(PNG_WRITE_BGR_SUPPORTED) && defined(PNG_READ_BGR_SUPPORTED) 799 if (png_ptr->transformations & PNG_BGR)
800 png_warning(png_ptr,
"PNG_WRITE_BGR_SUPPORTED is not defined.");
802 #if !defined(PNG_WRITE_SWAP_SUPPORTED) && defined(PNG_READ_SWAP_SUPPORTED) 803 if (png_ptr->transformations & PNG_SWAP_BYTES)
804 png_warning(png_ptr,
"PNG_WRITE_SWAP_SUPPORTED is not defined.");
810 #if defined(PNG_WRITE_INTERLACING_SUPPORTED) 812 if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))
814 switch (png_ptr->pass)
817 if (png_ptr->row_number & 0x07)
824 if ((png_ptr->row_number & 0x07) || png_ptr->width < 5)
831 if ((png_ptr->row_number & 0x07) != 4)
838 if ((png_ptr->row_number & 0x03) || png_ptr->width < 3)
845 if ((png_ptr->row_number & 0x03) != 2)
852 if ((png_ptr->row_number & 0x01) || png_ptr->width < 2)
859 if (!(png_ptr->row_number & 0x01))
870 png_ptr->row_info.color_type = png_ptr->color_type;
871 png_ptr->row_info.width = png_ptr->usr_width;
872 png_ptr->row_info.channels = png_ptr->usr_channels;
873 png_ptr->row_info.bit_depth = png_ptr->usr_bit_depth;
874 png_ptr->row_info.pixel_depth = (
png_byte)(png_ptr->row_info.bit_depth *
875 png_ptr->row_info.channels);
877 png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth,
878 png_ptr->row_info.width);
880 png_debug1(3,
"row_info->color_type = %d\n", png_ptr->row_info.color_type);
881 png_debug1(3,
"row_info->width = %lu\n", png_ptr->row_info.width);
882 png_debug1(3,
"row_info->channels = %d\n", png_ptr->row_info.channels);
883 png_debug1(3,
"row_info->bit_depth = %d\n", png_ptr->row_info.bit_depth);
884 png_debug1(3,
"row_info->pixel_depth = %d\n", png_ptr->row_info.pixel_depth);
885 png_debug1(3,
"row_info->rowbytes = %lu\n", png_ptr->row_info.rowbytes);
889 png_ptr->row_info.rowbytes);
891 #if defined(PNG_WRITE_INTERLACING_SUPPORTED) 893 if (png_ptr->interlaced && png_ptr->pass < 6 &&
894 (png_ptr->transformations & PNG_INTERLACE))
897 png_ptr->row_buf + 1, png_ptr->pass);
899 if (!(png_ptr->row_info.width))
908 if (png_ptr->transformations)
911 #if defined(PNG_MNG_FEATURES_SUPPORTED) 932 if (png_ptr->write_row_fn != NULL)
933 (*(png_ptr->write_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass);
936 #if defined(PNG_WRITE_FLUSH_SUPPORTED) 944 png_ptr->flush_dist = (nrows < 0 ? 0 :
nrows);
957 if (png_ptr->row_number >= png_ptr->num_rows)
971 if (png_ptr->zstream.msg != NULL)
972 png_error(png_ptr, png_ptr->zstream.msg);
977 if (!(png_ptr->zstream.avail_out))
982 png_ptr->zstream.next_out = png_ptr->zbuf;
983 png_ptr->zstream.avail_out = (
uInt)png_ptr->zbuf_size;
986 }
while(wrote_IDAT == 1);
989 if (png_ptr->zbuf_size != png_ptr->zstream.avail_out)
993 png_ptr->zbuf_size - png_ptr->zstream.avail_out);
994 png_ptr->zstream.next_out = png_ptr->zbuf;
995 png_ptr->zstream.avail_out = (
uInt)png_ptr->zbuf_size;
997 png_ptr->flush_rows = 0;
1008 #ifdef PNG_USER_MEM_SUPPORTED 1013 png_debug(1,
"in png_destroy_write_struct\n");
1014 if (png_ptr_ptr != NULL)
1016 png_ptr = *png_ptr_ptr;
1017 #ifdef PNG_USER_MEM_SUPPORTED 1018 free_fn = png_ptr->free_fn;
1019 mem_ptr = png_ptr->mem_ptr;
1023 #ifdef PNG_USER_MEM_SUPPORTED 1024 if (png_ptr != NULL)
1026 free_fn = png_ptr->free_fn;
1027 mem_ptr = png_ptr->mem_ptr;
1031 if (info_ptr_ptr != NULL)
1034 if (info_ptr != NULL)
1036 if (png_ptr != NULL)
1040 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) 1041 if (png_ptr->num_chunk_list)
1043 png_free(png_ptr, png_ptr->chunk_list);
1044 png_ptr->chunk_list=NULL;
1045 png_ptr->num_chunk_list = 0;
1050 #ifdef PNG_USER_MEM_SUPPORTED 1056 *info_ptr_ptr = NULL;
1059 if (png_ptr != NULL)
1062 #ifdef PNG_USER_MEM_SUPPORTED 1068 *png_ptr_ptr = NULL;
1077 #ifdef PNG_SETJMP_SUPPORTED 1083 #ifdef PNG_USER_MEM_SUPPORTED 1093 png_free(png_ptr, png_ptr->row_buf);
1094 #ifndef PNG_NO_WRITE_FILTER 1095 png_free(png_ptr, png_ptr->prev_row);
1096 png_free(png_ptr, png_ptr->sub_row);
1097 png_free(png_ptr, png_ptr->up_row);
1098 png_free(png_ptr, png_ptr->avg_row);
1099 png_free(png_ptr, png_ptr->paeth_row);
1102 #if defined(PNG_TIME_RFC1123_SUPPORTED) 1103 png_free(png_ptr, png_ptr->time_buffer);
1106 #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) 1107 png_free(png_ptr, png_ptr->prev_filters);
1108 png_free(png_ptr, png_ptr->filter_weights);
1109 png_free(png_ptr, png_ptr->inv_filter_weights);
1110 png_free(png_ptr, png_ptr->filter_costs);
1111 png_free(png_ptr, png_ptr->inv_filter_costs);
1114 #ifdef PNG_SETJMP_SUPPORTED 1119 error_fn = png_ptr->error_fn;
1120 warning_fn = png_ptr->warning_fn;
1121 error_ptr = png_ptr->error_ptr;
1122 #ifdef PNG_USER_MEM_SUPPORTED 1123 free_fn = png_ptr->free_fn;
1131 #ifdef PNG_USER_MEM_SUPPORTED 1135 #ifdef PNG_SETJMP_SUPPORTED 1145 if (png_ptr == NULL)
1147 #if defined(PNG_MNG_FEATURES_SUPPORTED) 1156 #ifndef PNG_NO_WRITE_FILTER 1159 case 7:
png_warning(png_ptr,
"Unknown row filter for method 0");
1163 #ifndef PNG_NO_WRITE_FILTER 1172 default: png_ptr->do_filter = (
png_byte)filters;
break;
1174 default:
png_warning(png_ptr,
"Unknown row filter for method 0");
1187 if (png_ptr->row_buf != NULL)
1189 #ifndef PNG_NO_WRITE_FILTER 1190 if ((png_ptr->do_filter &
PNG_FILTER_SUB) && png_ptr->sub_row == NULL)
1193 (png_ptr->rowbytes + 1));
1197 if ((png_ptr->do_filter &
PNG_FILTER_UP) && png_ptr->up_row == NULL)
1199 if (png_ptr->prev_row == NULL)
1201 png_warning(png_ptr,
"Can't add Up filter after starting");
1207 (png_ptr->rowbytes + 1));
1212 if ((png_ptr->do_filter &
PNG_FILTER_AVG) && png_ptr->avg_row == NULL)
1214 if (png_ptr->prev_row == NULL)
1216 png_warning(png_ptr,
"Can't add Average filter after starting");
1222 (png_ptr->rowbytes + 1));
1228 png_ptr->paeth_row == NULL)
1230 if (png_ptr->prev_row == NULL)
1232 png_warning(png_ptr,
"Can't add Paeth filter after starting");
1238 (png_ptr->rowbytes + 1));
1249 png_error(png_ptr,
"Unknown custom filter method");
1259 #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) 1267 png_debug(1,
"in png_set_filter_heuristics\n");
1268 if (png_ptr == NULL)
1272 png_warning(png_ptr,
"Unknown filter heuristic method");
1281 if (num_weights < 0 || filter_weights == NULL ||
1287 png_ptr->num_prev_filters = (
png_byte)num_weights;
1288 png_ptr->heuristic_method = (
png_byte)heuristic_method;
1290 if (num_weights > 0)
1292 if (png_ptr->prev_filters == NULL)
1300 png_ptr->prev_filters[
i] = 255;
1304 if (png_ptr->filter_weights == NULL)
1313 png_ptr->inv_filter_weights[
i] =
1314 png_ptr->filter_weights[
i] = PNG_WEIGHT_FACTOR;
1320 if (filter_weights[i] < 0.0)
1322 png_ptr->inv_filter_weights[
i] =
1323 png_ptr->filter_weights[
i] = PNG_WEIGHT_FACTOR;
1327 png_ptr->inv_filter_weights[
i] =
1328 (
png_uint_16)((
double)PNG_WEIGHT_FACTOR*filter_weights[
i]+0.5);
1329 png_ptr->filter_weights[
i] =
1330 (
png_uint_16)((
double)PNG_WEIGHT_FACTOR/filter_weights[
i]+0.5);
1338 if (png_ptr->filter_costs == NULL)
1348 png_ptr->inv_filter_costs[
i] =
1349 png_ptr->filter_costs[
i] = PNG_COST_FACTOR;
1362 if (filter_costs == NULL || filter_costs[i] < 0.0)
1364 png_ptr->inv_filter_costs[
i] =
1365 png_ptr->filter_costs[
i] = PNG_COST_FACTOR;
1367 else if (filter_costs[i] >= 1.0)
1369 png_ptr->inv_filter_costs[
i] =
1370 (
png_uint_16)((
double)PNG_COST_FACTOR / filter_costs[
i] + 0.5);
1371 png_ptr->filter_costs[
i] =
1372 (
png_uint_16)((
double)PNG_COST_FACTOR * filter_costs[
i] + 0.5);
1381 png_debug(1,
"in png_set_compression_level\n");
1382 if (png_ptr == NULL)
1384 png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_LEVEL;
1385 png_ptr->zlib_level =
level;
1391 png_debug(1,
"in png_set_compression_mem_level\n");
1392 if (png_ptr == NULL)
1394 png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL;
1401 png_debug(1,
"in png_set_compression_strategy\n");
1402 if (png_ptr == NULL)
1404 png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_STRATEGY;
1411 if (png_ptr == NULL)
1413 if (window_bits > 15)
1414 png_warning(png_ptr,
"Only compression windows <= 32k supported by PNG");
1415 else if (window_bits < 8)
1416 png_warning(png_ptr,
"Only compression windows >= 256 supported by PNG");
1419 if (window_bits == 8)
1421 png_warning(png_ptr,
"Compression window is being reset to 512");
1425 png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS;
1432 png_debug(1,
"in png_set_compression_method\n");
1433 if (png_ptr == NULL)
1436 png_warning(png_ptr,
"Only compression method 8 is supported by PNG");
1437 png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_METHOD;
1438 png_ptr->zlib_method =
method;
1444 if (png_ptr == NULL)
1449 #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) 1454 png_debug(1,
"in png_set_write_user_transform_fn\n");
1455 if (png_ptr == NULL)
1457 png_ptr->transformations |= PNG_USER_TRANSFORM;
1463 #if defined(PNG_INFO_IMAGE_SUPPORTED) 1468 if (png_ptr == NULL || info_ptr == NULL)
1470 #if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) 1481 #if defined(PNG_WRITE_INVERT_SUPPORTED) 1487 #if defined(PNG_WRITE_SHIFT_SUPPORTED) 1496 #if defined(PNG_WRITE_PACK_SUPPORTED) 1502 #if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) 1508 #if defined(PNG_WRITE_FILLER_SUPPORTED) 1516 #if defined(PNG_WRITE_BGR_SUPPORTED) 1522 #if defined(PNG_WRITE_SWAP_SUPPORTED) 1528 #if defined(PNG_WRITE_PACKSWAP_SUPPORTED) void png_write_sCAL(png_structp png_ptr, int unit, double width, double height)
void png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
#define PNG_FILTER_VALUE_AVG
void PNGAPI png_write_chunk(png_structp png_ptr, png_bytep chunk_name, png_bytep data, png_size_t length)
void PNGAPI png_set_packing(png_structp png_ptr)
PNG_CONST char png_libpng_ver[18]
#define PNG_USER_WIDTH_MAX
void PNGAPI png_set_filter_heuristics(png_structp png_ptr, int heuristic_method, int num_weights, png_doublep filter_weights, png_doublep filter_costs)
#define PNG_TRANSFORM_SWAP_ENDIAN
void png_write_start_row(png_structp png_ptr)
png_voidp png_error_ptr png_error_ptr png_voidp png_malloc_ptr malloc_fn
void PNGAPI png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask, int num)
void PNGAPI png_write_image(png_structp png_ptr, png_bytepp image)
png_voidp png_create_struct(int type)
void PNGAPI png_write_png(png_structp png_ptr, png_infop info_ptr, int transforms, voidp params)
#define PNG_FILTER_VALUE_LAST
void png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist)
#define PNG_FILLER_BEFORE
void PNGAPI png_set_flush(png_structp png_ptr, int nrows)
void PNGAPI png_set_compression_level(png_structp png_ptr, int level)
int int png_doublep filter_weights
#define PNG_TRANSFORM_INVERT_MONO
png_voidp png_error_ptr png_error_ptr png_voidp png_malloc_ptr png_free_ptr free_fn
png_user_transform_ptr write_user_transform_fn
void PNGAPI png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)
#define png_malloc_ptr_NULL
void PNGAPI png_set_invert_alpha(png_structp png_ptr)
#define PNG_TRANSFORM_PACKSWAP
void png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma)
void PNGAPI png_write_rows(png_structp png_ptr, png_bytepp row, png_uint_32 num_rows)
#define PNG_COLOR_TYPE_PALETTE
void png_write_sig(png_structp png_ptr)
#define PNG_FILTER_VALUE_PAETH
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
png_infop png_charp png_int_32 png_int_32 int int png_charp png_charpp * params
#define PNG_TRANSFORM_BGR
void png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type)
int PNGAPI png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name)
void png_do_write_transformations(png_structp png_ptr)
PNG_CONST char FAR * png_const_charp
void PNGAPI png_set_compression_strategy(png_structp png_ptr, int strategy)
int ZEXPORT deflateEnd(z_streamp strm)
void png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset, int unit_type)
#define PNG_USER_HEIGHT_MAX
void png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
void PNGAPI png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
#define PNG_TEXT_COMPRESSION_NONE_WR
png_voidp png_error_ptr png_error_ptr warning_fn
void png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type, png_charp profile, int profile_len)
png_struct FAR *FAR * png_structpp
#define PNG_WRITE_INTERLACING_SUPPORTED
void png_flush(png_structp png_ptr)
int int png_doublep png_doublep filter_costs
#define PNG_TRANSFORM_STRIP_FILLER
png_write_status_ptr write_row_fn
void png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text, png_size_t text_len)
void png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, int unit_type)
void PNGAPI png_set_bgr(png_structp png_ptr)
png_byte FAR *FAR * png_bytepp
#define PNG_TEXT_COMPRESSION_zTXt
void PNGAPI png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr write_user_transform_fn)
#define PNG_FILTER_HEURISTIC_UNWEIGHTED
void png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette)
#define PNG_TEXT_COMPRESSION_NONE
png_struct FAR * png_structp
void PNGAPI png_write_info(png_structp png_ptr, png_infop info_ptr)
#define PNG_HANDLE_CHUNK_ALWAYS
void PNGAPI png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
void png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, png_fixed_point blue_x, png_fixed_point blue_y)
#define PNG_FILTER_HEURISTIC_LAST
void PNGAPI png_error(png_structp png_ptr, png_const_charp error_message)
int JSAMPARRAY int int num_rows
void PNGAPI png_set_packswap(png_structp png_ptr)
void png_destroy_struct(png_voidp struct_ptr)
void PNGAPI png_set_swap(png_structp png_ptr)
void PNGAPI png_write_flush(png_structp png_ptr)
void png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
png_voidp png_error_ptr error_fn
unsigned short png_uint_16
void PNGAPI png_set_compression_mem_level(png_structp png_ptr, int mem_level)
#define PNG_FILTER_VALUE_SUB
def j(str, encoding="cp932")
void png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, int compression_type, int filter_type, int interlace_type)
#define png_flush_ptr_NULL
void png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran, int num_trans, int color_type)
void PNGAPI png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t png_info_size)
void PNGAPI png_warning(png_structp png_ptr, png_const_charp warning_message)
void PNGAPI png_set_write_status_fn(png_structp png_ptr, png_write_status_ptr write_row_fn)
void png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, png_charp units, png_charpp params)
void png_write_gAMA(png_structp png_ptr, double file_gamma)
png_uint_16 FAR * png_uint_16p
void PNGAPI png_convert_from_struct_tm(png_timep ptime, struct tm FAR *ttime)
png_structp PNGAPI png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)
void PNGAPI png_write_end(png_structp png_ptr, png_infop info_ptr)
#define PNG_TRANSFORM_PACKING
#define PNG_TRANSFORM_INVERT_ALPHA
#define png_debug1(l, m, p1)
void PNGAPI png_set_compression_window_bits(png_structp png_ptr, int window_bits)
#define PNG_FILTER_VALUE_UP
int ZEXPORT deflate(z_streamp strm, int flush)
void PNGAPI png_set_invert_mono(png_structp png_ptr)
#define PNG_FLAG_MNG_FILTER_64
#define PNG_FILTER_TYPE_BASE
void png_write_destroy(png_structp png_ptr)
void png_write_tIME(png_structp png_ptr, png_timep mod_time)
#define PNG_TEXT_COMPRESSION_zTXt_WR
png_voidp png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
#define png_free_ptr_NULL
void png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal)
#define PNG_COMPRESSION_TYPE_BASE
void png_write_sRGB(png_structp png_ptr, int srgb_intent)
void PNGAPI png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
#define PNG_FILTER_HEURISTIC_DEFAULT
png_voidp png_error_ptr png_error_ptr warn_fn
png_voidp PNGAPI png_memcpy_check(png_structp png_ptr, png_voidp s1, png_voidp s2, png_uint_32 length)
void PNGAPI png_convert_from_time_t(png_timep ptime, time_t ttime)
void PNGAPI png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
int PNGAPI png_set_interlace_handling(png_structp png_ptr)
void png_write_IEND(png_structp png_ptr)
void PNGAPI png_write_row(png_structp png_ptr, png_bytep row)
void PNGAPI png_set_shift(png_structp png_ptr, png_color_8p true_bits)
#define PNG_TRANSFORM_SWAP_ALPHA
void png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
void png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, png_voidp mem_ptr)
png_structp PNGAPI png_create_write_struct(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn)
png_byte name[PNG_CHUNK_NAME_LENGTH]
#define PNG_FILTER_VALUE_NONE
void PNGAPI png_write_init(png_structp png_ptr)
#define PNG_INTRAPIXEL_DIFFERENCING
void PNGAPI png_set_compression_method(png_structp png_ptr, int method)
void png_write_finish_row(png_structp png_ptr)
unsigned long png_uint_32
void png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text, png_size_t text_len, int compression)
png_voidp png_error_ptr png_error_ptr png_voidp mem_ptr
png_info FAR *FAR * png_infopp
void PNGAPI png_free(png_structp png_ptr, png_voidp ptr)
#define png_debug2(l, m, p1, p2)
void PNGAPI png_set_swap_alpha(png_structp png_ptr)
#define PNG_TRANSFORM_SHIFT
void PNGAPI png_set_filter(png_structp png_ptr, int method, int filters)
void png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
void PNGAPI png_set_error_fn(png_structp png_ptr, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)
#define PNG_HANDLE_CHUNK_NEVER
png_voidp PNGAPI png_malloc(png_structp png_ptr, png_uint_32 size)
void png_write_cHRM(png_structp png_ptr, double white_x, double white_y, double red_x, double red_y, double green_x, double green_y, double blue_x, double blue_y)
void PNGAPI png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, png_size_t png_struct_size)