mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng16] Revised contrib/pngminus/pnm2png.c to avoid warnings
when png_uint_32 and unsigned long are of different sizes.
This commit is contained in:
parent
0522f269e0
commit
04ab33560f
13
ANNOUNCE
13
ANNOUNCE
@ -95,11 +95,14 @@ Version 1.6.0beta04 [December 29, 2011]
|
|||||||
location in configure.ac (Gilles Espinasse).
|
location in configure.ac (Gilles Espinasse).
|
||||||
Changed png_memcpy to C assignment where appropriate. Changed all those
|
Changed png_memcpy to C assignment where appropriate. Changed all those
|
||||||
uses of png_memcpy that were doing a simple assignment to assignments
|
uses of png_memcpy that were doing a simple assignment to assignments
|
||||||
(all those cases where the thing being copied is a non-array C L-value.)
|
(all those cases where the thing being copied is a non-array C L-value).
|
||||||
Added some error checking to png_set_*() routines and removed the
|
Added some error checking to png_set_*() routines.
|
||||||
reference to the non-exported function png_memcpy() from example.c. Fixed
|
Removed the reference to the non-exported function png_memcpy() from
|
||||||
the Visual C 64-bit build - it requires jmp_buf to be aligned, but it had
|
example.c.
|
||||||
become misaligned.
|
Fixed the Visual C 64-bit build - it requires jmp_buf to be aligned, but
|
||||||
|
it had become misaligned.
|
||||||
|
Revised contrib/pngminus/pnm2png.c to avoid warnings when png_uint_32
|
||||||
|
and unsigned long are of different sizes.
|
||||||
|
|
||||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||||
(subscription required; visit
|
(subscription required; visit
|
||||||
|
13
CHANGES
13
CHANGES
@ -3846,11 +3846,14 @@ Version 1.6.0beta04 [December 29, 2011]
|
|||||||
location in configure.ac (Gilles Espinasse).
|
location in configure.ac (Gilles Espinasse).
|
||||||
Changed png_memcpy to C assignment where appropriate. Changed all those
|
Changed png_memcpy to C assignment where appropriate. Changed all those
|
||||||
uses of png_memcpy that were doing a simple assignment to assignments
|
uses of png_memcpy that were doing a simple assignment to assignments
|
||||||
(all those cases where the thing being copied is a non-array C L-value.)
|
(all those cases where the thing being copied is a non-array C L-value).
|
||||||
Added some error checking to png_set_*() routines and removed the
|
Added some error checking to png_set_*() routines.
|
||||||
reference to the non-exported function png_memcpy() from example.c. Fixed
|
Removed the reference to the non-exported function png_memcpy() from
|
||||||
the Visual C 64-bit build - it requires jmp_buf to be aligned, but it had
|
example.c.
|
||||||
become misaligned.
|
Fixed the Visual C 64-bit build - it requires jmp_buf to be aligned, but
|
||||||
|
it had become misaligned.
|
||||||
|
Revised contrib/pngminus/pnm2png.c to avoid warnings when png_uint_32
|
||||||
|
and unsigned long are of different sizes.
|
||||||
|
|
||||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||||
(subscription required; visit
|
(subscription required; visit
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <mem.h>
|
#include <mem.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <zlib.h>
|
||||||
|
|
||||||
#ifndef BOOL
|
#ifndef BOOL
|
||||||
#define BOOL unsigned char
|
#define BOOL unsigned char
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <mem.h>
|
#include <mem.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <zlib.h>
|
||||||
|
|
||||||
#ifndef BOOL
|
#ifndef BOOL
|
||||||
#define BOOL unsigned char
|
#define BOOL unsigned char
|
||||||
@ -197,6 +198,9 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
|||||||
char height_token[16];
|
char height_token[16];
|
||||||
char maxval_token[16];
|
char maxval_token[16];
|
||||||
int color_type;
|
int color_type;
|
||||||
|
unsigned long ul_width, ul_alpha_width;
|
||||||
|
unsigned long ul_height, ul_alpha_height;
|
||||||
|
unsigned long ul_maxval;
|
||||||
png_uint_32 width, alpha_width;
|
png_uint_32 width, alpha_width;
|
||||||
png_uint_32 height, alpha_height;
|
png_uint_32 height, alpha_height;
|
||||||
png_uint_32 maxval;
|
png_uint_32 maxval;
|
||||||
@ -227,11 +231,15 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
|||||||
raw = (type_token[1] == '5');
|
raw = (type_token[1] == '5');
|
||||||
color_type = PNG_COLOR_TYPE_GRAY;
|
color_type = PNG_COLOR_TYPE_GRAY;
|
||||||
get_token(pnm_file, width_token);
|
get_token(pnm_file, width_token);
|
||||||
sscanf (width_token, "%lu", &width);
|
sscanf (width_token, "%lu", &ul_width);
|
||||||
|
width = (png_uint_32) ul_width;
|
||||||
get_token(pnm_file, height_token);
|
get_token(pnm_file, height_token);
|
||||||
sscanf (height_token, "%lu", &height);
|
sscanf (height_token, "%lu", &ul_height);
|
||||||
|
height = (png_uint_32) ul_height;
|
||||||
get_token(pnm_file, maxval_token);
|
get_token(pnm_file, maxval_token);
|
||||||
sscanf (maxval_token, "%lu", &maxval);
|
sscanf (maxval_token, "%lu", &ul_maxval);
|
||||||
|
maxval = (png_uint_32) ul_maxval;
|
||||||
|
|
||||||
if (maxval <= 1)
|
if (maxval <= 1)
|
||||||
bit_depth = 1;
|
bit_depth = 1;
|
||||||
else if (maxval <= 3)
|
else if (maxval <= 3)
|
||||||
@ -248,11 +256,14 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
|||||||
raw = (type_token[1] == '6');
|
raw = (type_token[1] == '6');
|
||||||
color_type = PNG_COLOR_TYPE_RGB;
|
color_type = PNG_COLOR_TYPE_RGB;
|
||||||
get_token(pnm_file, width_token);
|
get_token(pnm_file, width_token);
|
||||||
sscanf (width_token, "%lu", &width);
|
sscanf (width_token, "%lu", &ul_width);
|
||||||
|
width = (png_uint_32) ul_width;
|
||||||
get_token(pnm_file, height_token);
|
get_token(pnm_file, height_token);
|
||||||
sscanf (height_token, "%lu", &height);
|
sscanf (height_token, "%lu", &ul_height);
|
||||||
|
height = (png_uint_32) ul_height;
|
||||||
get_token(pnm_file, maxval_token);
|
get_token(pnm_file, maxval_token);
|
||||||
sscanf (maxval_token, "%lu", &maxval);
|
sscanf (maxval_token, "%lu", &ul_maxval);
|
||||||
|
maxval = (png_uint_32) ul_maxval;
|
||||||
if (maxval <= 1)
|
if (maxval <= 1)
|
||||||
bit_depth = 1;
|
bit_depth = 1;
|
||||||
else if (maxval <= 3)
|
else if (maxval <= 3)
|
||||||
@ -287,15 +298,18 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
|||||||
{
|
{
|
||||||
alpha_raw = (type_token[1] == '5');
|
alpha_raw = (type_token[1] == '5');
|
||||||
get_token(alpha_file, width_token);
|
get_token(alpha_file, width_token);
|
||||||
sscanf (width_token, "%lu", &alpha_width);
|
sscanf (width_token, "%lu", &ul_alpha_width);
|
||||||
|
alpha_width=(png_uint_32) ul_alpha_width;
|
||||||
if (alpha_width != width)
|
if (alpha_width != width)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
get_token(alpha_file, height_token);
|
get_token(alpha_file, height_token);
|
||||||
sscanf (height_token, "%lu", &alpha_height);
|
sscanf (height_token, "%lu", &ul_alpha_height);
|
||||||
|
alpha_height = (png_uint_32) ul_alpha_height;
|
||||||
if (alpha_height != height)
|
if (alpha_height != height)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
get_token(alpha_file, maxval_token);
|
get_token(alpha_file, maxval_token);
|
||||||
sscanf (maxval_token, "%lu", &maxval);
|
sscanf (maxval_token, "%lu", &ul_maxval);
|
||||||
|
maxval = (png_uint_32) ul_maxval;
|
||||||
if (maxval <= 1)
|
if (maxval <= 1)
|
||||||
alpha_depth = 1;
|
alpha_depth = 1;
|
||||||
else if (maxval <= 3)
|
else if (maxval <= 3)
|
||||||
@ -510,6 +524,7 @@ png_uint_32 get_value (FILE *pnm_file, int depth)
|
|||||||
{
|
{
|
||||||
static png_uint_32 mask = 0;
|
static png_uint_32 mask = 0;
|
||||||
png_byte token[16];
|
png_byte token[16];
|
||||||
|
unsigned long ulret_value;
|
||||||
png_uint_32 ret_value;
|
png_uint_32 ret_value;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
@ -518,7 +533,8 @@ png_uint_32 get_value (FILE *pnm_file, int depth)
|
|||||||
mask = (mask << 1) | 0x01;
|
mask = (mask << 1) | 0x01;
|
||||||
|
|
||||||
get_token (pnm_file, (char *) token);
|
get_token (pnm_file, (char *) token);
|
||||||
sscanf ((const char *) token, "%lu", &ret_value);
|
sscanf ((const char *) token, "%lu", &ulret_value);
|
||||||
|
ret_value = (png_uint_32) ulret_value;
|
||||||
|
|
||||||
ret_value &= mask;
|
ret_value &= mask;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user