diff options
author | Aki <please@ignore.pl> | 2022-02-09 22:23:03 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-02-09 22:53:55 +0100 |
commit | 373dc625f82b47096893add42c4472e4a57ab7eb (patch) | |
tree | 640228d02476d379de13071b13d1b1fa322b767f /libpng/contrib/pngminus | |
parent | 2d7dd844219965b81e81848e60d7f7bf23035ee4 (diff) | |
download | starshatter-373dc625f82b47096893add42c4472e4a57ab7eb.zip starshatter-373dc625f82b47096893add42c4472e4a57ab7eb.tar.gz starshatter-373dc625f82b47096893add42c4472e4a57ab7eb.tar.bz2 |
Moved third-party libraries to a separate subdirectory
Diffstat (limited to 'libpng/contrib/pngminus')
-rw-r--r-- | libpng/contrib/pngminus/README | 153 | ||||
-rw-r--r-- | libpng/contrib/pngminus/makefile.std | 65 | ||||
-rw-r--r-- | libpng/contrib/pngminus/makefile.tc3 | 38 | ||||
-rw-r--r-- | libpng/contrib/pngminus/makevms.com | 92 | ||||
-rw-r--r-- | libpng/contrib/pngminus/png2pnm.bat | 41 | ||||
-rw-r--r-- | libpng/contrib/pngminus/png2pnm.c | 430 | ||||
-rw-r--r-- | libpng/contrib/pngminus/png2pnm.sh | 42 | ||||
-rw-r--r-- | libpng/contrib/pngminus/pngminus.bat | 4 | ||||
-rw-r--r-- | libpng/contrib/pngminus/pngminus.sh | 5 | ||||
-rw-r--r-- | libpng/contrib/pngminus/pnm2png.bat | 41 | ||||
-rw-r--r-- | libpng/contrib/pngminus/pnm2png.c | 533 | ||||
-rw-r--r-- | libpng/contrib/pngminus/pnm2png.sh | 42 |
12 files changed, 0 insertions, 1486 deletions
diff --git a/libpng/contrib/pngminus/README b/libpng/contrib/pngminus/README deleted file mode 100644 index bbe7407..0000000 --- a/libpng/contrib/pngminus/README +++ /dev/null @@ -1,153 +0,0 @@ -PngMinus --------- -(copyright Willem van Schaik, 1999) - - -License -------- - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and -that both that copyright notice and this permission notice appear in -supporting documentation. This software is provided "as is" without -express or implied warranty. - - -Some history ------------- -Soon after the creation of PNG in 1995, the need was felt for a set of -pnmtopng / pngtopnm utilities. Independantly Alexander Lehmann and I -(Willem van Schaik) started such a project. Luckily we discovered this -and merged the two together into pnmtopng.tar.gz, which is available -from a/o ftp://ftp.simplesystems.org/pub/libpng/png/. - -These two utilities have many, many options and make use of most of the -features of PNG, like gamma, alpha, sbit, text-chunks, etc. This makes -the utilities quite complex and by now not anymore very maintainable. -When we wrote these programs, libpng was still in an early stage. -Therefore, lots of the functionality that we put in our software can now -be done using transform-functions in libpng. - -Finally, to compile these programs, you need to have installed and -compiled three libraries: libpng, zlib and netpbm. Especially the latter -makes the whole setup a bit bulky. But that's unavoidable given the many -features of pnmtopng. - - -What now --------- -At this moment libpng is in a very stable state and can do much of the -work done in pnmtopng. Also, pnmtopng needs to be upgraded to the new -interface of libpng. Hence, it is time for a rewrite from the ground up -of pnmtopng and pngtopnm. This will happen in the near future (stay -tuned). The new package will get a different name to distinguish it from -the old one: PngPlus. - -To experiment a bit with the new interface of libpng, I started off with -a small prototype that contains only the basic functionality. It doesn't -have any of the options to read or write special chunks and it will do -no gamma correction. But this makes it also a simple program that is -quite easy to understand and can serve well as a template for other -software developments. (By now there are of course a couple of programs, -like Greg Roelofs' rpng/wpng, that can be used just as good.) - - -Can and can not ---------------- -As this is the small brother of the future PngPlus, I called this fellow -PngMinus. Because I started this development in good-old Turbo-C, I -avoided the use the netpbm library, which requires DOS extenders. Again, -another reason to call it PngMinus (minus netpbm :-). So, part of the -program are some elementary routines to read / write pgm- and ppm-files. -It does not read b&w pbm-files. - -The downside of this approach is that you can not use them on images -that require blocks of memory bigger than 64k (the DOS version). For -larger images you will get an out-of-memory error. - -As said before, PngMinus doesn't correct for gamma. When reading -png-files you can do this just as well by piping the output of png2pnm -to pnmgamma, one of the standard PbmPlus tools. This same scenario will -most probably also be followed in the full-blown future PngPlus, with -the addition of course of the possibility to create gamma-chunks when -writing png-files. - -On the other hand it supports alpha-channels. When reading a png-image -you can write the alpha-channel into a pgm-file. And when creating an -RGB+A png-image, you just combine a ppm-file with a corresponding -pgm-file containing the alpha-channel. When reading, transparency chunks -are converted into an alpha-channel and from there on treated the same -way. - -Finally you can opt for writing ascii or binary pgm- and ppm-files. When -the bit-depth is 16, the format will always be ascii. - - -Using it --------- -To distinguish them from pnmtopng and PngPlus, the utilities are named -png2pnm and pnm2png (2 instead of to). The input- and output-files can -be given as parameters or through redirection. Therefore the programs -can be part of a pipe. - -To list the options type "png2pnm -h" or "pnm2png -h". - - -Just like Scandinavian furniture --------------------------------- -You have to put it together yourself. I did test the software under -MS-DOS with Turbo-C 3.0 and under RedHat Linux 4.2 with gcc. In both -cases I used libpng-1.0.4 and zlib-1.1.3. Later versions should be OK, -however some older libpng versions have a bug in pngmem.c when using -Turbo-C 3.0 (see below). - -You can build it using one of the two makefiles (make -f makefile.###) -or use the batch/script files pngminus.bat / pngminus.sh. This assumes -that you have built the libraries in ../libpng and ../zlib. Using Linux, -make sure that you have built libpng with makefile.std and not -makefile.linux (also called .lnx in earlier versions of libpng). The -latter creates a .so shared-library, while the PngMinus makefile assumes -a normal .a static library. - -If you create a ../pngsuite directory and then store the basn####.png -files from PngSuite (http://www.schaik.com/pngsuite/) in there, you can -test in one go the proper functioning of PngMinus, see png2pnm.bat and -pnm2png.bat (or the .sh versions). - - -Warranty -------- -Please, remember that this was just a small experiment to learn a few -things. It will have many unforeseen features <vbg>. Who said bugs? Use -it when you are in need for something simple or when you want to start -developing your own stuff. - - -The Turbo bug -------------- -** pngmem.old - hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L); - hptr += 16L; -** pngmem.c - hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L); - hptr = hptr + 16L; -** - -** pngmem.old - png_ptr->offset_table_ptr[i] = (png_bytep)hptr; - hptr += (png_uint_32)65536L; -** pngmem.c - png_ptr->offset_table_ptr[i] = (png_bytep)hptr; - hptr = hptr + 65536L; -** - - -The end -------- -Willem van Schaik -mailto:willem@schaik.com -http://www.schaik.com/png/ -------- -Oct 1999 - diff --git a/libpng/contrib/pngminus/makefile.std b/libpng/contrib/pngminus/makefile.std deleted file mode 100644 index 2fb061b..0000000 --- a/libpng/contrib/pngminus/makefile.std +++ /dev/null @@ -1,65 +0,0 @@ -# Makefile for PngMinus (png2pnm and pnm2png) -# Linux / Unix - -#CC=cc -CC=gcc -LD=$(CC) - -RM=rm -f - -#PNGPATH = /usr/local -#PNGINC = -I$(PNGPATH)/include/libpng12 -#PNGLIB = -L$(PNGPATH)/lib -lpng12 -#PNGLIBS = $(PNGPATH)/lib/libpng12.a -PNGINC = -I../.. -PNGLIB = -L../.. -lpng -PNGLIBS = ../../libpng.a - -#ZPATH = /usr/local -#ZINC = -I$(ZPATH)/include -#ZLIB = -L$(ZPATH)/lib -lz -#ZLIBS = $(ZPATH)/lib/libz.a -ZINC = -I../../../zlib -ZLIB = -L../../../zlib -lz -ZLIBS = ../../../zlib/libz.a - -CFLAGS=-O3 $(PNGINC) $(ZINC) -LDFLAGS=$(PNGLIB) $(ZLIB) -LDFLAGSS=$(PNGLIBS) $(ZLIBS) -C=.c -O=.o -L=.a -E= - -# dependencies - -#all: png2pnm$(E) pnm2png$(E) -all: png2pnm$(E) pnm2png$(E) png2pnm-static$(E) pnm2png-static$(E) - -png2pnm$(O): png2pnm$(C) - $(CC) -c $(CFLAGS) png2pnm$(C) - -png2pnm$(E): png2pnm$(O) - $(LD) -o png2pnm$(E) png2pnm$(O) $(LDFLAGS) -lm - -png2pnm-static$(E): png2pnm$(O) - $(LD) -o png2pnm-static$(E) png2pnm$(O) $(LDFLAGSS) -lm - -pnm2png$(O): pnm2png$(C) - $(CC) -c $(CFLAGS) pnm2png$(C) - -pnm2png$(E): pnm2png$(O) - $(LD) -o pnm2png$(E) pnm2png$(O) $(LDFLAGS) -lm - -pnm2png-static$(E): pnm2png$(O) - $(LD) -o pnm2png-static$(E) pnm2png$(O) $(LDFLAGSS) -lm - -clean: - $(RM) png2pnm$(O) - $(RM) pnm2png$(O) - $(RM) png2pnm$(E) - $(RM) pnm2png$(E) - $(RM) png2pnm-static$(E) - $(RM) pnm2png-static$(E) - -# End of makefile for png2pnm / pnm2png diff --git a/libpng/contrib/pngminus/makefile.tc3 b/libpng/contrib/pngminus/makefile.tc3 deleted file mode 100644 index 404f18d..0000000 --- a/libpng/contrib/pngminus/makefile.tc3 +++ /dev/null @@ -1,38 +0,0 @@ -# Makefile for PngMinus (png2pnm and pnm2png) -# TurboC++ 3.0 - -CC=tcc -Ic:\tc3\inc -LD=tcc -Lc:\tc3\lib -LB=tlib -RM=del -CP=copy -MODEL=l -CCFLAGS=-O -m$(MODEL) -I..\libpng -I..\zlib -LDFLAGS=-m$(MODEL) -L..\libpng -L..\zlib -C=.c -O=.obj -L=.lib -E=.exe - -# dependencies - -all: png2pnm$(E) pnm2png$(E) - -png2pnm$(O): png2pnm$(C) - $(CC) -c $(CCFLAGS) png2pnm$(C) - -png2pnm$(E): png2pnm$(O) - $(LD) $(LDFLAGS) png2pnm$(O) libpng$(L) zlib$(L) - -pnm2png$(O): pnm2png$(C) - $(CC) -c $(CCFLAGS) pnm2png$(C) - -pnm2png$(E): pnm2png$(O) - $(LD) $(LDFLAGS) pnm2png$(O) libpng$(L) zlib$(L) - -clean: - $(RM) *$(O) - $(RM) *$(E) - -# End of makefile for png2pnm / pnm2png - diff --git a/libpng/contrib/pngminus/makevms.com b/libpng/contrib/pngminus/makevms.com deleted file mode 100644 index 00561bc..0000000 --- a/libpng/contrib/pngminus/makevms.com +++ /dev/null @@ -1,92 +0,0 @@ -$!------------------------------------------------------------------------------ -$! make Contrib programs of libpng under OpenVMS -$! -$! -$! Look for the compiler used -$! -$ zlibsrc = "[---.zlib]" -$ ccopt="/include=(''zlibsrc',[--])" -$ if f$getsyi("HW_MODEL").ge.1024 -$ then -$ ccopt = "/prefix=all"+ccopt -$ comp = "__decc__=1" -$ if f$trnlnm("SYS").eqs."" then define sys sys$library: -$ else -$ if f$search("SYS$SYSTEM:DECC$COMPILER.EXE").eqs."" -$ then -$ if f$trnlnm("SYS").eqs."" then define sys sys$library: -$ if f$search("SYS$SYSTEM:VAXC.EXE").eqs."" -$ then -$ comp = "__gcc__=1" -$ CC :== GCC -$ else -$ comp = "__vaxc__=1" -$ endif -$ else -$ if f$trnlnm("SYS").eqs."" then define sys decc$library_include: -$ ccopt = "/decc/prefix=all"+ccopt -$ comp = "__decc__=1" -$ endif -$ endif -$ open/write lopt lib.opt -$ write lopt "[--]libpng.olb/lib" -$ write lopt "''zlibsrc'libz.olb/lib" -$ close lopt -$ open/write xopt x11.opt -$ write xopt "sys$library:decw$xlibshr.exe/share" -$ close xopt -$ write sys$output "Compiling PNG contrib programs ..." -$ write sys$output "Building pnm2png..." -$ CALL MAKE pnm2png.OBJ "cc ''CCOPT' pnm2png" - - pnm2png.c -$ call make pnm2png.exe - - "LINK pnm2png,lib.opt/opt" - - pnm2png.obj -$ write sys$output "Building png2pnm..." -$ CALL MAKE png2pnm.OBJ "cc ''CCOPT' png2pnm" - - png2pnm.c -$ call make png2pnm.exe - - "LINK png2pnm,lib.opt/opt" - - png2pnm.obj -$ exit -$! -$! -$MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES -$ V = 'F$Verify(0) -$! P1 = What we are trying to make -$! P2 = Command to make it -$! P3 - P8 What it depends on -$ -$ If F$Search(P1) .Eqs. "" Then Goto Makeit -$ Time = F$CvTime(F$File(P1,"RDT")) -$arg=3 -$Loop: -$ Argument = P'arg -$ If Argument .Eqs. "" Then Goto Exit -$ El=0 -$Loop2: -$ File = F$Element(El," ",Argument) -$ If File .Eqs. " " Then Goto Endl -$ AFile = "" -$Loop3: -$ OFile = AFile -$ AFile = F$Search(File) -$ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl -$ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit -$ Goto Loop3 -$NextEL: -$ El = El + 1 -$ Goto Loop2 -$EndL: -$ arg=arg+1 -$ If arg .Le. 8 Then Goto Loop -$ Goto Exit -$ -$Makeit: -$ VV=F$VERIFY(0) -$ write sys$output P2 -$ 'P2 -$ VV='F$Verify(VV) -$Exit: -$ If V Then Set Verify -$ENDSUBROUTINE diff --git a/libpng/contrib/pngminus/png2pnm.bat b/libpng/contrib/pngminus/png2pnm.bat deleted file mode 100644 index 449cf36..0000000 --- a/libpng/contrib/pngminus/png2pnm.bat +++ /dev/null @@ -1,41 +0,0 @@ -REM -- grayscale -png2pnm.exe -noraw ..\pngsuite\basn0g01.png basn0g01.pgm -png2pnm.exe -noraw ..\pngsuite\basn0g02.png basn0g02.pgm -png2pnm.exe -noraw ..\pngsuite\basn0g04.png basn0g04.pgm -png2pnm.exe -noraw ..\pngsuite\basn0g08.png basn0g08.pgm -png2pnm.exe -noraw ..\pngsuite\basn0g16.png basn0g16.pgm -REM -- full-color -png2pnm.exe -noraw ..\pngsuite\basn2c08.png basn2c08.ppm -png2pnm.exe -noraw ..\pngsuite\basn2c16.png basn2c16.ppm -REM -- palletted -png2pnm.exe -noraw ..\pngsuite\basn3p01.png basn3p01.ppm -png2pnm.exe -noraw ..\pngsuite\basn3p02.png basn3p02.ppm -png2pnm.exe -noraw ..\pngsuite\basn3p04.png basn3p04.ppm -png2pnm.exe -noraw ..\pngsuite\basn3p08.png basn3p08.ppm -REM -- gray with alpha-channel -png2pnm.exe -noraw ..\pngsuite\basn4a08.png basn4a08.pgm -png2pnm.exe -noraw ..\pngsuite\basn4a16.png basn4a16.pgm -REM -- color with alpha-channel -png2pnm.exe -noraw -alpha basn6a08.pgm ..\pngsuite\basn6a08.png basn6a08.ppm -png2pnm.exe -noraw -alpha basn6a16.pgm ..\pngsuite\basn6a16.png basn6a16.ppm -REM -- grayscale -png2pnm.exe -raw ..\pngsuite\basn0g01.png rawn0g01.pgm -png2pnm.exe -raw ..\pngsuite\basn0g02.png rawn0g02.pgm -png2pnm.exe -raw ..\pngsuite\basn0g04.png rawn0g04.pgm -png2pnm.exe -raw ..\pngsuite\basn0g08.png rawn0g08.pgm -png2pnm.exe -raw ..\pngsuite\basn0g16.png rawn0g16.pgm -REM -- full-color -png2pnm.exe -raw ..\pngsuite\basn2c08.png rawn2c08.ppm -png2pnm.exe -raw ..\pngsuite\basn2c16.png rawn2c16.ppm -REM -- palletted -png2pnm.exe -raw ..\pngsuite\basn3p01.png rawn3p01.ppm -png2pnm.exe -raw ..\pngsuite\basn3p02.png rawn3p02.ppm -png2pnm.exe -raw ..\pngsuite\basn3p04.png rawn3p04.ppm -png2pnm.exe -raw ..\pngsuite\basn3p08.png rawn3p08.ppm -REM -- gray with alpha-channel -png2pnm.exe -raw ..\pngsuite\basn4a08.png rawn4a08.pgm -png2pnm.exe -raw ..\pngsuite\basn4a16.png rawn4a16.pgm -REM -- color with alpha-channel -png2pnm.exe -noraw -alpha rawn6a08.pgm ..\pngsuite\basn6a08.png rawn6a08.ppm -png2pnm.exe -noraw -alpha rawn6a16.pgm ..\pngsuite\basn6a16.png rawn6a16.ppm - diff --git a/libpng/contrib/pngminus/png2pnm.c b/libpng/contrib/pngminus/png2pnm.c deleted file mode 100644 index a95acfa..0000000 --- a/libpng/contrib/pngminus/png2pnm.c +++ /dev/null @@ -1,430 +0,0 @@ -/* - * png2pnm.c --- conversion from PNG-file to PGM/PPM-file - * copyright (C) 1999 by Willem van Schaik <willem@schaik.com> - * - * version 1.0 - 1999.10.15 - First version. - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear in - * supporting documentation. This software is provided "as is" without - * express or implied warranty. - */ - -#include <stdio.h> -#include <stdlib.h> -#ifdef __TURBOC__ -#include <mem.h> -#include <fcntl.h> -#endif - -#ifndef BOOL -#define BOOL unsigned char -#endif -#ifndef TRUE -#define TRUE (BOOL) 1 -#endif -#ifndef FALSE -#define FALSE (BOOL) 0 -#endif - -#ifdef __TURBOC__ -#define STDIN 0 -#define STDOUT 1 -#define STDERR 2 -#endif - -/* to make png2pnm verbose so we can find problems (needs to be before png.h) */ -#ifndef PNG_DEBUG -#define PNG_DEBUG 0 -#endif - -#include "png.h" - -/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */ -#ifndef png_jmpbuf -# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) -#endif - -/* function prototypes */ - -int main (int argc, char *argv[]); -void usage (); -BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha); - -/* - * main - */ - -int main(int argc, char *argv[]) -{ - FILE *fp_rd = stdin; - FILE *fp_wr = stdout; - FILE *fp_al = NULL; - BOOL raw = TRUE; - BOOL alpha = FALSE; - int argi; - - for (argi = 1; argi < argc; argi++) - { - if (argv[argi][0] == '-') - { - switch (argv[argi][1]) - { - case 'n': - raw = FALSE; - break; - case 'r': - raw = TRUE; - break; - case 'a': - alpha = TRUE; - argi++; - if ((fp_al = fopen (argv[argi], "wb")) == NULL) - { - fprintf (stderr, "PNM2PNG\n"); - fprintf (stderr, "Error: can not create alpha-channel file %s\n", argv[argi]); - exit (1); - } - break; - case 'h': - case '?': - usage(); - exit(0); - break; - default: - fprintf (stderr, "PNG2PNM\n"); - fprintf (stderr, "Error: unknown option %s\n", argv[argi]); - usage(); - exit(1); - break; - } /* end switch */ - } - else if (fp_rd == stdin) - { - if ((fp_rd = fopen (argv[argi], "rb")) == NULL) - { - fprintf (stderr, "PNG2PNM\n"); - fprintf (stderr, "Error: file %s does not exist\n", argv[argi]); - exit (1); - } - } - else if (fp_wr == stdout) - { - if ((fp_wr = fopen (argv[argi], "wb")) == NULL) - { - fprintf (stderr, "PNG2PNM\n"); - fprintf (stderr, "Error: can not create file %s\n", argv[argi]); - exit (1); - } - } - else - { - fprintf (stderr, "PNG2PNM\n"); - fprintf (stderr, "Error: too many parameters\n"); - usage(); - exit(1); - } - } /* end for */ - -#ifdef __TURBOC__ - /* set stdin/stdout if required to binary */ - if (fp_rd == stdin) - { - setmode (STDIN, O_BINARY); - } - if ((raw) && (fp_wr == stdout)) - { - setmode (STDOUT, O_BINARY); - } -#endif - - /* call the conversion program itself */ - if (png2pnm (fp_rd, fp_wr, fp_al, raw, alpha) == FALSE) - { - fprintf (stderr, "PNG2PNM\n"); - fprintf (stderr, "Error: unsuccessful convertion of PNG-image\n"); - exit(1); - } - - /* close input file */ - fclose (fp_rd); - /* close output file */ - fclose (fp_wr); - /* close alpha file */ - if (alpha) - fclose (fp_al); - - return 0; -} - -/* - * usage - */ - -void usage() -{ - fprintf (stderr, "PNG2PNM\n"); - fprintf (stderr, " by Willem van Schaik, 1999\n"); -#ifdef __TURBOC__ - fprintf (stderr, " for Turbo-C and Borland-C compilers\n"); -#else - fprintf (stderr, " for Linux (and Unix) compilers\n"); -#endif - fprintf (stderr, "Usage: png2pnm [options] <file>.png [<file>.pnm]\n"); - fprintf (stderr, " or: ... | png2pnm [options]\n"); - fprintf (stderr, "Options:\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, " -a[lpha] <file>.pgm write PNG alpha channel as pgm-file\n"); - fprintf (stderr, " -h | -? print this help-information\n"); -} - -/* - * png2pnm - */ - -BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha) -{ - png_struct *png_ptr = NULL; - png_info *info_ptr = NULL; - png_byte buf[8]; - png_byte *png_pixels = NULL; - png_byte **row_pointers = NULL; - png_byte *pix_ptr = NULL; - png_uint_32 row_bytes; - - png_uint_32 width; - png_uint_32 height; - int bit_depth; - int channels; - int color_type; - int alpha_present; - int row, col; - int ret; - int i; - long dep_16; - - /* read and check signature in PNG file */ - ret = fread (buf, 1, 8, png_file); - if (ret != 8) - return FALSE; - - ret = png_sig_cmp (buf, 0, 8); - if (ret) - return FALSE; - - /* create png and info structures */ - - png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, - NULL, NULL, NULL); - if (!png_ptr) - return FALSE; /* out of memory */ - - info_ptr = png_create_info_struct (png_ptr); - if (!info_ptr) - { - png_destroy_read_struct (&png_ptr, NULL, NULL); - return FALSE; /* out of memory */ - } - - if (setjmp (png_jmpbuf(png_ptr))) - { - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); - return FALSE; - } - - /* set up the input control for C streams */ - png_init_io (png_ptr, png_file); - png_set_sig_bytes (png_ptr, 8); /* we already read the 8 signature bytes */ - - /* read the file information */ - png_read_info (png_ptr, info_ptr); - - /* get size and bit-depth of the PNG-image */ - png_get_IHDR (png_ptr, info_ptr, - &width, &height, &bit_depth, &color_type, - NULL, NULL, NULL); - - /* set-up the transformations */ - - /* transform paletted images into full-color rgb */ - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_expand (png_ptr); - /* expand images to bit-depth 8 (only applicable for grayscale images) */ - if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) - png_set_expand (png_ptr); - /* transform transparency maps into full alpha-channel */ - if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) - png_set_expand (png_ptr); - -#ifdef NJET - /* downgrade 16-bit images to 8 bit */ - if (bit_depth == 16) - png_set_strip_16 (png_ptr); - /* transform grayscale images into full-color */ - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb (png_ptr); - /* only if file has a file gamma, we do a correction */ - if (png_get_gAMA (png_ptr, info_ptr, &file_gamma)) - png_set_gamma (png_ptr, (double) 2.2, file_gamma); -#endif - - /* all transformations have been registered; now update info_ptr data, - * get rowbytes and channels, and allocate image memory */ - - png_read_update_info (png_ptr, info_ptr); - - /* get the new color-type and bit-depth (after expansion/stripping) */ - png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, - NULL, NULL, NULL); - - /* check for 16-bit files */ - if (bit_depth == 16) - { - raw = FALSE; -#ifdef __TURBOC__ - pnm_file->flags &= ~((unsigned) _F_BIN); -#endif - } - - /* calculate new number of channels and store alpha-presence */ - if (color_type == PNG_COLOR_TYPE_GRAY) - channels = 1; - else if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - channels = 2; - else if (color_type == PNG_COLOR_TYPE_RGB) - channels = 3; - else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) - channels = 4; - else - channels = 0; /* should never happen */ - alpha_present = (channels - 1) % 2; - - /* check if alpha is expected to be present in file */ - if (alpha && !alpha_present) - { - fprintf (stderr, "PNG2PNM\n"); - fprintf (stderr, "Error: PNG-file doesn't contain alpha channel\n"); - exit (1); - } - - /* row_bytes is the width x number of channels x (bit-depth / 8) */ - row_bytes = png_get_rowbytes (png_ptr, info_ptr); - - if ((png_pixels = (png_byte *) malloc (row_bytes * height * sizeof (png_byte))) == NULL) { - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); - return FALSE; - } - - if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL) - { - png_destroy_read_struct (&png_ptr, &info_ptr, NULL); - free (png_pixels); - png_pixels = NULL; - return FALSE; - } - - /* set the individual row_pointers to point at the correct offsets */ - for (i = 0; i < (height); i++) - row_pointers[i] = png_pixels + i * row_bytes; - - /* now we can go ahead and just read the whole image */ - png_read_image (png_ptr, row_pointers); - - /* read rest of file, and get additional chunks in info_ptr - REQUIRED */ - png_read_end (png_ptr, info_ptr); - - /* clean up after the read, and free any memory allocated - REQUIRED */ - png_destroy_read_struct (&png_ptr, &info_ptr, (png_infopp) NULL); - - /* write header of PNM file */ - - if ((color_type == PNG_COLOR_TYPE_GRAY) || - (color_type == PNG_COLOR_TYPE_GRAY_ALPHA)) - { - fprintf (pnm_file, "%s\n", (raw) ? "P5" : "P2"); - fprintf (pnm_file, "%d %d\n", (int) width, (int) height); - fprintf (pnm_file, "%ld\n", ((1L << (int) bit_depth) - 1L)); - } - else if ((color_type == PNG_COLOR_TYPE_RGB) || - (color_type == PNG_COLOR_TYPE_RGB_ALPHA)) - { - fprintf (pnm_file, "%s\n", (raw) ? "P6" : "P3"); - fprintf (pnm_file, "%d %d\n", (int) width, (int) height); - fprintf (pnm_file, "%ld\n", ((1L << (int) bit_depth) - 1L)); - } - - /* write header of PGM file with alpha channel */ - - if ((alpha) && - ((color_type == PNG_COLOR_TYPE_GRAY_ALPHA) || - (color_type == PNG_COLOR_TYPE_RGB_ALPHA))) - { - fprintf (alpha_file, "%s\n", (raw) ? "P5" : "P2"); - fprintf (alpha_file, "%d %d\n", (int) width, (int) height); - fprintf (alpha_file, "%ld\n", ((1L << (int) bit_depth) - 1L)); - } - - /* write data to PNM file */ - pix_ptr = png_pixels; - - for (row = 0; row < height; row++) - { - for (col = 0; col < width; col++) - { - for (i = 0; i < (channels - alpha_present); i++) - { - if (raw) - fputc ((int) *pix_ptr++ , pnm_file); - else - if (bit_depth == 16){ - dep_16 = (long) *pix_ptr++; - fprintf (pnm_file, "%ld ", (dep_16 << 8) + ((long) *pix_ptr++)); - } - else - fprintf (pnm_file, "%ld ", (long) *pix_ptr++); - } - if (alpha_present) - { - if (!alpha) - { - pix_ptr++; /* alpha */ - if (bit_depth == 16) - pix_ptr++; - } - else /* output alpha-channel as pgm file */ - { - if (raw) - fputc ((int) *pix_ptr++ , alpha_file); - else - if (bit_depth == 16){ - dep_16 = (long) *pix_ptr++; - fprintf (alpha_file, "%ld ", (dep_16 << 8) + (long) *pix_ptr++); - } - else - fprintf (alpha_file, "%ld ", (long) *pix_ptr++); - } - } /* if alpha_present */ - - if (!raw) - if (col % 4 == 3) - fprintf (pnm_file, "\n"); - } /* end for col */ - - if (!raw) - if (col % 4 != 0) - fprintf (pnm_file, "\n"); - } /* end for row */ - - if (row_pointers != (unsigned char**) NULL) - free (row_pointers); - if (png_pixels != (unsigned char*) NULL) - free (png_pixels); - - return TRUE; - -} /* end of source */ - diff --git a/libpng/contrib/pngminus/png2pnm.sh b/libpng/contrib/pngminus/png2pnm.sh deleted file mode 100644 index b1c0537..0000000 --- a/libpng/contrib/pngminus/png2pnm.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -# -- grayscale -./png2pnm -noraw ../pngsuite/basn0g01.png basn0g01.pgm -./png2pnm -noraw ../pngsuite/basn0g02.png basn0g02.pgm -./png2pnm -noraw ../pngsuite/basn0g04.png basn0g04.pgm -./png2pnm -noraw ../pngsuite/basn0g08.png basn0g08.pgm -./png2pnm -noraw ../pngsuite/basn0g16.png basn0g16.pgm -# -- full-color -./png2pnm -noraw ../pngsuite/basn2c08.png basn2c08.ppm -./png2pnm -noraw ../pngsuite/basn2c16.png basn2c16.ppm -# -- palletted -./png2pnm -noraw ../pngsuite/basn3p01.png basn3p01.ppm -./png2pnm -noraw ../pngsuite/basn3p02.png basn3p02.ppm -./png2pnm -noraw ../pngsuite/basn3p04.png basn3p04.ppm -./png2pnm -noraw ../pngsuite/basn3p08.png basn3p08.ppm -# -- gray with alpha-channel -./png2pnm -noraw ../pngsuite/basn4a08.png basn4a08.pgm -./png2pnm -noraw ../pngsuite/basn4a16.png basn4a16.pgm -# -- color with alpha-channel -./png2pnm -noraw -alpha basn6a08.pgm ../pngsuite/basn6a08.png basn6a08.ppm -./png2pnm -noraw -alpha basn6a16.pgm ../pngsuite/basn6a16.png basn6a16.ppm -# -- grayscale -./png2pnm -raw ../pngsuite/basn0g01.png rawn0g01.pgm -./png2pnm -raw ../pngsuite/basn0g02.png rawn0g02.pgm -./png2pnm -raw ../pngsuite/basn0g04.png rawn0g04.pgm -./png2pnm -raw ../pngsuite/basn0g08.png rawn0g08.pgm -./png2pnm -raw ../pngsuite/basn0g16.png rawn0g16.pgm -# -- full-color -./png2pnm -raw ../pngsuite/basn2c08.png rawn2c08.ppm -./png2pnm -raw ../pngsuite/basn2c16.png rawn2c16.ppm -# -- palletted -./png2pnm -raw ../pngsuite/basn3p01.png rawn3p01.ppm -./png2pnm -raw ../pngsuite/basn3p02.png rawn3p02.ppm -./png2pnm -raw ../pngsuite/basn3p04.png rawn3p04.ppm -./png2pnm -raw ../pngsuite/basn3p08.png rawn3p08.ppm -# -- gray with alpha-channel -./png2pnm -raw ../pngsuite/basn4a08.png rawn4a08.pgm -./png2pnm -raw ../pngsuite/basn4a16.png rawn4a16.pgm -# -- color with alpha-channel -./png2pnm -noraw -alpha rawn6a08.pgm ../pngsuite/basn6a08.png rawn6a08.ppm -./png2pnm -noraw -alpha rawn6a16.pgm ../pngsuite/basn6a16.png rawn6a16.ppm - diff --git a/libpng/contrib/pngminus/pngminus.bat b/libpng/contrib/pngminus/pngminus.bat deleted file mode 100644 index 911bb8d..0000000 --- a/libpng/contrib/pngminus/pngminus.bat +++ /dev/null @@ -1,4 +0,0 @@ -make -f makefile.tc3 -call png2pnm.bat -call pnm2png.bat - diff --git a/libpng/contrib/pngminus/pngminus.sh b/libpng/contrib/pngminus/pngminus.sh deleted file mode 100644 index 2a0a9d8..0000000 --- a/libpng/contrib/pngminus/pngminus.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -make -f makefile.std -sh png2pnm.sh -sh pnm2png.sh - diff --git a/libpng/contrib/pngminus/pnm2png.bat b/libpng/contrib/pngminus/pnm2png.bat deleted file mode 100644 index f756cb8..0000000 --- a/libpng/contrib/pngminus/pnm2png.bat +++ /dev/null @@ -1,41 +0,0 @@ -REM -- grayscale -pnm2png.exe basn0g01.pgm basn0g01.png -pnm2png.exe basn0g02.pgm basn0g02.png -pnm2png.exe basn0g04.pgm basn0g04.png -pnm2png.exe basn0g08.pgm basn0g08.png -pnm2png.exe basn0g16.pgm basn0g16.png -REM -- full-color -pnm2png.exe basn2c08.ppm basn2c08.png -pnm2png.exe basn2c16.ppm basn2c16.png -REM -- palletted -pnm2png.exe basn3p01.ppm basn3p01.png -pnm2png.exe basn3p02.ppm basn3p02.png -pnm2png.exe basn3p04.ppm basn3p04.png -pnm2png.exe basn3p08.ppm basn3p08.png -REM -- gray with alpha-channel -pnm2png.exe -alpha basn6a08.pgm basn4a08.pgm basn4a08.png -pnm2png.exe -alpha basn6a16.pgm basn4a16.pgm basn4a16.png -REM -- color with alpha-channel -pnm2png.exe -alpha basn6a08.pgm basn6a08.ppm basn6a08.png -pnm2png.exe -alpha basn6a16.pgm basn6a16.ppm basn6a16.png -REM -- grayscale -pnm2png.exe rawn0g01.pgm rawn0g01.png -pnm2png.exe rawn0g02.pgm rawn0g02.png -pnm2png.exe rawn0g04.pgm rawn0g04.png -pnm2png.exe rawn0g08.pgm rawn0g08.png -pnm2png.exe rawn0g16.pgm rawn0g16.png -REM -- full-color -pnm2png.exe rawn2c08.ppm rawn2c08.png -pnm2png.exe rawn2c16.ppm rawn2c16.png -REM -- palletted -pnm2png.exe rawn3p01.ppm rawn3p01.png -pnm2png.exe rawn3p02.ppm rawn3p02.png -pnm2png.exe rawn3p04.ppm rawn3p04.png -pnm2png.exe rawn3p08.ppm rawn3p08.png -REM -- gray with alpha-channel -pnm2png.exe -alpha rawn6a08.pgm rawn4a08.pgm rawn4a08.png -pnm2png.exe -alpha rawn6a16.pgm rawn4a16.pgm rawn4a16.png -REM -- color with alpha-channel -pnm2png.exe -alpha rawn6a08.pgm rawn6a08.ppm rawn6a08.png -pnm2png.exe -alpha rawn6a16.pgm rawn6a16.ppm rawn6a16.png - diff --git a/libpng/contrib/pngminus/pnm2png.c b/libpng/contrib/pngminus/pnm2png.c deleted file mode 100644 index 4cdfad8..0000000 --- a/libpng/contrib/pngminus/pnm2png.c +++ /dev/null @@ -1,533 +0,0 @@ -/* - * pnm2png.c --- conversion from PBM/PGM/PPM-file to PNG-file - * copyright (C) 1999 by Willem van Schaik <willem@schaik.com> - * - * version 1.0 - 1999.10.15 - First version. - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear in - * supporting documentation. This software is provided "as is" without - * express or implied warranty. - */ - -#include <stdio.h> -#include <stdlib.h> -#ifdef __TURBOC__ -#include <mem.h> -#include <fcntl.h> -#endif - -#ifndef BOOL -#define BOOL unsigned char -#endif -#ifndef TRUE -#define TRUE (BOOL) 1 -#endif -#ifndef FALSE -#define FALSE (BOOL) 0 -#endif - -#define STDIN 0 -#define STDOUT 1 -#define STDERR 2 - -/* to make pnm2png verbose so we can find problems (needs to be before png.h) */ -#ifndef PNG_DEBUG -#define PNG_DEBUG 0 -#endif - -#include "png.h" - -/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */ -#ifndef png_jmpbuf -# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) -#endif - -/* function prototypes */ - -int main (int argc, char *argv[]); -void usage (); -BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, BOOL alpha); -void get_token(FILE *pnm_file, char *token); -png_uint_32 get_data (FILE *pnm_file, int depth); -png_uint_32 get_value (FILE *pnm_file, int depth); - -/* - * main - */ - -int main(int argc, char *argv[]) -{ - FILE *fp_rd = stdin; - FILE *fp_al = NULL; - FILE *fp_wr = stdout; - BOOL interlace = FALSE; - BOOL alpha = FALSE; - int argi; - - for (argi = 1; argi < argc; argi++) - { - if (argv[argi][0] == '-') - { - switch (argv[argi][1]) - { - case 'i': - interlace = TRUE; - break; - case 'a': - alpha = TRUE; - argi++; - if ((fp_al = fopen (argv[argi], "rb")) == NULL) - { - fprintf (stderr, "PNM2PNG\n"); - fprintf (stderr, "Error: alpha-channel file %s does not exist\n", - argv[argi]); - exit (1); - } - break; - case 'h': - case '?': - usage(); - exit(0); - break; - default: - fprintf (stderr, "PNM2PNG\n"); - fprintf (stderr, "Error: unknown option %s\n", argv[argi]); - usage(); - exit(1); - break; - } /* end switch */ - } - else if (fp_rd == stdin) - { - if ((fp_rd = fopen (argv[argi], "rb")) == NULL) - { - fprintf (stderr, "PNM2PNG\n"); - fprintf (stderr, "Error: file %s does not exist\n", argv[argi]); - exit (1); - } - } - else if (fp_wr == stdout) - { - if ((fp_wr = fopen (argv[argi], "wb")) == NULL) - { - fprintf (stderr, "PNM2PNG\n"); - fprintf (stderr, "Error: can not create PNG-file %s\n", argv[argi]); - exit (1); - } - } - else - { - fprintf (stderr, "PNM2PNG\n"); - fprintf (stderr, "Error: too many parameters\n"); - usage(); - exit (1); - } - } /* end for */ - -#ifdef __TURBOC__ - /* set stdin/stdout to binary, we're reading the PNM always! in binary format */ - if (fp_rd == stdin) - { - setmode (STDIN, O_BINARY); - } - if (fp_wr == stdout) - { - setmode (STDOUT, O_BINARY); - } -#endif - - /* call the conversion program itself */ - if (pnm2png (fp_rd, fp_wr, fp_al, interlace, alpha) == FALSE) - { - fprintf (stderr, "PNM2PNG\n"); - fprintf (stderr, "Error: unsuccessful converting to PNG-image\n"); - exit (1); - } - - /* close input file */ - fclose (fp_rd); - /* close output file */ - fclose (fp_wr); - /* close alpha file */ - if (alpha) - fclose (fp_al); - - return 0; -} - -/* - * usage - */ - -void usage() -{ - fprintf (stderr, "PNM2PNG\n"); - fprintf (stderr, " by Willem van Schaik, 1999\n"); -#ifdef __TURBOC__ - fprintf (stderr, " for Turbo-C and Borland-C compilers\n"); -#else - fprintf (stderr, " for Linux (and Unix) compilers\n"); -#endif - fprintf (stderr, "Usage: pnm2png [options] <file>.<pnm> [<file>.png]\n"); - fprintf (stderr, " or: ... | pnm2png [options]\n"); - fprintf (stderr, "Options:\n"); - fprintf (stderr, " -i[nterlace] write png-file with interlacing on\n"); - fprintf (stderr, " -a[lpha] <file>.pgm read PNG alpha channel as pgm-file\n"); - fprintf (stderr, " -h | -? print this help-information\n"); -} - -/* - * pnm2png - */ - -BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, BOOL alpha) -{ - png_struct *png_ptr = NULL; - png_info *info_ptr = NULL; - png_byte *png_pixels = NULL; - png_byte **row_pointers = NULL; - png_byte *pix_ptr = NULL; - png_uint_32 row_bytes; - - char type_token[16]; - char width_token[16]; - char height_token[16]; - char maxval_token[16]; - int color_type; - png_uint_32 width, alpha_width; - png_uint_32 height, alpha_height; - png_uint_32 maxval; - int bit_depth = 0; - int channels; - int alpha_depth = 0; - int alpha_present; - int row, col; - BOOL raw, alpha_raw = FALSE; - png_uint_32 tmp16; - int i; - - /* read header of PNM file */ - - get_token(pnm_file, type_token); - if (type_token[0] != 'P') - { - return FALSE; - } - else if ((type_token[1] == '1') || (type_token[1] == '4')) - { - raw = (type_token[1] == '4'); - color_type = PNG_COLOR_TYPE_GRAY; - bit_depth = 1; - } - else if ((type_token[1] == '2') || (type_token[1] == '5')) - { - raw = (type_token[1] == '5'); - color_type = PNG_COLOR_TYPE_GRAY; - get_token(pnm_file, width_token); - sscanf (width_token, "%lu", &width); - get_token(pnm_file, height_token); - sscanf (height_token, "%lu", &height); - get_token(pnm_file, maxval_token); - sscanf (maxval_token, "%lu", &maxval); - if (maxval <= 1) - bit_depth = 1; - else if (maxval <= 3) - bit_depth = 2; - else if (maxval <= 15) - bit_depth = 4; - else if (maxval <= 255) - bit_depth = 8; - else /* if (maxval <= 65535) */ - bit_depth = 16; - } - else if ((type_token[1] == '3') || (type_token[1] == '6')) - { - raw = (type_token[1] == '6'); - color_type = PNG_COLOR_TYPE_RGB; - get_token(pnm_file, width_token); - sscanf (width_token, "%lu", &width); - get_token(pnm_file, height_token); - sscanf (height_token, "%lu", &height); - get_token(pnm_file, maxval_token); - sscanf (maxval_token, "%lu", &maxval); - if (maxval <= 1) - bit_depth = 1; - else if (maxval <= 3) - bit_depth = 2; - else if (maxval <= 15) - bit_depth = 4; - else if (maxval <= 255) - bit_depth = 8; - else /* if (maxval <= 65535) */ - bit_depth = 16; - } - else - { - return FALSE; - } - - /* read header of PGM file with alpha channel */ - - if (alpha) - { - if (color_type == PNG_COLOR_TYPE_GRAY) - color_type = PNG_COLOR_TYPE_GRAY_ALPHA; - if (color_type == PNG_COLOR_TYPE_RGB) - color_type = PNG_COLOR_TYPE_RGB_ALPHA; - - get_token(alpha_file, type_token); - if (type_token[0] != 'P') - { - return FALSE; - } - else if ((type_token[1] == '2') || (type_token[1] == '5')) - { - alpha_raw = (type_token[1] == '5'); - get_token(alpha_file, width_token); - sscanf (width_token, "%lu", &alpha_width); - if (alpha_width != width) - return FALSE; - get_token(alpha_file, height_token); - sscanf (height_token, "%lu", &alpha_height); - if (alpha_height != height) - return FALSE; - get_token(alpha_file, maxval_token); - sscanf (maxval_token, "%lu", &maxval); - if (maxval <= 1) - alpha_depth = 1; - else if (maxval <= 3) - alpha_depth = 2; - else if (maxval <= 15) - alpha_depth = 4; - else if (maxval <= 255) - alpha_depth = 8; - else /* if (maxval <= 65535) */ - alpha_depth = 16; - if (alpha_depth != bit_depth) - return FALSE; - } - else - { - return FALSE; - } - } /* end if alpha */ - - /* calculate the number of channels and store alpha-presence */ - if (color_type == PNG_COLOR_TYPE_GRAY) - channels = 1; - else if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - channels = 2; - else if (color_type == PNG_COLOR_TYPE_RGB) - channels = 3; - else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) - channels = 4; - else - channels = 0; /* should not happen */ - - alpha_present = (channels - 1) % 2; - - /* row_bytes is the width x number of channels x (bit-depth / 8) */ - row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2); - - if ((png_pixels = (png_byte *) malloc (row_bytes * height * sizeof (png_byte))) == NULL) - return FALSE; - - /* read data from PNM file */ - pix_ptr = png_pixels; - - for (row = 0; row < height; row++) - { - for (col = 0; col < width; col++) - { - for (i = 0; i < (channels - alpha_present); i++) - { - if (raw) - *pix_ptr++ = get_data (pnm_file, bit_depth); - else - if (bit_depth <= 8) - *pix_ptr++ = get_value (pnm_file, bit_depth); - else - { - tmp16 = get_value (pnm_file, bit_depth); - *pix_ptr = (png_byte) ((tmp16 >> 8) & 0xFF); - pix_ptr++; - *pix_ptr = (png_byte) (tmp16 & 0xFF); - pix_ptr++; - } - } - - if (alpha) /* read alpha-channel from pgm file */ - { - if (alpha_raw) - *pix_ptr++ = get_data (alpha_file, alpha_depth); - else - if (alpha_depth <= 8) - *pix_ptr++ = get_value (alpha_file, bit_depth); - else - { - tmp16 = get_value (alpha_file, bit_depth); - *pix_ptr++ = (png_byte) ((tmp16 >> 8) & 0xFF); - *pix_ptr++ = (png_byte) (tmp16 & 0xFF); - } - } /* if alpha */ - - } /* end for col */ - } /* end for row */ - - /* prepare the standard PNG structures */ - png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!png_ptr) - { - return FALSE; - } - info_ptr = png_create_info_struct (png_ptr); - if (!info_ptr) - { - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); - return FALSE; - } - - /* setjmp() must be called in every function that calls a PNG-reading libpng function */ - if (setjmp (png_jmpbuf(png_ptr))) - { - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); - return FALSE; - } - - /* initialize the png structure */ - png_init_io (png_ptr, png_file); - - /* we're going to write more or less the same PNG as the input file */ - png_set_IHDR (png_ptr, info_ptr, width, height, bit_depth, color_type, - (!interlace) ? PNG_INTERLACE_NONE : PNG_INTERLACE_ADAM7, - PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - - /* write the file header information */ - png_write_info (png_ptr, info_ptr); - - /* if needed we will allocate memory for an new array of row-pointers */ - if (row_pointers == (unsigned char**) NULL) - { - if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL) - { - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); - return FALSE; - } - } - - /* set the individual row_pointers to point at the correct offsets */ - for (i = 0; i < (height); i++) - row_pointers[i] = png_pixels + i * row_bytes; - - /* write out the entire image data in one call */ - png_write_image (png_ptr, row_pointers); - - /* write the additional chuncks to the PNG file (not really needed) */ - png_write_end (png_ptr, info_ptr); - - /* clean up after the write, and free any memory allocated */ - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); - - if (row_pointers != (unsigned char**) NULL) - free (row_pointers); - if (png_pixels != (unsigned char*) NULL) - free (png_pixels); - - return TRUE; -} /* end of pnm2png */ - -/* - * get_token() - gets the first string after whitespace - */ - -void get_token(FILE *pnm_file, char *token) -{ - int i = 0; - - /* remove white-space */ - do - { - token[i] = (unsigned char) fgetc (pnm_file); - } - while ((token[i] == '\n') || (token[i] == '\r') || (token[i] == ' ')); - - /* read string */ - do - { - i++; - token[i] = (unsigned char) fgetc (pnm_file); - } - while ((token[i] != '\n') && (token[i] != '\r') && (token[i] != ' ')); - - token[i] = '\0'; - - return; -} - -/* - * get_data() - takes first byte and converts into next pixel value, - * taking as much bits as defined by bit-depth and - * using the bit-depth to fill up a byte (0Ah -> AAh) - */ - -png_uint_32 get_data (FILE *pnm_file, int depth) -{ - static int bits_left = 0; - static int old_value = 0; - static int mask = 0; - int i; - png_uint_32 ret_value; - - if (mask == 0) - for (i = 0; i < depth; i++) - mask = (mask >> 1) | 0x80; - - if (bits_left <= 0) - { - old_value = fgetc (pnm_file); - bits_left = 8; - } - - ret_value = old_value & mask; - for (i = 1; i < (8 / depth); i++) - ret_value = ret_value || (ret_value >> depth); - - old_value = (old_value << depth) & 0xFF; - bits_left -= depth; - - return ret_value; -} - -/* - * get_value() - takes first (numeric) string and converts into number, - * using the bit-depth to fill up a byte (0Ah -> AAh) - */ - -png_uint_32 get_value (FILE *pnm_file, int depth) -{ - static png_uint_32 mask = 0; - png_byte token[16]; - png_uint_32 ret_value; - int i = 0; - - if (mask == 0) - for (i = 0; i < depth; i++) - mask = (mask << 1) | 0x01; - - get_token (pnm_file, (char *) token); - sscanf ((const char *) token, "%lu", &ret_value); - - ret_value &= mask; - - if (depth < 8) - for (i = 0; i < (8 / depth); i++) - ret_value = (ret_value << depth) || ret_value; - - return ret_value; -} - -/* end of source */ - diff --git a/libpng/contrib/pngminus/pnm2png.sh b/libpng/contrib/pngminus/pnm2png.sh deleted file mode 100644 index d79df2f..0000000 --- a/libpng/contrib/pngminus/pnm2png.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -# -- grayscale -./pnm2png basn0g01.pgm basn0g01.png -./pnm2png basn0g02.pgm basn0g02.png -./pnm2png basn0g04.pgm basn0g04.png -./pnm2png basn0g08.pgm basn0g08.png -./pnm2png basn0g16.pgm basn0g16.png -# -- full-color -./pnm2png basn2c08.ppm basn2c08.png -./pnm2png basn2c16.ppm basn2c16.png -# -- palletted -./pnm2png basn3p01.ppm basn3p01.png -./pnm2png basn3p02.ppm basn3p02.png -./pnm2png basn3p04.ppm basn3p04.png -./pnm2png basn3p08.ppm basn3p08.png -# -- gray with alpha-channel -./pnm2png -alpha basn6a08.pgm basn4a08.pgm basn4a08.png -./pnm2png -alpha basn6a16.pgm basn4a16.pgm basn4a16.png -# -- color with alpha-channel -./pnm2png -alpha basn6a08.pgm basn6a08.ppm basn6a08.png -./pnm2png -alpha basn6a16.pgm basn6a16.ppm basn6a16.png -# -- grayscale -./pnm2png rawn0g01.pgm rawn0g01.png -./pnm2png rawn0g02.pgm rawn0g02.png -./pnm2png rawn0g04.pgm rawn0g04.png -./pnm2png rawn0g08.pgm rawn0g08.png -./pnm2png rawn0g16.pgm rawn0g16.png -# -- full-color -./pnm2png rawn2c08.ppm rawn2c08.png -./pnm2png rawn2c16.ppm rawn2c16.png -# -- palletted -./pnm2png rawn3p01.ppm rawn3p01.png -./pnm2png rawn3p02.ppm rawn3p02.png -./pnm2png rawn3p04.ppm rawn3p04.png -./pnm2png rawn3p08.ppm rawn3p08.png -# -- gray with alpha-channel -./pnm2png -alpha rawn6a08.pgm rawn4a08.pgm rawn4a08.png -./pnm2png -alpha rawn6a16.pgm rawn4a16.pgm rawn4a16.png -# -- color with alpha-channel -./pnm2png -alpha rawn6a08.pgm rawn6a08.ppm rawn6a08.png -./pnm2png -alpha rawn6a16.pgm rawn6a16.ppm rawn6a16.png - |