[devel] Fix png_get_current_row_number in the interlaced case.
This commit is contained in:
parent
9c69360e97
commit
5432c01ffd
4
png.h
4
png.h
@ -1477,6 +1477,10 @@ PNG_EXPORT(87, png_voidp, png_get_user_transform_ptr,
|
||||
* row number is still the row in the final, de-interlaced, image but the row
|
||||
* only contains the data of the current pass - consult png_row_info for the
|
||||
* actual width of the row!
|
||||
*
|
||||
* In contrast the row numbers passed to the progressive reader and sequential
|
||||
* reader callbacks are actually the rows in the input data - so the row in the
|
||||
* interlaced pass for an interlaced image.
|
||||
*/
|
||||
PNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structp));
|
||||
PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structp));
|
||||
|
13
pngtrans.c
13
pngtrans.c
@ -703,11 +703,21 @@ png_get_user_transform_ptr(png_const_structp png_ptr)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_current_row_number(png_const_structp png_ptr)
|
||||
{
|
||||
/* This API returns the row in output, not the input row: */
|
||||
if (png_ptr != NULL)
|
||||
return png_ptr->row_number;
|
||||
{
|
||||
if (png_ptr->interlaced == PNG_INTERLACE_NONE)
|
||||
return png_ptr->row_number;
|
||||
else if (png_ptr->interlaced == PNG_INTERLACE_ADAM7)
|
||||
return PNG_ROW_FROM_PASS_ROW(png_ptr->row_number, png_ptr->pass);
|
||||
|
||||
/* Else something bad is happening: */
|
||||
}
|
||||
|
||||
return PNG_UINT_32_MAX; /* help the app not to fail silently */
|
||||
}
|
||||
|
||||
@ -718,6 +728,7 @@ png_get_current_pass_number(png_const_structp png_ptr)
|
||||
return png_ptr->pass;
|
||||
return 8; /* invalid */
|
||||
}
|
||||
#endif /* PNG_USER_TRANSFORM_INFO_SUPPORTED */
|
||||
#endif /* PNG_READ_USER_TRANSFORM_SUPPORTED ||
|
||||
PNG_WRITE_USER_TRANSFORM_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
|
@ -3072,7 +3072,13 @@ progressive_row(png_structp pp, png_bytep new_row, png_uint_32 y, int pass)
|
||||
* us the y in the sub-image:
|
||||
*/
|
||||
if (dp->do_interlace && dp->interlace_type == PNG_INTERLACE_ADAM7)
|
||||
{
|
||||
if (pass != png_get_current_pass_number(pp))
|
||||
png_error(pp, "png_get_current_pass_number is broken");
|
||||
y = PNG_ROW_FROM_PASS_ROW(y, pass);
|
||||
if (y != png_get_current_row_number(pp))
|
||||
png_error(pp, "png_get_current_row_number is broken");
|
||||
}
|
||||
|
||||
/* Validate this just in case. */
|
||||
if (y >= dp->h)
|
||||
|
@ -148,6 +148,7 @@
|
||||
#define PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
#define PNG_sCAL_SUPPORTED
|
||||
#define PNG_WRITE_zTXt_SUPPORTED
|
||||
#define PNG_USER_TRANSFORM_INFO_SUPPORTED
|
||||
#define PNG_sBIT_SUPPORTED
|
||||
#define PNG_cHRM_SUPPORTED
|
||||
#define PNG_bKGD_SUPPORTED
|
||||
@ -155,7 +156,6 @@
|
||||
#define PNG_WRITE_iTXt_SUPPORTED
|
||||
#define PNG_oFFs_SUPPORTED
|
||||
#define PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||
#define PNG_USER_TRANSFORM_INFO_SUPPORTED
|
||||
#define PNG_hIST_SUPPORTED
|
||||
#define PNG_iCCP_SUPPORTED
|
||||
#define PNG_sRGB_SUPPORTED
|
||||
|
Loading…
Reference in New Issue
Block a user