mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng16] Added PNG_IMAGE_FLAG_FAST for the benefit of applications that
store intermediate files, or intermediate in-memory data, while processing image data with the simplified API. The option makes the files larger but faster to write and read. pngstest now uses this by default; this can be disabled with the --slow option.
This commit is contained in:
committed by
Glenn Randers-Pehrson
parent
1c25b9b06b
commit
dee7577330
21
pngwrite.c
21
pngwrite.c
@@ -731,6 +731,15 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0 /* To do: implement png_do_check_palette_indexes() */
|
||||
/* Check for out-of-range palette index */
|
||||
if (png_ptr->num_palette < (1 << png_ptr->bit_depth))
|
||||
png_do_check_palette_indexes(&row_info, png_ptr->row_buf + 1,
|
||||
png_ptr->num_palette_max);
|
||||
if (png_ptr->num_palette_max > num_palette + 1)
|
||||
png_warning(png_ptr, "Palette index exceeded num_palette");
|
||||
#endif
|
||||
|
||||
/* Find a filter if necessary, filter the row and write it out. */
|
||||
png_write_find_filter(png_ptr, &row_info);
|
||||
|
||||
@@ -2109,6 +2118,18 @@ png_image_write_main(png_voidp argument)
|
||||
display->row_bytes = row_bytes;
|
||||
}
|
||||
|
||||
/* Apply 'fast' options if the flag is set. */
|
||||
if ((image->flags & PNG_IMAGE_FLAG_FAST) != 0)
|
||||
{
|
||||
png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, PNG_NO_FILTERS);
|
||||
/* NOTE: determined by experiment using pngstest, this reflects some
|
||||
* balance between the time to write the image once and the time to read
|
||||
* it about 50 times. The speed-up in pngstest was about 10-20% of the
|
||||
* total (user) time on a heavily loaded system.
|
||||
*/
|
||||
png_set_compression_level(png_ptr, 3);
|
||||
}
|
||||
|
||||
/* Check for the cases that currently require a pre-transform on the row
|
||||
* before it is written. This only applies when the input is 16-bit and
|
||||
* either there is an alpha channel or it is converted to 8-bit.
|
||||
|
||||
Reference in New Issue
Block a user