16#ifdef PNG_WRITE_SUPPORTED
18#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED
26 buf[0] = (png_byte)((
i >> 24) & 0xffU);
27 buf[1] = (png_byte)((
i >> 16) & 0xffU);
28 buf[2] = (png_byte)((
i >> 8) & 0xffU);
29 buf[3] = (png_byte)(
i & 0xffU);
39 buf[0] = (png_byte)((
i >> 8) & 0xffU);
40 buf[1] = (png_byte)(
i & 0xffU);
53 png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
55#ifdef PNG_IO_STATE_SUPPORTED
62 (
size_t)(8 -
png_ptr->sig_bytes));
78#if defined(PNG_DEBUG) && (PNG_DEBUG > 0)
86#ifdef PNG_IO_STATE_SUPPORTED
95 png_save_uint_32(
buf + 4, chunk_name);
99 png_ptr->chunk_name = chunk_name;
106#ifdef PNG_IO_STATE_SUPPORTED
152#ifdef PNG_IO_STATE_SUPPORTED
183 png_error(
png_ptr,
"length exceeds PNG maximum");
211 if (
png_ptr->rowbytes < 32768 &&
h < 32768)
219 unsigned int pd =
png_ptr->pixel_depth;
242#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
255 if (data_size <= 16384)
257 unsigned int z_cmf =
data[0];
259 if ((z_cmf & 0x0f) == 8 && (z_cmf & 0xf0) <= 0x70)
261 unsigned int z_cinfo;
262 unsigned int half_z_window_size;
264 z_cinfo = z_cmf >> 4;
265 half_z_window_size = 1U << (z_cinfo + 7);
267 if (data_size <= half_z_window_size)
273 half_z_window_size >>= 1;
276 while (z_cinfo > 0 && data_size <= half_z_window_size);
278 z_cmf = (z_cmf & 0x0f) | (z_cinfo << 4);
280 data[0] = (png_byte)z_cmf;
281 tmp =
data[1] & 0xe0;
282 tmp += 0x1f - ((z_cmf << 8) + tmp) % 0x1f;
283 data[1] = (png_byte)tmp;
297#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED)
308 (
void)png_safecat(
msg, (
sizeof msg), 10,
" using zstream");
330 int memLevel =
png_ptr->zlib_mem_level;
337 strategy =
png_ptr->zlib_strategy;
348#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
352 memLevel =
png_ptr->zlib_text_mem_level;
353 strategy =
png_ptr->zlib_text_strategy;
371 if (data_size <= 16384)
378 unsigned int half_window_size = 1U << (
windowBits-1);
380 while (data_size + 262 <= half_window_size)
382 half_window_size >>= 1;
392 png_ptr->zlib_set_mem_level != memLevel ||
393 png_ptr->zlib_set_strategy != strategy))
396 png_warning(
png_ptr,
"deflateEnd failed (ignored)");
398 png_ptr->flags &= ~PNG_FLAG_ZSTREAM_INITIALIZED;
407 png_ptr->zstream.avail_out = 0;
441 png_compression_bufferp
list = *listp;
458#ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
474 png_byte output[1024];
482 comp->input_len = input_len;
483 comp->output_len = 0;
503 ret = png_deflate_claim(
png_ptr, chunk_name, comp->input_len);
515 png_compression_bufferp *
end = &
png_ptr->zbuffer_list;
522 png_ptr->zstream.next_out = comp->output;
523 png_ptr->zstream.avail_out = (
sizeof comp->output);
525 output_len =
png_ptr->zstream.avail_out;
531 if (avail_in > input_len)
532 avail_in = (
uInt)input_len;
534 input_len -= avail_in;
536 png_ptr->zstream.avail_in = avail_in;
538 if (
png_ptr->zstream.avail_out == 0)
540 png_compression_buffer *
next;
573 output_len +=
png_ptr->zstream.avail_out;
586 input_len +=
png_ptr->zstream.avail_in;
594 output_len -=
png_ptr->zstream.avail_out;
595 png_ptr->zstream.avail_out = 0;
596 comp->output_len = output_len;
619#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
621 optimize_cmf(comp->output, comp->input_len);
642 png_compression_buffer *
next =
png_ptr->zbuffer_list;
646 if (
avail > output_len)
653 if (output_len == 0 ||
next ==
NULL)
657 output =
next->output;
663 png_error(
png_ptr,
"error writing ancillary chunked compressed data");
673 int bit_depth,
int color_type,
int compression_type,
int filter_type,
677 int is_invalid_depth;
691#ifdef PNG_WRITE_16BIT_SUPPORTED
698 "Invalid bit depth for grayscale image");
703 is_invalid_depth = (bit_depth != 8);
704#ifdef PNG_WRITE_16BIT_SUPPORTED
705 is_invalid_depth = (is_invalid_depth && bit_depth != 16);
707 if (is_invalid_depth)
708 png_error(
png_ptr,
"Invalid bit depth for RGB image");
724 png_error(
png_ptr,
"Invalid bit depth for paletted image");
729 is_invalid_depth = (bit_depth != 8);
730#ifdef PNG_WRITE_16BIT_SUPPORTED
731 is_invalid_depth = (is_invalid_depth && bit_depth != 16);
733 if (is_invalid_depth)
734 png_error(
png_ptr,
"Invalid bit depth for grayscale+alpha image");
740 is_invalid_depth = (bit_depth != 8);
741#ifdef PNG_WRITE_16BIT_SUPPORTED
742 is_invalid_depth = (is_invalid_depth && bit_depth != 16);
744 if (is_invalid_depth)
745 png_error(
png_ptr,
"Invalid bit depth for RGBA image");
751 png_error(
png_ptr,
"Invalid image color type specified");
756 png_warning(
png_ptr,
"Invalid compression type specified");
779 png_warning(
png_ptr,
"Invalid filter type specified");
783#ifdef PNG_WRITE_INTERLACING_SUPPORTED
787 png_warning(
png_ptr,
"Invalid interlace type specified");
795 png_ptr->bit_depth = (png_byte)bit_depth;
796 png_ptr->color_type = (png_byte)color_type;
797 png_ptr->interlaced = (png_byte)interlace_type;
798#ifdef PNG_MNG_FEATURES_SUPPORTED
799 png_ptr->filter_type = (png_byte)filter_type;
801 png_ptr->compression_type = (png_byte)compression_type;
815 buf[8] = (png_byte)bit_depth;
816 buf[9] = (png_byte)color_type;
817 buf[10] = (png_byte)compression_type;
818 buf[11] = (png_byte)filter_type;
819 buf[12] = (png_byte)interlace_type;
858 num_pal == 0) || num_pal > max_palette_length)
862 png_error(
png_ptr,
"Invalid number of colors in palette");
867 png_warning(
png_ptr,
"Invalid number of colors in palette");
875 "Ignoring request to write a PLTE chunk in grayscale PNG");
880 png_ptr->num_palette = (png_uint_16)num_pal;
884#ifdef PNG_POINTER_INDEXING_SUPPORTED
886 for (
i = 0, pal_ptr =
palette;
i < num_pal;
i++, pal_ptr++)
900 for (
i = 0;
i < num_pal;
i++)
975 if (
avail > input_len)
984 input_len +=
png_ptr->zstream.avail_in;
991 if (
png_ptr->zstream.avail_out == 0)
999#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
1032 png_error(
png_ptr,
"Z_OK on Z_FINISH with output space");
1046#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
1054 png_ptr->zstream.avail_out = 0;
1081#ifdef PNG_WRITE_gAMA_SUPPORTED
1096#ifdef PNG_WRITE_sRGB_SUPPORTED
1107 "Invalid sRGB rendering intent specified");
1109 buf[0]=(png_byte)srgb_intent;
1114#ifdef PNG_WRITE_iCCP_SUPPORTED
1122 png_byte new_name[81];
1123 compression_state comp;
1132 png_error(
png_ptr,
"No profile for iCCP chunk");
1136 if (profile_len < 132)
1137 png_error(
png_ptr,
"ICC profile too short");
1140 if (
temp > 3 && (profile_len & 0x03))
1141 png_error(
png_ptr,
"ICC profile length invalid (not a multiple of 4)");
1146 if (profile_len != embedded_profile_len)
1147 png_error(
png_ptr,
"Profile length does not match profile");
1150 name_len = png_check_keyword(
png_ptr,
name, new_name);
1153 png_error(
png_ptr,
"iCCP: invalid keyword");
1160 png_text_compress_init(&comp,
profile, profile_len);
1166 png_write_chunk_header(
png_ptr,
png_iCCP, name_len + comp.output_len);
1168 png_write_chunk_data(
png_ptr, new_name, name_len);
1170 png_write_compressed_data_out(
png_ptr, &comp);
1176#ifdef PNG_WRITE_sPLT_SUPPORTED
1182 png_byte new_name[80];
1183 png_byte entrybuf[10];
1184 size_t entry_size = (spalette->
depth == 8 ? 6 : 10);
1193 name_len = png_check_keyword(
png_ptr, spalette->
name, new_name);
1196 png_error(
png_ptr,
"sPLT: invalid keyword");
1202 png_write_chunk_data(
png_ptr, (
png_bytep)new_name, (
size_t)(name_len + 1));
1207#ifdef PNG_POINTER_INDEXING_SUPPORTED
1208 for (ep = spalette->
entries; ep<spalette->entries + spalette->
nentries; ep++)
1210 if (spalette->
depth == 8)
1212 entrybuf[0] = (png_byte)ep->red;
1213 entrybuf[1] = (png_byte)ep->green;
1214 entrybuf[2] = (png_byte)ep->blue;
1215 entrybuf[3] = (png_byte)ep->alpha;
1216 png_save_uint_16(entrybuf + 4, ep->frequency);
1221 png_save_uint_16(entrybuf + 0, ep->red);
1222 png_save_uint_16(entrybuf + 2, ep->green);
1223 png_save_uint_16(entrybuf + 4, ep->blue);
1224 png_save_uint_16(entrybuf + 6, ep->alpha);
1225 png_save_uint_16(entrybuf + 8, ep->frequency);
1228 png_write_chunk_data(
png_ptr, entrybuf, entry_size);
1234 if (spalette->
depth == 8)
1236 entrybuf[0] = (png_byte)ep[
i].
red;
1237 entrybuf[1] = (png_byte)ep[
i].
green;
1238 entrybuf[2] = (png_byte)ep[
i].
blue;
1239 entrybuf[3] = (png_byte)ep[
i].
alpha;
1240 png_save_uint_16(entrybuf + 4, ep[
i].
frequency);
1245 png_save_uint_16(entrybuf + 0, ep[
i].
red);
1246 png_save_uint_16(entrybuf + 2, ep[
i].
green);
1247 png_save_uint_16(entrybuf + 4, ep[
i].
blue);
1248 png_save_uint_16(entrybuf + 6, ep[
i].
alpha);
1249 png_save_uint_16(entrybuf + 8, ep[
i].
frequency);
1252 png_write_chunk_data(
png_ptr, entrybuf, entry_size);
1260#ifdef PNG_WRITE_sBIT_SUPPORTED
1278 if (sbit->
red == 0 || sbit->
red > maxbits ||
1280 sbit->
blue == 0 || sbit->
blue > maxbits)
1282 png_warning(
png_ptr,
"Invalid sBIT depth specified");
1296 png_warning(
png_ptr,
"Invalid sBIT depth specified");
1308 png_warning(
png_ptr,
"Invalid sBIT depth specified");
1319#ifdef PNG_WRITE_cHRM_SUPPORTED
1329 png_save_int_32(
buf, xy->whitex);
1330 png_save_int_32(
buf + 4, xy->whitey);
1332 png_save_int_32(
buf + 8, xy->redx);
1333 png_save_int_32(
buf + 12, xy->redy);
1335 png_save_int_32(
buf + 16, xy->greenx);
1336 png_save_int_32(
buf + 20, xy->greeny);
1338 png_save_int_32(
buf + 24, xy->bluex);
1339 png_save_int_32(
buf + 28, xy->bluey);
1345#ifdef PNG_WRITE_tRNS_SUPPORTED
1357 if (num_trans <= 0 || num_trans > (
int)
png_ptr->num_palette)
1360 "Invalid number of transparent colors specified");
1375 "Ignoring attempt to write tRNS chunk out-of-range for bit_depth");
1380 png_save_uint_16(
buf, tran->
gray);
1387 png_save_uint_16(
buf, tran->
red);
1388 png_save_uint_16(
buf + 2, tran->
green);
1389 png_save_uint_16(
buf + 4, tran->
blue);
1390#ifdef PNG_WRITE_16BIT_SUPPORTED
1397 "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8");
1411#ifdef PNG_WRITE_bKGD_SUPPORTED
1429 png_warning(
png_ptr,
"Invalid background palette index");
1439 png_save_uint_16(
buf, back->
red);
1440 png_save_uint_16(
buf + 2, back->
green);
1441 png_save_uint_16(
buf + 4, back->
blue);
1442#ifdef PNG_WRITE_16BIT_SUPPORTED
1449 "Ignoring attempt to write 16-bit bKGD chunk "
1450 "when bit_depth is 8");
1463 "Ignoring attempt to write bKGD chunk out-of-range for bit_depth");
1468 png_save_uint_16(
buf, back->
gray);
1474#ifdef PNG_WRITE_eXIf_SUPPORTED
1486 for (
i = 0;
i < num_exif;
i++)
1496#ifdef PNG_WRITE_hIST_SUPPORTED
1506 if (num_hist > (
int)
png_ptr->num_palette)
1508 png_debug2(3,
"num_hist = %d, num_palette = %d", num_hist,
1511 png_warning(
png_ptr,
"Invalid number of histogram entries specified");
1517 for (
i = 0;
i < num_hist;
i++)
1519 png_save_uint_16(
buf, hist[
i]);
1527#ifdef PNG_WRITE_tEXt_SUPPORTED
1541 png_error(
png_ptr,
"tEXt: invalid keyword");
1550 png_error(
png_ptr,
"tEXt: text too long");
1570#ifdef PNG_WRITE_zTXt_SUPPORTED
1578 compression_state comp;
1589 png_error(
png_ptr,
"zTXt: invalid compression type");
1594 png_error(
png_ptr,
"zTXt: invalid keyword");
1614 png_write_compressed_data_out(
png_ptr, &comp);
1621#ifdef PNG_WRITE_iTXt_SUPPORTED
1628 size_t lang_len, lang_key_len;
1630 compression_state comp;
1637 png_error(
png_ptr,
"iTXt: invalid keyword");
1653 png_error(
png_ptr,
"iTXt: invalid compression");
1671 if (lang_key ==
NULL) lang_key =
"";
1672 lang_key_len =
strlen(lang_key)+1;
1675 prefix_len = key_len;
1679 prefix_len = (
png_uint_32)(prefix_len + lang_len);
1684 prefix_len = (
png_uint_32)(prefix_len + lang_key_len);
1697 png_error(
png_ptr,
"iTXt: uncompressed text too long");
1703 png_write_chunk_header(
png_ptr,
png_iTXt, comp.output_len + prefix_len);
1712 png_write_compressed_data_out(
png_ptr, &comp);
1721#ifdef PNG_WRITE_oFFs_SUPPORTED
1732 png_warning(
png_ptr,
"Unrecognized unit type for oFFs chunk");
1734 png_save_int_32(
buf, x_offset);
1735 png_save_int_32(
buf + 4, y_offset);
1736 buf[8] = (png_byte)unit_type;
1741#ifdef PNG_WRITE_pCAL_SUPPORTED
1749 size_t units_len, total_len;
1752 png_byte new_purpose[80];
1755 png_debug1(1,
"in png_write_pCAL (%d parameters)", nparams);
1758 png_error(
png_ptr,
"Unrecognized equation type for pCAL chunk");
1760 purpose_len = png_check_keyword(
png_ptr, purpose, new_purpose);
1762 if (purpose_len == 0)
1763 png_error(
png_ptr,
"pCAL: invalid keyword");
1767 png_debug1(3,
"pCAL purpose length = %d", (
int)purpose_len);
1768 units_len =
strlen(
units) + (nparams == 0 ? 0 : 1);
1769 png_debug1(3,
"pCAL units length = %d", (
int)units_len);
1770 total_len = purpose_len + units_len + 10;
1772 params_len = (
size_t *)png_malloc(
png_ptr,
1778 for (
i = 0;
i < nparams;
i++)
1781 png_debug2(3,
"pCAL parameter %d length = %lu",
i,
1782 (
unsigned long)params_len[
i]);
1783 total_len += params_len[
i];
1786 png_debug1(3,
"pCAL total length = %d", (
int)total_len);
1788 png_write_chunk_data(
png_ptr, new_purpose, purpose_len);
1789 png_save_int_32(
buf, X0);
1790 png_save_int_32(
buf + 4, X1);
1792 buf[9] = (png_byte)nparams;
1796 for (
i = 0;
i < nparams;
i++)
1801 png_free(
png_ptr, params_len);
1806#ifdef PNG_WRITE_sCAL_SUPPORTED
1813 size_t wlen, hlen, total_len;
1819 total_len = wlen + hlen + 2;
1823 png_warning(
png_ptr,
"Can't write sCAL (buffer too small)");
1831 png_debug1(3,
"sCAL total length = %u", (
unsigned int)total_len);
1836#ifdef PNG_WRITE_pHYs_SUPPORTED
1848 png_warning(
png_ptr,
"Unrecognized unit type for pHYs chunk");
1850 png_save_uint_32(
buf, x_pixels_per_unit);
1851 png_save_uint_32(
buf + 4, y_pixels_per_unit);
1852 buf[8] = (png_byte)unit_type;
1858#ifdef PNG_WRITE_tIME_SUPPORTED
1869 if (mod_time->
month > 12 || mod_time->
month < 1 ||
1870 mod_time->
day > 31 || mod_time->
day < 1 ||
1871 mod_time->
hour > 23 || mod_time->
second > 60)
1873 png_warning(
png_ptr,
"Invalid time specified for tIME chunk");
1877 png_save_uint_16(
buf, mod_time->
year);
1892#ifdef PNG_WRITE_INTERLACING_SUPPORTED
1896 static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
1899 static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
1902 static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
1905 static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
1909 int usr_pixel_depth;
1911#ifdef PNG_WRITE_FILTER_SUPPORTED
1917 usr_pixel_depth =
png_ptr->usr_channels *
png_ptr->usr_bit_depth;
1922 png_ptr->maximum_pixel_depth = (png_byte)usr_pixel_depth;
1929#ifdef PNG_WRITE_FILTER_SUPPORTED
1946 int num_filters = 0;
1962 if (num_filters > 1)
1972 png_calloc(
png_ptr, buf_size));
1975#ifdef PNG_WRITE_INTERLACING_SUPPORTED
1982 png_pass_ystart[0]) / png_pass_yinc[0];
1985 png_pass_start[0]) / png_pass_inc[0];
2007#ifdef PNG_WRITE_INTERLACING_SUPPORTED
2011 static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
2014 static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
2017 static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
2020 static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
2023 png_debug(1,
"in png_write_finish_row");
2032#ifdef PNG_WRITE_INTERLACING_SUPPORTED
2053 png_pass_inc[
png_ptr->pass] - 1 -
2054 png_pass_start[
png_ptr->pass]) /
2058 png_pass_yinc[
png_ptr->pass] - 1 -
2059 png_pass_ystart[
png_ptr->pass]) /
2087#ifdef PNG_WRITE_INTERLACING_SUPPORTED
2101 static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
2104 static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
2106 png_debug(1,
"in png_do_write_interlace");
2128 for (
i = png_pass_start[
pass];
i < row_width;
2129 i += png_pass_inc[
pass])
2132 value = (
int)(*
sp >> (7 - (
int)(
i & 0x07))) & 0x01;
2138 *dp++ = (png_byte)
d;
2166 for (
i = png_pass_start[
pass];
i < row_width;
2167 i += png_pass_inc[
pass])
2170 value = (*
sp >> ((3 - (
int)(
i & 0x03)) << 1)) & 0x03;
2176 *dp++ = (png_byte)
d;
2202 for (
i = png_pass_start[
pass];
i < row_width;
2203 i += png_pass_inc[
pass])
2206 value = (*
sp >> ((1 - (
int)(
i & 0x01)) << 2)) & 0x0f;
2212 *dp++ = (png_byte)
d;
2240 for (
i = png_pass_start[
pass];
i < row_width;
2241 i += png_pass_inc[
pass])
2258 png_pass_inc[
pass] - 1 -
2259 png_pass_start[
pass]) /
2277#ifdef PNG_WRITE_FILTER_SUPPORTED
2280 size_t row_bytes,
size_t lmins)
2294 sum += 128 -
abs((
int)
v - 128);
2296 sum += (
v < 128) ?
v : 256 -
v;
2300 for (lp =
png_ptr->row_buf + 1;
i < row_bytes;
2301 i++, rp++, lp++, dp++)
2303 v = *dp = (png_byte)(((
int)*rp - (
int)*lp) & 0xff);
2305 sum += 128 -
abs((
int)
v - 128);
2307 sum += (
v < 128) ?
v : 256 -
v;
2332 for (lp =
png_ptr->row_buf + 1;
i < row_bytes;
2333 i++, rp++, lp++, dp++)
2335 *dp = (png_byte)(((
int)*rp - (
int)*lp) & 0xff);
2350 pp =
png_ptr->prev_row + 1;
i < row_bytes;
2351 i++, rp++, pp++, dp++)
2353 v = *dp = (png_byte)(((
int)*rp - (
int)*pp) & 0xff);
2355 sum += 128 -
abs((
int)
v - 128);
2357 sum += (
v < 128) ?
v : 256 -
v;
2375 pp =
png_ptr->prev_row + 1;
i < row_bytes;
2376 i++, rp++, pp++, dp++)
2378 *dp = (png_byte)(((
int)*rp - (
int)*pp) & 0xff);
2384 size_t row_bytes,
size_t lmins)
2396 v = *dp++ = (png_byte)(((
int)*rp++ - ((
int)*pp++ / 2)) & 0xff);
2399 sum += 128 -
abs((
int)
v - 128);
2401 sum += (
v < 128) ?
v : 256 -
v;
2405 for (lp =
png_ptr->row_buf + 1;
i < row_bytes;
i++)
2407 v = *dp++ = (png_byte)(((
int)*rp++ - (((
int)*pp++ + (
int)*lp++) / 2))
2411 sum += 128 -
abs((
int)
v - 128);
2413 sum += (
v < 128) ?
v : 256 -
v;
2434 *dp++ = (png_byte)(((
int)*rp++ - ((
int)*pp++ / 2)) & 0xff);
2437 for (lp =
png_ptr->row_buf + 1;
i < row_bytes;
i++)
2439 *dp++ = (png_byte)(((
int)*rp++ - (((
int)*pp++ + (
int)*lp++) / 2))
2446 size_t row_bytes,
size_t lmins)
2458 v = *dp++ = (png_byte)(((
int)*rp++ - (
int)*pp++) & 0xff);
2461 sum += 128 -
abs((
int)
v - 128);
2463 sum += (
v < 128) ?
v : 256 -
v;
2470 int a,
b,
c,
pa, pb, pc,
p;
2484 pa =
p < 0 ? -
p :
p;
2485 pb = pc < 0 ? -pc : pc;
2486 pc = (
p + pc) < 0 ? -(
p + pc) :
p + pc;
2489 p = (
pa <= pb &&
pa <=pc) ?
a : (pb <= pc) ?
b :
c;
2491 v = *dp++ = (png_byte)(((
int)*rp++ -
p) & 0xff);
2494 sum += 128 -
abs((
int)
v - 128);
2496 sum += (
v < 128) ?
v : 256 -
v;
2517 *dp++ = (png_byte)(((
int)*rp++ - (
int)*pp++) & 0xff);
2523 int a,
b,
c,
pa, pb, pc,
p;
2537 pa =
p < 0 ? -
p :
p;
2538 pb = pc < 0 ? -pc : pc;
2539 pc = (
p + pc) < 0 ? -(
p + pc) :
p + pc;
2542 p = (
pa <= pb &&
pa <=pc) ?
a : (pb <= pc) ?
b :
c;
2544 *dp++ = (png_byte)(((
int)*rp++ -
p) & 0xff);
2552#ifndef PNG_WRITE_FILTER_SUPPORTED
2555 unsigned int filter_to_do =
png_ptr->do_filter;
2560 size_t row_bytes = row_info->
rowbytes;
2562 png_debug(1,
"in png_write_find_filter");
2606 filter_to_do &= 0
U-filter_to_do;
2620 for (
i = 0, rp = row_buf + 1;
i < row_bytes;
i++, rp++)
2624 sum += 128 -
abs((
int)
v - 128);
2626 sum += (
v < 128) ?
v : 256 -
v;
2638 png_setup_sub_row_only(
png_ptr,
bpp, row_bytes);
2645 size_t lmins = mins;
2664 png_setup_up_row_only(
png_ptr, row_bytes);
2671 size_t lmins = mins;
2673 sum = png_setup_up_row(
png_ptr, row_bytes, lmins);
2690 png_setup_avg_row_only(
png_ptr,
bpp, row_bytes);
2697 size_t lmins = mins;
2716 png_setup_paeth_row_only(
png_ptr,
bpp, row_bytes);
2723 size_t lmins = mins;
2748 size_t full_row_length)
2750 png_debug(1,
"in png_write_filtered_row");
2752 png_debug1(2,
"filter = %d", filtered_row[0]);
2756#ifdef PNG_WRITE_FILTER_SUPPORTED
2769 png_write_finish_row(
png_ptr);
2771#ifdef PNG_WRITE_FLUSH_SUPPORTED
2774 if (
png_ptr->flush_dist > 0 &&
ACPI_SIZE strlen(const char *String)
_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
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[]