18#ifdef PNG_WRITE_SUPPORTED
20#ifdef PNG_WRITE_INTERLACING_SUPPORTED
24static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
26static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
28static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
30static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
35#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED
43 buf[0] = (png_byte)((
i >> 24) & 0xffU);
44 buf[1] = (png_byte)((
i >> 16) & 0xffU);
45 buf[2] = (png_byte)((
i >> 8) & 0xffU);
46 buf[3] = (png_byte)(
i & 0xffU);
56 buf[0] = (png_byte)((
i >> 8) & 0xffU);
57 buf[1] = (png_byte)(
i & 0xffU);
70 png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
72#ifdef PNG_IO_STATE_SUPPORTED
79 (
size_t)(8 -
png_ptr->sig_bytes));
95#if defined(PNG_DEBUG) && (PNG_DEBUG > 0)
103#ifdef PNG_IO_STATE_SUPPORTED
112 png_save_uint_32(
buf + 4, chunk_name);
116 png_ptr->chunk_name = chunk_name;
123#ifdef PNG_IO_STATE_SUPPORTED
169#ifdef PNG_IO_STATE_SUPPORTED
200 png_error(
png_ptr,
"length exceeds PNG maximum");
228 if (
png_ptr->rowbytes < 32768 &&
h < 32768)
236 unsigned int pd =
png_ptr->pixel_depth;
259#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
272 if (data_size <= 16384)
274 unsigned int z_cmf =
data[0];
276 if ((z_cmf & 0x0f) == 8 && (z_cmf & 0xf0) <= 0x70)
278 unsigned int z_cinfo;
279 unsigned int half_z_window_size;
281 z_cinfo = z_cmf >> 4;
282 half_z_window_size = 1U << (z_cinfo + 7);
284 if (data_size <= half_z_window_size)
290 half_z_window_size >>= 1;
293 while (z_cinfo > 0 && data_size <= half_z_window_size);
295 z_cmf = (z_cmf & 0x0f) | (z_cinfo << 4);
297 data[0] = (png_byte)z_cmf;
298 tmp =
data[1] & 0xe0;
299 tmp += 0x1f - ((z_cmf << 8) + tmp) % 0x1f;
300 data[1] = (png_byte)tmp;
314#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED)
325 (
void)png_safecat(
msg, (
sizeof msg), 10,
" using zstream");
347 int memLevel =
png_ptr->zlib_mem_level;
354 strategy =
png_ptr->zlib_strategy;
365#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
369 memLevel =
png_ptr->zlib_text_mem_level;
370 strategy =
png_ptr->zlib_text_strategy;
388 if (data_size <= 16384)
395 unsigned int half_window_size = 1U << (
windowBits-1);
397 while (data_size + 262 <= half_window_size)
399 half_window_size >>= 1;
409 png_ptr->zlib_set_mem_level != memLevel ||
410 png_ptr->zlib_set_strategy != strategy))
413 png_warning(
png_ptr,
"deflateEnd failed (ignored)");
415 png_ptr->flags &= ~PNG_FLAG_ZSTREAM_INITIALIZED;
424 png_ptr->zstream.avail_out = 0;
458 png_compression_bufferp
list = *listp;
475#ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
491 png_byte output[1024];
499 comp->input_len = input_len;
500 comp->output_len = 0;
520 ret = png_deflate_claim(
png_ptr, chunk_name, comp->input_len);
532 png_compression_bufferp *
end = &
png_ptr->zbuffer_list;
539 png_ptr->zstream.next_out = comp->output;
540 png_ptr->zstream.avail_out = (
sizeof comp->output);
542 output_len =
png_ptr->zstream.avail_out;
548 if (avail_in > input_len)
549 avail_in = (
uInt)input_len;
551 input_len -= avail_in;
553 png_ptr->zstream.avail_in = avail_in;
555 if (
png_ptr->zstream.avail_out == 0)
557 png_compression_buffer *
next;
590 output_len +=
png_ptr->zstream.avail_out;
603 input_len +=
png_ptr->zstream.avail_in;
611 output_len -=
png_ptr->zstream.avail_out;
612 png_ptr->zstream.avail_out = 0;
613 comp->output_len = output_len;
636#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
638 optimize_cmf(comp->output, comp->input_len);
659 png_compression_buffer *
next =
png_ptr->zbuffer_list;
663 if (
avail > output_len)
670 if (output_len == 0 ||
next ==
NULL)
674 output =
next->output;
680 png_error(
png_ptr,
"error writing ancillary chunked compressed data");
690 int bit_depth,
int color_type,
int compression_type,
int filter_type,
694 int is_invalid_depth;
708#ifdef PNG_WRITE_16BIT_SUPPORTED
715 "Invalid bit depth for grayscale image");
720 is_invalid_depth = (bit_depth != 8);
721#ifdef PNG_WRITE_16BIT_SUPPORTED
722 is_invalid_depth = (is_invalid_depth && bit_depth != 16);
724 if (is_invalid_depth)
725 png_error(
png_ptr,
"Invalid bit depth for RGB image");
741 png_error(
png_ptr,
"Invalid bit depth for paletted image");
746 is_invalid_depth = (bit_depth != 8);
747#ifdef PNG_WRITE_16BIT_SUPPORTED
748 is_invalid_depth = (is_invalid_depth && bit_depth != 16);
750 if (is_invalid_depth)
751 png_error(
png_ptr,
"Invalid bit depth for grayscale+alpha image");
757 is_invalid_depth = (bit_depth != 8);
758#ifdef PNG_WRITE_16BIT_SUPPORTED
759 is_invalid_depth = (is_invalid_depth && bit_depth != 16);
761 if (is_invalid_depth)
762 png_error(
png_ptr,
"Invalid bit depth for RGBA image");
768 png_error(
png_ptr,
"Invalid image color type specified");
773 png_warning(
png_ptr,
"Invalid compression type specified");
796 png_warning(
png_ptr,
"Invalid filter type specified");
800#ifdef PNG_WRITE_INTERLACING_SUPPORTED
804 png_warning(
png_ptr,
"Invalid interlace type specified");
812 png_ptr->bit_depth = (png_byte)bit_depth;
813 png_ptr->color_type = (png_byte)color_type;
814 png_ptr->interlaced = (png_byte)interlace_type;
815#ifdef PNG_MNG_FEATURES_SUPPORTED
816 png_ptr->filter_type = (png_byte)filter_type;
818 png_ptr->compression_type = (png_byte)compression_type;
832 buf[8] = (png_byte)bit_depth;
833 buf[9] = (png_byte)color_type;
834 buf[10] = (png_byte)compression_type;
835 buf[11] = (png_byte)filter_type;
836 buf[12] = (png_byte)interlace_type;
875 num_pal == 0) || num_pal > max_palette_length)
879 png_error(
png_ptr,
"Invalid number of colors in palette");
884 png_warning(
png_ptr,
"Invalid number of colors in palette");
892 "Ignoring request to write a PLTE chunk in grayscale PNG");
897 png_ptr->num_palette = (png_uint_16)num_pal;
901#ifdef PNG_POINTER_INDEXING_SUPPORTED
903 for (
i = 0, pal_ptr =
palette;
i < num_pal;
i++, pal_ptr++)
917 for (
i = 0;
i < num_pal;
i++)
992 if (
avail > input_len)
1001 input_len +=
png_ptr->zstream.avail_in;
1002 png_ptr->zstream.avail_in = 0;
1008 if (
png_ptr->zstream.avail_out == 0)
1016#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
1049 png_error(
png_ptr,
"Z_OK on Z_FINISH with output space");
1063#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
1071 png_ptr->zstream.avail_out = 0;
1098#ifdef PNG_WRITE_gAMA_SUPPORTED
1113#ifdef PNG_WRITE_sRGB_SUPPORTED
1124 "Invalid sRGB rendering intent specified");
1126 buf[0]=(png_byte)srgb_intent;
1131#ifdef PNG_WRITE_iCCP_SUPPORTED
1138 png_byte new_name[81];
1139 compression_state comp;
1148 png_error(
png_ptr,
"No profile for iCCP chunk");
1150 if (profile_len < 132)
1151 png_error(
png_ptr,
"ICC profile too short");
1154 png_error(
png_ptr,
"Incorrect data in iCCP");
1157 if (
temp > 3 && (profile_len & 0x03))
1158 png_error(
png_ptr,
"ICC profile length invalid (not a multiple of 4)");
1163 if (profile_len != embedded_profile_len)
1164 png_error(
png_ptr,
"Profile length does not match profile");
1167 name_len = png_check_keyword(
png_ptr,
name, new_name);
1170 png_error(
png_ptr,
"iCCP: invalid keyword");
1177 png_text_compress_init(&comp,
profile, profile_len);
1183 png_write_chunk_header(
png_ptr,
png_iCCP, name_len + comp.output_len);
1185 png_write_chunk_data(
png_ptr, new_name, name_len);
1187 png_write_compressed_data_out(
png_ptr, &comp);
1193#ifdef PNG_WRITE_sPLT_SUPPORTED
1199 png_byte new_name[80];
1200 png_byte entrybuf[10];
1201 size_t entry_size = (spalette->
depth == 8 ? 6 : 10);
1210 name_len = png_check_keyword(
png_ptr, spalette->
name, new_name);
1213 png_error(
png_ptr,
"sPLT: invalid keyword");
1219 png_write_chunk_data(
png_ptr, (
png_bytep)new_name, (
size_t)(name_len + 1));
1224#ifdef PNG_POINTER_INDEXING_SUPPORTED
1225 for (ep = spalette->
entries; ep<spalette->entries + spalette->
nentries; ep++)
1227 if (spalette->
depth == 8)
1229 entrybuf[0] = (png_byte)ep->red;
1230 entrybuf[1] = (png_byte)ep->green;
1231 entrybuf[2] = (png_byte)ep->blue;
1232 entrybuf[3] = (png_byte)ep->alpha;
1233 png_save_uint_16(entrybuf + 4, ep->frequency);
1238 png_save_uint_16(entrybuf + 0, ep->red);
1239 png_save_uint_16(entrybuf + 2, ep->green);
1240 png_save_uint_16(entrybuf + 4, ep->blue);
1241 png_save_uint_16(entrybuf + 6, ep->alpha);
1242 png_save_uint_16(entrybuf + 8, ep->frequency);
1245 png_write_chunk_data(
png_ptr, entrybuf, entry_size);
1251 if (spalette->
depth == 8)
1253 entrybuf[0] = (png_byte)ep[
i].
red;
1254 entrybuf[1] = (png_byte)ep[
i].
green;
1255 entrybuf[2] = (png_byte)ep[
i].
blue;
1256 entrybuf[3] = (png_byte)ep[
i].
alpha;
1257 png_save_uint_16(entrybuf + 4, ep[
i].
frequency);
1262 png_save_uint_16(entrybuf + 0, ep[
i].
red);
1263 png_save_uint_16(entrybuf + 2, ep[
i].
green);
1264 png_save_uint_16(entrybuf + 4, ep[
i].
blue);
1265 png_save_uint_16(entrybuf + 6, ep[
i].
alpha);
1266 png_save_uint_16(entrybuf + 8, ep[
i].
frequency);
1269 png_write_chunk_data(
png_ptr, entrybuf, entry_size);
1277#ifdef PNG_WRITE_sBIT_SUPPORTED
1295 if (sbit->
red == 0 || sbit->
red > maxbits ||
1297 sbit->
blue == 0 || sbit->
blue > maxbits)
1299 png_warning(
png_ptr,
"Invalid sBIT depth specified");
1313 png_warning(
png_ptr,
"Invalid sBIT depth specified");
1325 png_warning(
png_ptr,
"Invalid sBIT depth specified");
1336#ifdef PNG_WRITE_cHRM_SUPPORTED
1349 png_save_int_32(
buf + 8, xy->
redx);
1350 png_save_int_32(
buf + 12, xy->
redy);
1355 png_save_int_32(
buf + 24, xy->
bluex);
1356 png_save_int_32(
buf + 28, xy->
bluey);
1362#ifdef PNG_WRITE_tRNS_SUPPORTED
1374 if (num_trans <= 0 || num_trans > (
int)
png_ptr->num_palette)
1377 "Invalid number of transparent colors specified");
1392 "Ignoring attempt to write tRNS chunk out-of-range for bit_depth");
1397 png_save_uint_16(
buf, tran->
gray);
1404 png_save_uint_16(
buf, tran->
red);
1405 png_save_uint_16(
buf + 2, tran->
green);
1406 png_save_uint_16(
buf + 4, tran->
blue);
1407#ifdef PNG_WRITE_16BIT_SUPPORTED
1414 "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8");
1428#ifdef PNG_WRITE_bKGD_SUPPORTED
1446 png_warning(
png_ptr,
"Invalid background palette index");
1456 png_save_uint_16(
buf, back->
red);
1457 png_save_uint_16(
buf + 2, back->
green);
1458 png_save_uint_16(
buf + 4, back->
blue);
1459#ifdef PNG_WRITE_16BIT_SUPPORTED
1466 "Ignoring attempt to write 16-bit bKGD chunk "
1467 "when bit_depth is 8");
1480 "Ignoring attempt to write bKGD chunk out-of-range for bit_depth");
1485 png_save_uint_16(
buf, back->
gray);
1491#ifdef PNG_WRITE_cICP_SUPPORTED
1495 png_byte colour_primaries, png_byte transfer_function,
1496 png_byte matrix_coefficients, png_byte video_full_range_flag)
1504 buf[0] = colour_primaries;
1505 buf[1] = transfer_function;
1506 buf[2] = matrix_coefficients;
1507 buf[3] = video_full_range_flag;
1514#ifdef PNG_WRITE_cLLI_SUPPORTED
1521 png_debug(1,
"in png_write_cLLI_fixed");
1523 png_save_uint_32(
buf, maxCLL);
1524 png_save_uint_32(
buf + 4, maxFALL);
1530#ifdef PNG_WRITE_mDCV_SUPPORTED
1533 png_uint_16 red_x, png_uint_16 red_y,
1534 png_uint_16 green_x, png_uint_16 green_y,
1535 png_uint_16 blue_x, png_uint_16 blue_y,
1536 png_uint_16 white_x, png_uint_16 white_y,
1541 png_debug(1,
"in png_write_mDCV_fixed");
1543 png_save_uint_16(
buf + 0, red_x);
1544 png_save_uint_16(
buf + 2, red_y);
1545 png_save_uint_16(
buf + 4, green_x);
1546 png_save_uint_16(
buf + 6, green_y);
1547 png_save_uint_16(
buf + 8, blue_x);
1548 png_save_uint_16(
buf + 10, blue_y);
1549 png_save_uint_16(
buf + 12, white_x);
1550 png_save_uint_16(
buf + 14, white_y);
1551 png_save_uint_32(
buf + 16, maxDL);
1552 png_save_uint_32(
buf + 20, minDL);
1558#ifdef PNG_WRITE_eXIf_SUPPORTED
1570 for (
i = 0;
i < num_exif;
i++)
1580#ifdef PNG_WRITE_hIST_SUPPORTED
1590 if (num_hist > (
int)
png_ptr->num_palette)
1592 png_debug2(3,
"num_hist = %d, num_palette = %d", num_hist,
1595 png_warning(
png_ptr,
"Invalid number of histogram entries specified");
1601 for (
i = 0;
i < num_hist;
i++)
1603 png_save_uint_16(
buf, hist[
i]);
1611#ifdef PNG_WRITE_tEXt_SUPPORTED
1625 png_error(
png_ptr,
"tEXt: invalid keyword");
1634 png_error(
png_ptr,
"tEXt: text too long");
1654#ifdef PNG_WRITE_zTXt_SUPPORTED
1662 compression_state comp;
1673 png_error(
png_ptr,
"zTXt: invalid compression type");
1678 png_error(
png_ptr,
"zTXt: invalid keyword");
1698 png_write_compressed_data_out(
png_ptr, &comp);
1705#ifdef PNG_WRITE_iTXt_SUPPORTED
1712 size_t lang_len, lang_key_len;
1714 compression_state comp;
1721 png_error(
png_ptr,
"iTXt: invalid keyword");
1737 png_error(
png_ptr,
"iTXt: invalid compression");
1755 if (lang_key ==
NULL) lang_key =
"";
1756 lang_key_len =
strlen(lang_key)+1;
1759 prefix_len = key_len;
1763 prefix_len = (
png_uint_32)(prefix_len + lang_len);
1768 prefix_len = (
png_uint_32)(prefix_len + lang_key_len);
1781 png_error(
png_ptr,
"iTXt: uncompressed text too long");
1787 png_write_chunk_header(
png_ptr,
png_iTXt, comp.output_len + prefix_len);
1796 png_write_compressed_data_out(
png_ptr, &comp);
1805#ifdef PNG_WRITE_oFFs_SUPPORTED
1816 png_warning(
png_ptr,
"Unrecognized unit type for oFFs chunk");
1818 png_save_int_32(
buf, x_offset);
1819 png_save_int_32(
buf + 4, y_offset);
1820 buf[8] = (png_byte)unit_type;
1825#ifdef PNG_WRITE_pCAL_SUPPORTED
1833 size_t units_len, total_len;
1836 png_byte new_purpose[80];
1839 png_debug1(1,
"in png_write_pCAL (%d parameters)", nparams);
1842 png_error(
png_ptr,
"Unrecognized equation type for pCAL chunk");
1844 purpose_len = png_check_keyword(
png_ptr, purpose, new_purpose);
1846 if (purpose_len == 0)
1847 png_error(
png_ptr,
"pCAL: invalid keyword");
1851 png_debug1(3,
"pCAL purpose length = %d", (
int)purpose_len);
1852 units_len =
strlen(
units) + (nparams == 0 ? 0 : 1);
1853 png_debug1(3,
"pCAL units length = %d", (
int)units_len);
1854 total_len = purpose_len + units_len + 10;
1856 params_len = (
size_t *)png_malloc(
png_ptr,
1862 for (
i = 0;
i < nparams;
i++)
1865 png_debug2(3,
"pCAL parameter %d length = %lu",
i,
1866 (
unsigned long)params_len[
i]);
1867 total_len += params_len[
i];
1870 png_debug1(3,
"pCAL total length = %d", (
int)total_len);
1872 png_write_chunk_data(
png_ptr, new_purpose, purpose_len);
1873 png_save_int_32(
buf, X0);
1874 png_save_int_32(
buf + 4, X1);
1876 buf[9] = (png_byte)nparams;
1880 for (
i = 0;
i < nparams;
i++)
1885 png_free(
png_ptr, params_len);
1890#ifdef PNG_WRITE_sCAL_SUPPORTED
1897 size_t wlen, hlen, total_len;
1903 total_len = wlen + hlen + 2;
1907 png_warning(
png_ptr,
"Can't write sCAL (buffer too small)");
1915 png_debug1(3,
"sCAL total length = %u", (
unsigned int)total_len);
1920#ifdef PNG_WRITE_pHYs_SUPPORTED
1932 png_warning(
png_ptr,
"Unrecognized unit type for pHYs chunk");
1934 png_save_uint_32(
buf, x_pixels_per_unit);
1935 png_save_uint_32(
buf + 4, y_pixels_per_unit);
1936 buf[8] = (png_byte)unit_type;
1942#ifdef PNG_WRITE_tIME_SUPPORTED
1953 if (mod_time->
month > 12 || mod_time->
month < 1 ||
1954 mod_time->
day > 31 || mod_time->
day < 1 ||
1955 mod_time->
hour > 23 || mod_time->
second > 60)
1957 png_warning(
png_ptr,
"Invalid time specified for tIME chunk");
1961 png_save_uint_16(
buf, mod_time->
year);
1977 int usr_pixel_depth;
1979#ifdef PNG_WRITE_FILTER_SUPPORTED
1985 usr_pixel_depth =
png_ptr->usr_channels *
png_ptr->usr_bit_depth;
1990 png_ptr->maximum_pixel_depth = (png_byte)usr_pixel_depth;
1997#ifdef PNG_WRITE_FILTER_SUPPORTED
2014 int num_filters = 0;
2030 if (num_filters > 1)
2040 png_calloc(
png_ptr, buf_size));
2043#ifdef PNG_WRITE_INTERLACING_SUPPORTED
2050 png_pass_ystart[0]) / png_pass_yinc[0];
2053 png_pass_start[0]) / png_pass_inc[0];
2075 png_debug(1,
"in png_write_finish_row");
2084#ifdef PNG_WRITE_INTERLACING_SUPPORTED
2105 png_pass_inc[
png_ptr->pass] - 1 -
2106 png_pass_start[
png_ptr->pass]) /
2110 png_pass_yinc[
png_ptr->pass] - 1 -
2111 png_pass_ystart[
png_ptr->pass]) /
2139#ifdef PNG_WRITE_INTERLACING_SUPPORTED
2150 png_debug(1,
"in png_do_write_interlace");
2172 for (
i = png_pass_start[
pass];
i < row_width;
2173 i += png_pass_inc[
pass])
2176 value = (
int)(*
sp >> (7 - (
int)(
i & 0x07))) & 0x01;
2182 *dp++ = (png_byte)
d;
2210 for (
i = png_pass_start[
pass];
i < row_width;
2211 i += png_pass_inc[
pass])
2214 value = (*
sp >> ((3 - (
int)(
i & 0x03)) << 1)) & 0x03;
2220 *dp++ = (png_byte)
d;
2246 for (
i = png_pass_start[
pass];
i < row_width;
2247 i += png_pass_inc[
pass])
2250 value = (*
sp >> ((1 - (
int)(
i & 0x01)) << 2)) & 0x0f;
2256 *dp++ = (png_byte)
d;
2284 for (
i = png_pass_start[
pass];
i < row_width;
2285 i += png_pass_inc[
pass])
2302 png_pass_inc[
pass] - 1 -
2303 png_pass_start[
pass]) /
2321#ifdef PNG_WRITE_FILTER_SUPPORTED
2324 size_t row_bytes,
size_t lmins)
2338 sum += 128 -
abs((
int)
v - 128);
2340 sum += (
v < 128) ?
v : 256 -
v;
2344 for (lp =
png_ptr->row_buf + 1;
i < row_bytes;
2345 i++, rp++, lp++, dp++)
2347 v = *dp = (png_byte)(((
int)*rp - (
int)*lp) & 0xff);
2349 sum += 128 -
abs((
int)
v - 128);
2351 sum += (
v < 128) ?
v : 256 -
v;
2376 for (lp =
png_ptr->row_buf + 1;
i < row_bytes;
2377 i++, rp++, lp++, dp++)
2379 *dp = (png_byte)(((
int)*rp - (
int)*lp) & 0xff);
2394 pp =
png_ptr->prev_row + 1;
i < row_bytes;
2395 i++, rp++, pp++, dp++)
2397 v = *dp = (png_byte)(((
int)*rp - (
int)*pp) & 0xff);
2399 sum += 128 -
abs((
int)
v - 128);
2401 sum += (
v < 128) ?
v : 256 -
v;
2419 pp =
png_ptr->prev_row + 1;
i < row_bytes;
2420 i++, rp++, pp++, dp++)
2422 *dp = (png_byte)(((
int)*rp - (
int)*pp) & 0xff);
2428 size_t row_bytes,
size_t lmins)
2440 v = *dp++ = (png_byte)(((
int)*rp++ - ((
int)*pp++ / 2)) & 0xff);
2443 sum += 128 -
abs((
int)
v - 128);
2445 sum += (
v < 128) ?
v : 256 -
v;
2449 for (lp =
png_ptr->row_buf + 1;
i < row_bytes;
i++)
2451 v = *dp++ = (png_byte)(((
int)*rp++ - (((
int)*pp++ + (
int)*lp++) / 2))
2455 sum += 128 -
abs((
int)
v - 128);
2457 sum += (
v < 128) ?
v : 256 -
v;
2478 *dp++ = (png_byte)(((
int)*rp++ - ((
int)*pp++ / 2)) & 0xff);
2481 for (lp =
png_ptr->row_buf + 1;
i < row_bytes;
i++)
2483 *dp++ = (png_byte)(((
int)*rp++ - (((
int)*pp++ + (
int)*lp++) / 2))
2490 size_t row_bytes,
size_t lmins)
2502 v = *dp++ = (png_byte)(((
int)*rp++ - (
int)*pp++) & 0xff);
2505 sum += 128 -
abs((
int)
v - 128);
2507 sum += (
v < 128) ?
v : 256 -
v;
2514 int a,
b,
c,
pa, pb, pc,
p;
2528 pa =
p < 0 ? -
p :
p;
2529 pb = pc < 0 ? -pc : pc;
2530 pc = (
p + pc) < 0 ? -(
p + pc) :
p + pc;
2533 p = (
pa <= pb &&
pa <=pc) ?
a : (pb <= pc) ?
b :
c;
2535 v = *dp++ = (png_byte)(((
int)*rp++ -
p) & 0xff);
2538 sum += 128 -
abs((
int)
v - 128);
2540 sum += (
v < 128) ?
v : 256 -
v;
2561 *dp++ = (png_byte)(((
int)*rp++ - (
int)*pp++) & 0xff);
2567 int a,
b,
c,
pa, pb, pc,
p;
2581 pa =
p < 0 ? -
p :
p;
2582 pb = pc < 0 ? -pc : pc;
2583 pc = (
p + pc) < 0 ? -(
p + pc) :
p + pc;
2586 p = (
pa <= pb &&
pa <=pc) ?
a : (pb <= pc) ?
b :
c;
2588 *dp++ = (png_byte)(((
int)*rp++ -
p) & 0xff);
2596#ifndef PNG_WRITE_FILTER_SUPPORTED
2599 unsigned int filter_to_do =
png_ptr->do_filter;
2604 size_t row_bytes = row_info->
rowbytes;
2606 png_debug(1,
"in png_write_find_filter");
2650 filter_to_do &= 0
U-filter_to_do;
2664 for (
i = 0, rp = row_buf + 1;
i < row_bytes;
i++, rp++)
2668 sum += 128 -
abs((
int)
v - 128);
2670 sum += (
v < 128) ?
v : 256 -
v;
2682 png_setup_sub_row_only(
png_ptr,
bpp, row_bytes);
2689 size_t lmins = mins;
2708 png_setup_up_row_only(
png_ptr, row_bytes);
2715 size_t lmins = mins;
2717 sum = png_setup_up_row(
png_ptr, row_bytes, lmins);
2734 png_setup_avg_row_only(
png_ptr,
bpp, row_bytes);
2741 size_t lmins = mins;
2760 png_setup_paeth_row_only(
png_ptr,
bpp, row_bytes);
2767 size_t lmins = mins;
2792 size_t full_row_length)
2794 png_debug(1,
"in png_write_filtered_row");
2796 png_debug1(2,
"filter = %d", filtered_row[0]);
2800#ifdef PNG_WRITE_FILTER_SUPPORTED
2813 png_write_finish_row(
png_ptr);
2815#ifdef PNG_WRITE_FLUSH_SUPPORTED
2818 if (
png_ptr->flush_dist > 0 &&
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void _In_opt_ PIRP _In_ LIST_ENTRY _In_ uint8_t compression
int ZEXPORT deflateReset(z_streamp strm)
static unsigned int palette_size(DWORD flags)
#define Z_DEFAULT_STRATEGY
int deflate(z_streamp strm, int flush) DECLSPEC_HIDDEN
int deflateEnd(z_streamp strm) DECLSPEC_HIDDEN
_ACRTIMP size_t __cdecl strlen(const char *)
static HCRYPTKEY new_key(HCRYPTPROV hProv, ALG_ID aiAlgid, DWORD dwFlags, CRYPTKEY **ppCryptKey)
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
GLuint GLuint GLsizei GLenum type
GLclampf GLclampf GLclampf alpha
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLint GLint GLsizei GLsizei height
GLint GLint GLsizei width
GLboolean GLboolean GLboolean b
GLenum const GLfloat * params
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint GLsizei GLsizei * length
GLboolean GLboolean GLboolean GLboolean a
GLenum GLenum GLenum input
GLubyte GLubyte GLubyte GLubyte w
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define memcpy(s1, s2, n)
#define PNG_COLOR_TYPE_RGB
#define PNG_COLOR_TYPE_RGB_ALPHA
#define PNG_COLOR_TYPE_GRAY_ALPHA
#define PNG_COLOR_TYPE_GRAY
#define PNG_COLOR_TYPE_PALETTE
static LARGE_INTEGER * frequency
#define PNG_INTRAPIXEL_DIFFERENCING
png_const_structrp png_const_inforp int * unit
#define PNG_MAX_PALETTE_LENGTH
#define PNG_ITXT_COMPRESSION_NONE
#define PNG_TEXT_COMPRESSION_zTXt
#define PNG_FLAG_MNG_FILTER_64
#define PNG_TEXT_COMPRESSION_NONE
#define PNG_sRGB_INTENT_LAST
#define PNG_EQUATION_LAST
#define PNG_FILTER_VALUE_AVG
#define PNG_COLOR_MASK_COLOR
#define PNG_PASS_ROWS(height, pass)
#define PNG_FILTER_VALUE_UP
#define PNG_IO_CHUNK_DATA
#define PNG_FILTER_TYPE_BASE
#define png_get_uint_32(buf)
#define PNG_COLOR_MASK_ALPHA
#define PNG_PASS_COLS(width, pass)
#define PNG_INTERLACE_ADAM7
#define PNG_RESOLUTION_LAST
#define PNG_FLAG_MNG_EMPTY_PLTE
#define PNG_FILTER_VALUE_PAETH
#define PNG_FILTER_VALUE_NONE
#define PNG_INTERLACE_NONE
#define PNG_COMPRESSION_TYPE_BASE
#define PNG_FILTER_VALUE_SUB
png_struct *PNG_RESTRICT png_structrp
#define PNG_ITXT_COMPRESSION_zTXt
png_int_32 png_fixed_point
const png_byte * png_const_bytep
const png_uint_16 * png_const_uint_16p
const char * png_const_charp
#define png_debug2(l, m, p1, p2)
#define png_debug1(l, m, p1)
#define PNG_Z_DEFAULT_STRATEGY
#define PNG_Z_DEFAULT_NOFILTER_STRATEGY
#define PNG_MNG_FEATURES_SUPPORTED
#define PNG_POINTER_INDEXING_SUPPORTED
#define PNG_HAVE_PNG_SIGNATURE
#define PNG_ROWBYTES(pixel_bits, width)
#define png_app_warning(pp, s)
#define PNG_CSTRING_FROM_CHUNK(s, c)
#define PNG_CHUNK_FROM_STRING(s)
#define PNG_FLAG_ZSTREAM_INITIALIZED
#define png_voidcast(type, value)
#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY
#define PNG_STRING_FROM_CHUNK(s, c)
#define PNGZ_INPUT_CAST(b)
static int sum(int x_, int y_)
static unsigned __int64 next
#define deflateInit2(strm, level, method, windowBits, memLevel, strategy)
static const WCHAR lang[]