mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng15] Merge with libpng16/pngminus
This commit is contained in:
parent
5a945f3393
commit
6b7c27341e
3
ANNOUNCE
3
ANNOUNCE
@ -27,7 +27,8 @@ Other information:
|
|||||||
Changes since the last public release (1.5.27):
|
Changes since the last public release (1.5.27):
|
||||||
|
|
||||||
version 1.5.28beta01 [October 30, 2016]
|
version 1.5.28beta01 [October 30, 2016]
|
||||||
Merge with current libpng16 gregbook, pngvalid.c, pngtest.c
|
Merged with current libpng16 gregbook, pngvalid.c, pngtest.c, pngminim,
|
||||||
|
pngminus
|
||||||
Fixed undefined behavior in png_push_save_buffer(). Do not call
|
Fixed undefined behavior in png_push_save_buffer(). Do not call
|
||||||
memcpy() with a null source, even if count is zero (Leon Scroggins III).
|
memcpy() with a null source, even if count is zero (Leon Scroggins III).
|
||||||
Added "Common linking failures" section to INSTALL.
|
Added "Common linking failures" section to INSTALL.
|
||||||
|
|||||||
3
CHANGES
3
CHANGES
@ -4497,7 +4497,8 @@ version 1.5.27 [May 26, 2016]
|
|||||||
No changes.
|
No changes.
|
||||||
|
|
||||||
version 1.5.28beta01 [October 30, 2016]
|
version 1.5.28beta01 [October 30, 2016]
|
||||||
Merge with current libpng16 gregbook, pngvalid.c, pngtest.c
|
Merged with current libpng16 gregbook, pngvalid.c, pngtest.c, pngminim,
|
||||||
|
pngminus
|
||||||
Fixed undefined behavior in png_push_save_buffer(). Do not call
|
Fixed undefined behavior in png_push_save_buffer(). Do not call
|
||||||
memcpy() with a null source, even if count is zero (Leon Scroggins III).
|
memcpy() with a null source, even if count is zero (Leon Scroggins III).
|
||||||
Added "Common linking failures" section to INSTALL.
|
Added "Common linking failures" section to INSTALL.
|
||||||
|
|||||||
@ -146,7 +146,7 @@ The Turbo bug
|
|||||||
The end
|
The end
|
||||||
-------
|
-------
|
||||||
Willem van Schaik
|
Willem van Schaik
|
||||||
mailto:willem@schaik.com
|
mailto:willem at schaik.com
|
||||||
http://www.schaik.com/png/
|
http://www.schaik.com/png/
|
||||||
-------
|
-------
|
||||||
Oct 1999
|
Oct 1999
|
||||||
|
|||||||
@ -23,7 +23,8 @@ ZINC = -I../../../zlib
|
|||||||
ZLIB = -L../../../zlib -lz
|
ZLIB = -L../../../zlib -lz
|
||||||
ZLIBS = ../../../zlib/libz.a
|
ZLIBS = ../../../zlib/libz.a
|
||||||
|
|
||||||
CFLAGS=$(PNGINC) $(ZINC)
|
CPPFLAGS=$(PNGINC) $(ZINC)
|
||||||
|
CFLAGS=
|
||||||
LDLIBS=$(PNGLIB) $(ZLIB)
|
LDLIBS=$(PNGLIB) $(ZLIB)
|
||||||
LDLIBSS=$(PNGLIBS) $(ZLIBS)
|
LDLIBSS=$(PNGLIBS) $(ZLIBS)
|
||||||
C=.c
|
C=.c
|
||||||
@ -37,7 +38,7 @@ E=
|
|||||||
all: png2pnm$(E) pnm2png$(E) png2pnm-static$(E) pnm2png-static$(E)
|
all: png2pnm$(E) pnm2png$(E) png2pnm-static$(E) pnm2png-static$(E)
|
||||||
|
|
||||||
png2pnm$(O): png2pnm$(C)
|
png2pnm$(O): png2pnm$(C)
|
||||||
$(CC) -c $(CFLAGS) png2pnm$(C)
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) png2pnm$(C)
|
||||||
|
|
||||||
png2pnm$(E): png2pnm$(O)
|
png2pnm$(E): png2pnm$(O)
|
||||||
$(LD) $(LDFLAGS) -o png2pnm$(E) png2pnm$(O) $(LDLIBS) -lm
|
$(LD) $(LDFLAGS) -o png2pnm$(E) png2pnm$(O) $(LDLIBS) -lm
|
||||||
@ -46,7 +47,7 @@ png2pnm-static$(E): png2pnm$(O)
|
|||||||
$(LD) $(LDFLAGS) -o png2pnm-static$(E) png2pnm$(O) $(LDLIBSS) -lm
|
$(LD) $(LDFLAGS) -o png2pnm-static$(E) png2pnm$(O) $(LDLIBSS) -lm
|
||||||
|
|
||||||
pnm2png$(O): pnm2png$(C)
|
pnm2png$(O): pnm2png$(C)
|
||||||
$(CC) -c $(CFLAGS) pnm2png$(C)
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) pnm2png$(C)
|
||||||
|
|
||||||
pnm2png$(E): pnm2png$(O)
|
pnm2png$(E): pnm2png$(O)
|
||||||
$(LD) $(LDFLAGS) -o pnm2png$(E) pnm2png$(O) $(LDLIBS) -lm
|
$(LD) $(LDFLAGS) -o pnm2png$(E) pnm2png$(O) $(LDLIBS) -lm
|
||||||
|
|||||||
@ -7,7 +7,8 @@ LB=tlib
|
|||||||
RM=del
|
RM=del
|
||||||
CP=copy
|
CP=copy
|
||||||
MODEL=l
|
MODEL=l
|
||||||
CCFLAGS=-O -m$(MODEL) -I..\libpng -I..\zlib
|
CPPFLAGS=-I..\libpng -I..\zlib
|
||||||
|
CFLAGS=-O -m$(MODEL)
|
||||||
LDFLAGS=-m$(MODEL) -L..\libpng -L..\zlib
|
LDFLAGS=-m$(MODEL) -L..\libpng -L..\zlib
|
||||||
C=.c
|
C=.c
|
||||||
O=.obj
|
O=.obj
|
||||||
@ -19,13 +20,13 @@ E=.exe
|
|||||||
all: png2pnm$(E) pnm2png$(E)
|
all: png2pnm$(E) pnm2png$(E)
|
||||||
|
|
||||||
png2pnm$(O): png2pnm$(C)
|
png2pnm$(O): png2pnm$(C)
|
||||||
$(CC) -c $(CCFLAGS) png2pnm$(C)
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) png2pnm$(C)
|
||||||
|
|
||||||
png2pnm$(E): png2pnm$(O)
|
png2pnm$(E): png2pnm$(O)
|
||||||
$(LD) $(LDFLAGS) png2pnm$(O) libpng$(L) zlib$(L)
|
$(LD) $(LDFLAGS) png2pnm$(O) libpng$(L) zlib$(L)
|
||||||
|
|
||||||
pnm2png$(O): pnm2png$(C)
|
pnm2png$(O): pnm2png$(C)
|
||||||
$(CC) -c $(CCFLAGS) pnm2png$(C)
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) pnm2png$(C)
|
||||||
|
|
||||||
pnm2png$(E): pnm2png$(O)
|
pnm2png$(E): pnm2png$(O)
|
||||||
$(LD) $(LDFLAGS) pnm2png$(O) libpng$(L) zlib$(L)
|
$(LD) $(LDFLAGS) pnm2png$(O) libpng$(L) zlib$(L)
|
||||||
@ -35,4 +36,3 @@ clean:
|
|||||||
$(RM) *$(E)
|
$(RM) *$(E)
|
||||||
|
|
||||||
# End of makefile for png2pnm / pnm2png
|
# End of makefile for png2pnm / pnm2png
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* png2pnm.c --- conversion from PNG-file to PGM/PPM-file
|
* png2pnm.c --- conversion from PNG-file to PGM/PPM-file
|
||||||
* copyright (C) 1999 by Willem van Schaik <willem@schaik.com>
|
* copyright (C) 1999 by Willem van Schaik <willem at schaik.com>
|
||||||
*
|
*
|
||||||
* version 1.0 - 1999.10.15 - First version.
|
* version 1.0 - 1999.10.15 - First version.
|
||||||
*
|
*
|
||||||
@ -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
|
||||||
@ -51,7 +52,8 @@
|
|||||||
|
|
||||||
int main (int argc, char *argv[]);
|
int main (int argc, char *argv[]);
|
||||||
void usage ();
|
void usage ();
|
||||||
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha);
|
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw,
|
||||||
|
BOOL alpha);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* main
|
* main
|
||||||
@ -84,7 +86,8 @@ int main(int argc, char *argv[])
|
|||||||
if ((fp_al = fopen (argv[argi], "wb")) == NULL)
|
if ((fp_al = fopen (argv[argi], "wb")) == NULL)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "PNM2PNG\n");
|
fprintf (stderr, "PNM2PNG\n");
|
||||||
fprintf (stderr, "Error: can not create alpha-channel file %s\n", argv[argi]);
|
fprintf (stderr, "Error: can not create alpha-channel file %s\n",
|
||||||
|
argv[argi]);
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -175,9 +178,11 @@ void usage()
|
|||||||
fprintf (stderr, "Usage: png2pnm [options] <file>.png [<file>.pnm]\n");
|
fprintf (stderr, "Usage: png2pnm [options] <file>.png [<file>.pnm]\n");
|
||||||
fprintf (stderr, " or: ... | png2pnm [options]\n");
|
fprintf (stderr, " or: ... | png2pnm [options]\n");
|
||||||
fprintf (stderr, "Options:\n");
|
fprintf (stderr, "Options:\n");
|
||||||
fprintf (stderr, " -r[aw] write pnm-file in binary format (P4/P5/P6) (default)\n");
|
fprintf (stderr,
|
||||||
|
" -r[aw] write pnm-file in binary format (P4/P5/P6) (default)\n");
|
||||||
fprintf (stderr, " -n[oraw] write pnm-file in ascii format (P1/P2/P3)\n");
|
fprintf (stderr, " -n[oraw] write pnm-file in ascii format (P1/P2/P3)\n");
|
||||||
fprintf (stderr, " -a[lpha] <file>.pgm write PNG alpha channel as pgm-file\n");
|
fprintf (stderr,
|
||||||
|
" -a[lpha] <file>.pgm write PNG alpha channel as pgm-file\n");
|
||||||
fprintf (stderr, " -h | -? print this help-information\n");
|
fprintf (stderr, " -h | -? print this help-information\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,7 +190,8 @@ void usage()
|
|||||||
* png2pnm
|
* png2pnm
|
||||||
*/
|
*/
|
||||||
|
|
||||||
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha)
|
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
|
||||||
|
volatile BOOL raw, BOOL alpha)
|
||||||
{
|
{
|
||||||
png_struct *png_ptr = NULL;
|
png_struct *png_ptr = NULL;
|
||||||
png_info *info_ptr = NULL;
|
png_info *info_ptr = NULL;
|
||||||
@ -217,7 +223,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
|
|||||||
|
|
||||||
/* create png and info structures */
|
/* create png and info structures */
|
||||||
|
|
||||||
png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING,
|
png_ptr = png_create_read_struct (png_get_libpng_ver(NULL),
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
if (!png_ptr)
|
if (!png_ptr)
|
||||||
return FALSE; /* out of memory */
|
return FALSE; /* out of memory */
|
||||||
@ -260,7 +266,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
|
|||||||
png_set_expand (png_ptr);
|
png_set_expand (png_ptr);
|
||||||
|
|
||||||
#ifdef NJET
|
#ifdef NJET
|
||||||
/* downgrade 16-bit images to 8 bit */
|
/* downgrade 16-bit images to 8-bit */
|
||||||
if (bit_depth == 16)
|
if (bit_depth == 16)
|
||||||
png_set_strip_16 (png_ptr);
|
png_set_strip_16 (png_ptr);
|
||||||
/* transform grayscale images into full-color */
|
/* transform grayscale images into full-color */
|
||||||
@ -314,12 +320,14 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
|
|||||||
/* 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 = png_get_rowbytes (png_ptr, info_ptr);
|
row_bytes = png_get_rowbytes (png_ptr, info_ptr);
|
||||||
|
|
||||||
if ((png_pixels = (png_byte *) malloc (row_bytes * height * sizeof (png_byte))) == NULL) {
|
if ((png_pixels = (png_byte *)
|
||||||
|
malloc (row_bytes * height * sizeof (png_byte))) == NULL) {
|
||||||
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL)
|
if ((row_pointers = (png_byte **)
|
||||||
|
malloc (height * sizeof (png_bytep))) == NULL)
|
||||||
{
|
{
|
||||||
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||||
free (png_pixels);
|
free (png_pixels);
|
||||||
@ -328,7 +336,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* set the individual row_pointers to point at the correct offsets */
|
/* set the individual row_pointers to point at the correct offsets */
|
||||||
for (i = 0; i < (height); i++)
|
for (i = 0; i < ((int) height); i++)
|
||||||
row_pointers[i] = png_pixels + i * row_bytes;
|
row_pointers[i] = png_pixels + i * row_bytes;
|
||||||
|
|
||||||
/* now we can go ahead and just read the whole image */
|
/* now we can go ahead and just read the whole image */
|
||||||
@ -371,9 +379,9 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
|
|||||||
/* write data to PNM file */
|
/* write data to PNM file */
|
||||||
pix_ptr = png_pixels;
|
pix_ptr = png_pixels;
|
||||||
|
|
||||||
for (row = 0; row < height; row++)
|
for (row = 0; row < (int) height; row++)
|
||||||
{
|
{
|
||||||
for (col = 0; col < width; col++)
|
for (col = 0; col < (int) width; col++)
|
||||||
{
|
{
|
||||||
for (i = 0; i < (channels - alpha_present); i++)
|
for (i = 0; i < (channels - alpha_present); i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* pnm2png.c --- conversion from PBM/PGM/PPM-file to PNG-file
|
* pnm2png.c --- conversion from PBM/PGM/PPM-file to PNG-file
|
||||||
* copyright (C) 1999 by Willem van Schaik <willem@schaik.com>
|
* copyright (C) 1999 by Willem van Schaik <willem at schaik.com>
|
||||||
*
|
*
|
||||||
* version 1.0 - 1999.10.15 - First version.
|
* version 1.0 - 1999.10.15 - First version.
|
||||||
* version 1.1 - 2015.07.29 - Fixed leaks (Glenn Randers-Pehrson)
|
* version 1.1 - 2015.07.29 - Fixed leaks (Glenn Randers-Pehrson)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user