[libpng15] Reverted patches committed to the wrong branch.

This commit is contained in:
Glenn Randers-Pehrson
2013-05-07 14:29:36 -05:00
parent 6ab1f4903f
commit 2defb206e7
4 changed files with 1503 additions and 2424 deletions

View File

@@ -18,7 +18,6 @@
#include <mem.h>
#include <fcntl.h>
#endif
#include <zlib.h>
#ifndef BOOL
#define BOOL unsigned char
@@ -198,9 +197,6 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
char height_token[16];
char maxval_token[16];
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 height, alpha_height;
png_uint_32 maxval;
@@ -231,15 +227,11 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
raw = (type_token[1] == '5');
color_type = PNG_COLOR_TYPE_GRAY;
get_token(pnm_file, width_token);
sscanf (width_token, "%lu", &ul_width);
width = (png_uint_32) ul_width;
sscanf (width_token, "%lu", &width);
get_token(pnm_file, height_token);
sscanf (height_token, "%lu", &ul_height);
height = (png_uint_32) ul_height;
sscanf (height_token, "%lu", &height);
get_token(pnm_file, maxval_token);
sscanf (maxval_token, "%lu", &ul_maxval);
maxval = (png_uint_32) ul_maxval;
sscanf (maxval_token, "%lu", &maxval);
if (maxval <= 1)
bit_depth = 1;
else if (maxval <= 3)
@@ -256,14 +248,11 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
raw = (type_token[1] == '6');
color_type = PNG_COLOR_TYPE_RGB;
get_token(pnm_file, width_token);
sscanf (width_token, "%lu", &ul_width);
width = (png_uint_32) ul_width;
sscanf (width_token, "%lu", &width);
get_token(pnm_file, height_token);
sscanf (height_token, "%lu", &ul_height);
height = (png_uint_32) ul_height;
sscanf (height_token, "%lu", &height);
get_token(pnm_file, maxval_token);
sscanf (maxval_token, "%lu", &ul_maxval);
maxval = (png_uint_32) ul_maxval;
sscanf (maxval_token, "%lu", &maxval);
if (maxval <= 1)
bit_depth = 1;
else if (maxval <= 3)
@@ -298,18 +287,15 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
{
alpha_raw = (type_token[1] == '5');
get_token(alpha_file, width_token);
sscanf (width_token, "%lu", &ul_alpha_width);
alpha_width=(png_uint_32) ul_alpha_width;
sscanf (width_token, "%lu", &alpha_width);
if (alpha_width != width)
return FALSE;
get_token(alpha_file, height_token);
sscanf (height_token, "%lu", &ul_alpha_height);
alpha_height = (png_uint_32) ul_alpha_height;
sscanf (height_token, "%lu", &alpha_height);
if (alpha_height != height)
return FALSE;
get_token(alpha_file, maxval_token);
sscanf (maxval_token, "%lu", &ul_maxval);
maxval = (png_uint_32) ul_maxval;
sscanf (maxval_token, "%lu", &maxval);
if (maxval <= 1)
alpha_depth = 1;
else if (maxval <= 3)
@@ -460,32 +446,19 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
void get_token(FILE *pnm_file, char *token)
{
int i = 0;
int ret;
/* remove white-space and comment lines */
/* remove white-space */
do
{
ret = fgetc(pnm_file);
if (ret == '#') {
/* the rest of this line is a comment */
do
{
ret = fgetc(pnm_file);
}
while ((ret != '\n') && (ret != '\r') && (ret != EOF));
}
if (ret == EOF) break;
token[i] = (unsigned char) ret;
token[i] = (unsigned char) fgetc (pnm_file);
}
while ((token[i] == '\n') || (token[i] == '\r') || (token[i] == ' '));
/* read string */
do
{
ret = fgetc(pnm_file);
if (ret == EOF) break;
i++;
token[i] = (unsigned char) ret;
token[i] = (unsigned char) fgetc (pnm_file);
}
while ((token[i] != '\n') && (token[i] != '\r') && (token[i] != ' '));
@@ -537,7 +510,6 @@ png_uint_32 get_value (FILE *pnm_file, int depth)
{
static png_uint_32 mask = 0;
png_byte token[16];
unsigned long ul_ret_value;
png_uint_32 ret_value;
int i = 0;
@@ -546,8 +518,7 @@ png_uint_32 get_value (FILE *pnm_file, int depth)
mask = (mask << 1) | 0x01;
get_token (pnm_file, (char *) token);
sscanf ((const char *) token, "%lu", &ul_ret_value);
ret_value = (png_uint_32) ul_ret_value;
sscanf ((const char *) token, "%lu", &ret_value);
ret_value &= mask;