mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng17] Updated contrib/pngminus/pnm2png.c (Paul Stewart):
Fixed whitespace handling Added a call to png_set_packing() Initialize dimension values so if sscanf fails at least we have known invalid values.
This commit is contained in:
parent
cb10e19725
commit
0cc23ac171
9
ANNOUNCE
9
ANNOUNCE
@ -276,10 +276,15 @@ Version 1.7.0beta12 [April 30, 2013]
|
|||||||
png_create_write_struct() (Andrew Church).
|
png_create_write_struct() (Andrew Church).
|
||||||
|
|
||||||
Version 1.7.0beta13 [May 10, 2013]
|
Version 1.7.0beta13 [May 10, 2013]
|
||||||
Check for EOF in contrib/pngminus/pnm2png.c (Paul Stewart).
|
|
||||||
Ignore "#" delimited comments in input file to pnm2png.c.
|
|
||||||
Revised contrib/pngminim/*/makefile to generate pnglibconf.h with the
|
Revised contrib/pngminim/*/makefile to generate pnglibconf.h with the
|
||||||
right zlib header files.
|
right zlib header files.
|
||||||
|
Updated contrib/pngminus/pnm2png.c (Paul Stewart):
|
||||||
|
Check for EOF
|
||||||
|
Ignore "#" delimited comments in input file to pnm2png.c.
|
||||||
|
Fixed whitespace handling
|
||||||
|
Added a call to png_set_packing()
|
||||||
|
Initialize dimension values so if sscanf fails at least we have known
|
||||||
|
invalid values.
|
||||||
|
|
||||||
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
|
||||||
|
9
CHANGES
9
CHANGES
@ -4564,10 +4564,15 @@ Version 1.7.0beta12 [April 30, 2013]
|
|||||||
png_create_write_struct() (Andrew Church).
|
png_create_write_struct() (Andrew Church).
|
||||||
|
|
||||||
Version 1.7.0beta13 [May 10, 2013]
|
Version 1.7.0beta13 [May 10, 2013]
|
||||||
Check for EOF in contrib/pngminus/pnm2png.c (Paul Stewart).
|
|
||||||
Ignore "#" delimited comments in input file to pnm2png.c.
|
|
||||||
Revised contrib/pngminim/*/makefile to generate pnglibconf.h with the
|
Revised contrib/pngminim/*/makefile to generate pnglibconf.h with the
|
||||||
right zlib header files.
|
right zlib header files.
|
||||||
|
Updated contrib/pngminus/pnm2png.c (Paul Stewart):
|
||||||
|
Check for EOF
|
||||||
|
Ignore "#" delimited comments in input file to pnm2png.c.
|
||||||
|
Fixed whitespace handling
|
||||||
|
Added a call to png_set_packing()
|
||||||
|
Initialize dimension values so if sscanf fails at least we have known
|
||||||
|
invalid values.
|
||||||
|
|
||||||
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
|
||||||
|
@ -198,9 +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_width=0, ul_alpha_width=0;
|
||||||
unsigned long ul_height, ul_alpha_height;
|
unsigned long ul_height=0, ul_alpha_height=0;
|
||||||
unsigned long ul_maxval;
|
unsigned long ul_maxval=0;
|
||||||
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;
|
||||||
@ -210,6 +210,9 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
|||||||
int alpha_present;
|
int alpha_present;
|
||||||
int row, col;
|
int row, col;
|
||||||
BOOL raw, alpha_raw = FALSE;
|
BOOL raw, alpha_raw = FALSE;
|
||||||
|
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||||
|
BOOL packed_bitmap = FALSE;
|
||||||
|
#endif
|
||||||
png_uint_32 tmp16;
|
png_uint_32 tmp16;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -222,9 +225,21 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
|||||||
}
|
}
|
||||||
else if ((type_token[1] == '1') || (type_token[1] == '4'))
|
else if ((type_token[1] == '1') || (type_token[1] == '4'))
|
||||||
{
|
{
|
||||||
|
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||||
raw = (type_token[1] == '4');
|
raw = (type_token[1] == '4');
|
||||||
color_type = PNG_COLOR_TYPE_GRAY;
|
color_type = PNG_COLOR_TYPE_GRAY;
|
||||||
|
get_token(pnm_file, width_token);
|
||||||
|
sscanf (width_token, "%lu", &ul_width);
|
||||||
|
width = (png_uint_32) ul_width;
|
||||||
|
get_token(pnm_file, height_token);
|
||||||
|
sscanf (height_token, "%lu", &ul_height);
|
||||||
|
height = (png_uint_32) ul_height;
|
||||||
bit_depth = 1;
|
bit_depth = 1;
|
||||||
|
packed_bitmap = TRUE;
|
||||||
|
#else
|
||||||
|
fprintf (stderr, "PNM2PNG built without PNG_WRITE_INVERT_SUPPORTED and \n");
|
||||||
|
fprintf (stderr, "PNG_WRITE_PACK_SUPPORTED can't read PBM (P1,P4) files\n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else if ((type_token[1] == '2') || (type_token[1] == '5'))
|
else if ((type_token[1] == '2') || (type_token[1] == '5'))
|
||||||
{
|
{
|
||||||
@ -343,6 +358,12 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
|||||||
|
|
||||||
alpha_present = (channels - 1) % 2;
|
alpha_present = (channels - 1) % 2;
|
||||||
|
|
||||||
|
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||||
|
if (packed_bitmap)
|
||||||
|
/* row data is as many bytes as can fit width x channels x bit_depth */
|
||||||
|
row_bytes = (width * channels * bit_depth + 7) / 8;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
/* row_bytes is the width x number of channels x (bit-depth / 8) */
|
/* row_bytes is the width x number of channels x (bit-depth / 8) */
|
||||||
row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2);
|
row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2);
|
||||||
|
|
||||||
@ -353,6 +374,14 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
|||||||
pix_ptr = png_pixels;
|
pix_ptr = png_pixels;
|
||||||
|
|
||||||
for (row = 0; row < height; row++)
|
for (row = 0; row < height; row++)
|
||||||
|
{
|
||||||
|
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||||
|
if (packed_bitmap) {
|
||||||
|
for (i = 0; i < row_bytes; i++)
|
||||||
|
/* png supports this format natively so no conversion is needed */
|
||||||
|
*pix_ptr++ = get_data (pnm_file, 8);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
for (col = 0; col < width; col++)
|
for (col = 0; col < width; col++)
|
||||||
{
|
{
|
||||||
@ -387,7 +416,7 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
|||||||
*pix_ptr++ = (png_byte) (tmp16 & 0xFF);
|
*pix_ptr++ = (png_byte) (tmp16 & 0xFF);
|
||||||
}
|
}
|
||||||
} /* if alpha */
|
} /* if alpha */
|
||||||
|
} /* if packed_bitmap */
|
||||||
} /* end for col */
|
} /* end for col */
|
||||||
} /* end for row */
|
} /* end for row */
|
||||||
|
|
||||||
@ -404,6 +433,14 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||||
|
if (packed_bitmap == TRUE)
|
||||||
|
{
|
||||||
|
png_set_packing (png_ptr);
|
||||||
|
png_set_invert_mono (png_ptr);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* setjmp() must be called in every function that calls a PNG-reading libpng function */
|
/* setjmp() must be called in every function that calls a PNG-reading libpng function */
|
||||||
if (setjmp (png_jmpbuf(png_ptr)))
|
if (setjmp (png_jmpbuf(png_ptr)))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user