[libpng14] Fixed png_save_int_32 when int is not 2's complement (John Bowler).

This commit is contained in:
John Bowler 2015-08-21 14:56:49 -05:00 committed by Glenn Randers-Pehrson
parent 627c2c8797
commit 72ee0aef48
3 changed files with 15 additions and 10 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.4.17beta02 - August 19, 2015
Libpng 1.4.17beta02 - August 21, 2015
This is not intended to be a public release. It will be replaced
within a few weeks by a public version or by another test version.
@ -49,7 +49,8 @@ version 1.4.17beta01 [August 19, 2015]
in ANSI-C (unlike 0x80000000 in the signed case) the checking that
occurs later can catch them (John Bowler).
version 1.4.17beta02 [August 19, 2015]
version 1.4.17beta02 [August 21, 2015]
Fixed png_save_int_32 when int is not 2's complement (John Bowler).
Send comments/corrections/commendations to glennrp at users.sourceforge.net
or to png-mng-implement at lists.sf.net (subscription required; visit

View File

@ -2979,7 +2979,8 @@ version 1.4.17beta01 [August 19, 2015]
in ANSI-C (unlike 0x80000000 in the signed case) the checking that
occurs later can catch them (John Bowler).
version 1.4.17beta02 [August 19, 2015]
version 1.4.17beta02 [August 21, 2015]
Fixed png_save_int_32 when int is not 2's complement (John Bowler).
Send comments/corrections/commendations to glennrp at users.sourceforge.net
or to png-mng-implement at lists.sf.net (subscription required; visit

View File

@ -30,17 +30,20 @@ png_save_uint_32(png_bytep buf, png_uint_32 i)
}
#ifdef PNG_SAVE_INT_32_SUPPORTED
/* The png_save_int_32 function assumes integers are stored in two's
* complement format. If this isn't the case, then this routine needs to
* be modified to write data in two's complement format.
/* PNG signed integers are saved in 32-bit 2's complement format. ANSI C-90
* defines a cast of a signed integer to an unsigned integer either to preserve
* the value, if it is positive, or to calculate:
*
* (UNSIGNED_MAX+1) + integer
*
* Where UNSIGNED_MAX is the appropriate maximum unsigned value, so when the
* negative integral value is added the result will be an unsigned value
* correspnding to the 2's complement representation.
*/
void PNGAPI
png_save_int_32(png_bytep buf, png_int_32 i)
{
buf[0] = (png_byte)((i >> 24) & 0xff);
buf[1] = (png_byte)((i >> 16) & 0xff);
buf[2] = (png_byte)((i >> 8) & 0xff);
buf[3] = (png_byte)(i & 0xff);
png_save_uint_32(buf, i);
}
#endif