mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng15] Fixed png_save_int_32 when int is not 2's complement (John Bowler).
This commit is contained in:
parent
7730265b27
commit
8c4b258355
5
ANNOUNCE
5
ANNOUNCE
@ -1,5 +1,5 @@
|
||||
|
||||
Libpng 1.5.24beta02 - August 19, 2015
|
||||
Libpng 1.5.24beta02 - 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.
|
||||
@ -43,7 +43,8 @@ Version 1.5.24beta01 [August 19, 2015]
|
||||
in ANSI-C (unlike 0x80000000 in the signed case) the checking that
|
||||
occurs later can catch them (John Bowler).
|
||||
|
||||
Version 1.5.24beta02 [August 19, 2015]
|
||||
Version 1.5.24beta02 [August 21, 2015]
|
||||
Fixed png_save_int_32 when int is not 2's complement (John Bowler).
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
|
||||
3
CHANGES
3
CHANGES
@ -4389,7 +4389,8 @@ Version 1.5.24beta01 [August 19, 2015]
|
||||
in ANSI-C (unlike 0x80000000 in the signed case) the checking that
|
||||
occurs later can catch them (John Bowler).
|
||||
|
||||
Version 1.5.24beta02 [August 19, 2015]
|
||||
Version 1.5.24beta02 [August 21, 2015]
|
||||
Fixed png_save_int_32 when int is not 2's complement (John Bowler).
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
|
||||
19
pngwutil.c
19
pngwutil.c
@ -30,19 +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. Note that,
|
||||
* the following works correctly even if png_int_32 has more than 32 bits
|
||||
* (compare the more complex code required on read for sign extention.)
|
||||
/* 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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user