diff options
author | David Walter Seikel | 2013-01-13 17:24:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2013-01-13 17:24:39 +1000 |
commit | 393b5cd1dc438872af89d334ef6e5fcc59f27d47 (patch) | |
tree | 6a14521219942a08a1b95cb2f5a923a9edd60f63 /libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus | |
parent | Add a note about rasters suggested start up code. (diff) | |
download | SledjHamr-393b5cd1dc438872af89d334ef6e5fcc59f27d47.zip SledjHamr-393b5cd1dc438872af89d334ef6e5fcc59f27d47.tar.gz SledjHamr-393b5cd1dc438872af89d334ef6e5fcc59f27d47.tar.bz2 SledjHamr-393b5cd1dc438872af89d334ef6e5fcc59f27d47.tar.xz |
Added Irrlicht 1.8, but without all the Windows binaries.
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus')
12 files changed, 1486 insertions, 0 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/README b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/README new file mode 100644 index 0000000..b0516ec --- /dev/null +++ b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/README | |||
@@ -0,0 +1,153 @@ | |||
1 | PngMinus | ||
2 | -------- | ||
3 | (copyright Willem van Schaik, 1999) | ||
4 | |||
5 | |||
6 | License | ||
7 | ------- | ||
8 | |||
9 | Permission to use, copy, modify, and distribute this software and | ||
10 | its documentation for any purpose and without fee is hereby granted, | ||
11 | provided that the above copyright notice appear in all copies and | ||
12 | that both that copyright notice and this permission notice appear in | ||
13 | supporting documentation. This software is provided "as is" without | ||
14 | express or implied warranty. | ||
15 | |||
16 | |||
17 | Some history | ||
18 | ------------ | ||
19 | Soon after the creation of PNG in 1995, the need was felt for a set of | ||
20 | pnmtopng / pngtopnm utilities. Independantly Alexander Lehmann and I | ||
21 | (Willem van Schaik) started such a project. Luckily we discovered this | ||
22 | and merged the two together into pnmtopng.tar.gz, which is available | ||
23 | from a/o ftp://ftp.simplesystems.org/pub/libpng/png/. | ||
24 | |||
25 | These two utilities have many, many options and make use of most of the | ||
26 | features of PNG, like gamma, alpha, sbit, text-chunks, etc. This makes | ||
27 | the utilities quite complex and by now not anymore very maintainable. | ||
28 | When we wrote these programs, libpng was still in an early stage. | ||
29 | Therefore, lots of the functionality that we put in our software can now | ||
30 | be done using transform-functions in libpng. | ||
31 | |||
32 | Finally, to compile these programs, you need to have installed and | ||
33 | compiled three libraries: libpng, zlib and netpbm. Especially the latter | ||
34 | makes the whole setup a bit bulky. But that's unavoidable given the many | ||
35 | features of pnmtopng. | ||
36 | |||
37 | |||
38 | What now | ||
39 | -------- | ||
40 | At this moment libpng is in a very stable state and can do much of the | ||
41 | work done in pnmtopng. Also, pnmtopng needs to be upgraded to the new | ||
42 | interface of libpng. Hence, it is time for a rewrite from the ground up | ||
43 | of pnmtopng and pngtopnm. This will happen in the near future (stay | ||
44 | tuned). The new package will get a different name to distinguish it from | ||
45 | the old one: PngPlus. | ||
46 | |||
47 | To experiment a bit with the new interface of libpng, I started off with | ||
48 | a small prototype that contains only the basic functionality. It doesn't | ||
49 | have any of the options to read or write special chunks and it will do | ||
50 | no gamma correction. But this makes it also a simple program that is | ||
51 | quite easy to understand and can serve well as a template for other | ||
52 | software developments. (By now there are of course a couple of programs, | ||
53 | like Greg Roelofs' rpng/wpng, that can be used just as good.) | ||
54 | |||
55 | |||
56 | Can and can not | ||
57 | --------------- | ||
58 | As this is the small brother of the future PngPlus, I called this fellow | ||
59 | PngMinus. Because I started this development in good-old Turbo-C, I | ||
60 | avoided the use the netpbm library, which requires DOS extenders. Again, | ||
61 | another reason to call it PngMinus (minus netpbm :-). So, part of the | ||
62 | program are some elementary routines to read / write pgm- and ppm-files. | ||
63 | It does not read b&w pbm-files. | ||
64 | |||
65 | The downside of this approach is that you can not use them on images | ||
66 | that require blocks of memory bigger than 64k (the DOS version). For | ||
67 | larger images you will get an out-of-memory error. | ||
68 | |||
69 | As said before, PngMinus doesn't correct for gamma. When reading | ||
70 | png-files you can do this just as well by piping the output of png2pnm | ||
71 | to pnmgamma, one of the standard PbmPlus tools. This same scenario will | ||
72 | most probably also be followed in the full-blown future PngPlus, with | ||
73 | the addition of course of the possibility to create gamma-chunks when | ||
74 | writing png-files. | ||
75 | |||
76 | On the other hand it supports alpha-channels. When reading a png-image | ||
77 | you can write the alpha-channel into a pgm-file. And when creating an | ||
78 | RGB+A png-image, you just combine a ppm-file with a corresponding | ||
79 | pgm-file containing the alpha-channel. When reading, transparency chunks | ||
80 | are converted into an alpha-channel and from there on treated the same | ||
81 | way. | ||
82 | |||
83 | Finally you can opt for writing ascii or binary pgm- and ppm-files. When | ||
84 | the bit-depth is 16, the format will always be ascii. | ||
85 | |||
86 | |||
87 | Using it | ||
88 | -------- | ||
89 | To distinguish them from pnmtopng and PngPlus, the utilities are named | ||
90 | png2pnm and pnm2png (2 instead of to). The input- and output-files can | ||
91 | be given as parameters or through redirection. Therefore the programs | ||
92 | can be part of a pipe. | ||
93 | |||
94 | To list the options type "png2pnm -h" or "pnm2png -h". | ||
95 | |||
96 | |||
97 | Just like Scandinavian furniture | ||
98 | -------------------------------- | ||
99 | You have to put it together yourself. I did test the software under | ||
100 | MS-DOS with Turbo-C 3.0 and under RedHat Linux 4.2 with gcc. In both | ||
101 | cases I used libpng-1.0.4 and zlib-1.1.3. Later versions should be OK, | ||
102 | however some older libpng versions have a bug in pngmem.c when using | ||
103 | Turbo-C 3.0 (see below). | ||
104 | |||
105 | You can build it using one of the two makefiles (make -f makefile.###) | ||
106 | or use the batch/script files pngminus.bat / pngminus.sh. This assumes | ||
107 | that you have built the libraries in ../libpng and ../zlib. Using Linux, | ||
108 | make sure that you have built libpng with makefile.std and not | ||
109 | makefile.linux (also called .lnx in earlier versions of libpng). The | ||
110 | latter creates a .so shared-library, while the PngMinus makefile assumes | ||
111 | a normal .a static library. | ||
112 | |||
113 | If you create a ../pngsuite directory and then store the basn####.png | ||
114 | files from PngSuite (http://www.schaik.com/pngsuite/) in there, you can | ||
115 | test in one go the proper functioning of PngMinus, see png2pnm.bat and | ||
116 | pnm2png.bat (or the .sh versions). | ||
117 | |||
118 | |||
119 | Warranty | ||
120 | ------- | ||
121 | Please, remember that this was just a small experiment to learn a few | ||
122 | things. It will have many unforeseen features <vbg>. Who said bugs? Use | ||
123 | it when you are in need for something simple or when you want to start | ||
124 | developing your own stuff. | ||
125 | |||
126 | |||
127 | The Turbo bug | ||
128 | ------------- | ||
129 | ** pngmem.old | ||
130 | hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L); | ||
131 | hptr += 16L; | ||
132 | ** pngmem.c | ||
133 | hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L); | ||
134 | hptr = hptr + 16L; | ||
135 | ** | ||
136 | |||
137 | ** pngmem.old | ||
138 | png_ptr->offset_table_ptr[i] = (png_bytep)hptr; | ||
139 | hptr += (png_uint_32)65536L; | ||
140 | ** pngmem.c | ||
141 | png_ptr->offset_table_ptr[i] = (png_bytep)hptr; | ||
142 | hptr = hptr + 65536L; | ||
143 | ** | ||
144 | |||
145 | |||
146 | The end | ||
147 | ------- | ||
148 | Willem van Schaik | ||
149 | mailto:willem@schaik.com | ||
150 | http://www.schaik.com/png/ | ||
151 | ------- | ||
152 | Oct 1999 | ||
153 | |||
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/makefile.std b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/makefile.std new file mode 100644 index 0000000..a121032 --- /dev/null +++ b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/makefile.std | |||
@@ -0,0 +1,65 @@ | |||
1 | # Makefile for PngMinus (png2pnm and pnm2png) | ||
2 | # Linux / Unix | ||
3 | |||
4 | #CC=cc | ||
5 | CC=gcc | ||
6 | LD=$(CC) | ||
7 | |||
8 | RM=rm -f | ||
9 | |||
10 | #PNGPATH = /usr/local | ||
11 | #PNGINC = -I$(PNGPATH)/include/libpng15 | ||
12 | #PNGLIB = -L$(PNGPATH)/lib -lpng15 | ||
13 | #PNGLIBS = $(PNGPATH)/lib/libpng15.a | ||
14 | PNGINC = -I../.. | ||
15 | PNGLIB = -L../.. -lpng | ||
16 | PNGLIBS = ../../libpng.a | ||
17 | |||
18 | #ZPATH = /usr/local | ||
19 | #ZINC = -I$(ZPATH)/include | ||
20 | #ZLIB = -L$(ZPATH)/lib -lz | ||
21 | #ZLIBS = $(ZPATH)/lib/libz.a | ||
22 | ZINC = -I../../../zlib | ||
23 | ZLIB = -L../../../zlib -lz | ||
24 | ZLIBS = ../../../zlib/libz.a | ||
25 | |||
26 | CFLAGS=$(PNGINC) $(ZINC) | ||
27 | LDLIBS=$(PNGLIB) $(ZLIB) | ||
28 | LDLIBSS=$(PNGLIBS) $(ZLIBS) | ||
29 | C=.c | ||
30 | O=.o | ||
31 | L=.a | ||
32 | E= | ||
33 | |||
34 | # dependencies | ||
35 | |||
36 | #all: png2pnm$(E) pnm2png$(E) | ||
37 | all: png2pnm$(E) pnm2png$(E) png2pnm-static$(E) pnm2png-static$(E) | ||
38 | |||
39 | png2pnm$(O): png2pnm$(C) | ||
40 | $(CC) -c $(CFLAGS) png2pnm$(C) | ||
41 | |||
42 | png2pnm$(E): png2pnm$(O) | ||
43 | $(LD) $(LDFLAGS) -o png2pnm$(E) png2pnm$(O) $(LDLIBS) -lm | ||
44 | |||
45 | png2pnm-static$(E): png2pnm$(O) | ||
46 | $(LD) $(LDFLAGS) -o png2pnm-static$(E) png2pnm$(O) $(LDLIBSS) -lm | ||
47 | |||
48 | pnm2png$(O): pnm2png$(C) | ||
49 | $(CC) -c $(CFLAGS) pnm2png$(C) | ||
50 | |||
51 | pnm2png$(E): pnm2png$(O) | ||
52 | $(LD) $(LDFLAGS) -o pnm2png$(E) pnm2png$(O) $(LDLIBS) -lm | ||
53 | |||
54 | pnm2png-static$(E): pnm2png$(O) | ||
55 | $(LD) $(LDFLAGS) -o pnm2png-static$(E) pnm2png$(O) $(LDLIBSS) -lm | ||
56 | |||
57 | clean: | ||
58 | $(RM) png2pnm$(O) | ||
59 | $(RM) pnm2png$(O) | ||
60 | $(RM) png2pnm$(E) | ||
61 | $(RM) pnm2png$(E) | ||
62 | $(RM) png2pnm-static$(E) | ||
63 | $(RM) pnm2png-static$(E) | ||
64 | |||
65 | # End of makefile for png2pnm / pnm2png | ||
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/makefile.tc3 b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/makefile.tc3 new file mode 100644 index 0000000..01062cc --- /dev/null +++ b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/makefile.tc3 | |||
@@ -0,0 +1,38 @@ | |||
1 | # Makefile for PngMinus (png2pnm and pnm2png) | ||
2 | # TurboC++ 3.0 | ||
3 | |||
4 | CC=tcc -Ic:\tc3\inc | ||
5 | LD=tcc -Lc:\tc3\lib | ||
6 | LB=tlib | ||
7 | RM=del | ||
8 | CP=copy | ||
9 | MODEL=l | ||
10 | CCFLAGS=-O -m$(MODEL) -I..\libpng -I..\zlib | ||
11 | LDFLAGS=-m$(MODEL) -L..\libpng -L..\zlib | ||
12 | C=.c | ||
13 | O=.obj | ||
14 | L=.lib | ||
15 | E=.exe | ||
16 | |||
17 | # dependencies | ||
18 | |||
19 | all: png2pnm$(E) pnm2png$(E) | ||
20 | |||
21 | png2pnm$(O): png2pnm$(C) | ||
22 | $(CC) -c $(CCFLAGS) png2pnm$(C) | ||
23 | |||
24 | png2pnm$(E): png2pnm$(O) | ||
25 | $(LD) $(LDFLAGS) png2pnm$(O) libpng$(L) zlib$(L) | ||
26 | |||
27 | pnm2png$(O): pnm2png$(C) | ||
28 | $(CC) -c $(CCFLAGS) pnm2png$(C) | ||
29 | |||
30 | pnm2png$(E): pnm2png$(O) | ||
31 | $(LD) $(LDFLAGS) pnm2png$(O) libpng$(L) zlib$(L) | ||
32 | |||
33 | clean: | ||
34 | $(RM) *$(O) | ||
35 | $(RM) *$(E) | ||
36 | |||
37 | # End of makefile for png2pnm / pnm2png | ||
38 | |||
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/makevms.com b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/makevms.com new file mode 100644 index 0000000..96c3147 --- /dev/null +++ b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/makevms.com | |||
@@ -0,0 +1,92 @@ | |||
1 | $!------------------------------------------------------------------------------ | ||
2 | $! make Contrib programs of libpng under OpenVMS | ||
3 | $! | ||
4 | $! | ||
5 | $! Look for the compiler used | ||
6 | $! | ||
7 | $ zlibsrc = "[---.zlib]" | ||
8 | $ ccopt="/include=(''zlibsrc',[--])" | ||
9 | $ if f$getsyi("HW_MODEL").ge.1024 | ||
10 | $ then | ||
11 | $ ccopt = "/prefix=all"+ccopt | ||
12 | $ comp = "__decc__=1" | ||
13 | $ if f$trnlnm("SYS").eqs."" then define sys sys$library: | ||
14 | $ else | ||
15 | $ if f$search("SYS$SYSTEM:DECC$COMPILER.EXE").eqs."" | ||
16 | $ then | ||
17 | $ if f$trnlnm("SYS").eqs."" then define sys sys$library: | ||
18 | $ if f$search("SYS$SYSTEM:VAXC.EXE").eqs."" | ||
19 | $ then | ||
20 | $ comp = "__gcc__=1" | ||
21 | $ CC :== GCC | ||
22 | $ else | ||
23 | $ comp = "__vaxc__=1" | ||
24 | $ endif | ||
25 | $ else | ||
26 | $ if f$trnlnm("SYS").eqs."" then define sys decc$library_include: | ||
27 | $ ccopt = "/decc/prefix=all"+ccopt | ||
28 | $ comp = "__decc__=1" | ||
29 | $ endif | ||
30 | $ endif | ||
31 | $ open/write lopt lib.opt | ||
32 | $ write lopt "[--]libpng.olb/lib" | ||
33 | $ write lopt "''zlibsrc'libz.olb/lib" | ||
34 | $ close lopt | ||
35 | $ open/write xopt x11.opt | ||
36 | $ write xopt "sys$library:decw$xlibshr.exe/share" | ||
37 | $ close xopt | ||
38 | $ write sys$output "Compiling PNG contrib programs ..." | ||
39 | $ write sys$output "Building pnm2png..." | ||
40 | $ CALL MAKE pnm2png.OBJ "cc ''CCOPT' pnm2png" - | ||
41 | pnm2png.c | ||
42 | $ call make pnm2png.exe - | ||
43 | "LINK pnm2png,lib.opt/opt" - | ||
44 | pnm2png.obj | ||
45 | $ write sys$output "Building png2pnm..." | ||
46 | $ CALL MAKE png2pnm.OBJ "cc ''CCOPT' png2pnm" - | ||
47 | png2pnm.c | ||
48 | $ call make png2pnm.exe - | ||
49 | "LINK png2pnm,lib.opt/opt" - | ||
50 | png2pnm.obj | ||
51 | $ exit | ||
52 | $! | ||
53 | $! | ||
54 | $MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES | ||
55 | $ V = 'F$Verify(0) | ||
56 | $! P1 = What we are trying to make | ||
57 | $! P2 = Command to make it | ||
58 | $! P3 - P8 What it depends on | ||
59 | $ | ||
60 | $ If F$Search(P1) .Eqs. "" Then Goto Makeit | ||
61 | $ Time = F$CvTime(F$File(P1,"RDT")) | ||
62 | $arg=3 | ||
63 | $Loop: | ||
64 | $ Argument = P'arg | ||
65 | $ If Argument .Eqs. "" Then Goto Exit | ||
66 | $ El=0 | ||
67 | $Loop2: | ||
68 | $ File = F$Element(El," ",Argument) | ||
69 | $ If File .Eqs. " " Then Goto Endl | ||
70 | $ AFile = "" | ||
71 | $Loop3: | ||
72 | $ OFile = AFile | ||
73 | $ AFile = F$Search(File) | ||
74 | $ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl | ||
75 | $ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit | ||
76 | $ Goto Loop3 | ||
77 | $NextEL: | ||
78 | $ El = El + 1 | ||
79 | $ Goto Loop2 | ||
80 | $EndL: | ||
81 | $ arg=arg+1 | ||
82 | $ If arg .Le. 8 Then Goto Loop | ||
83 | $ Goto Exit | ||
84 | $ | ||
85 | $Makeit: | ||
86 | $ VV=F$VERIFY(0) | ||
87 | $ write sys$output P2 | ||
88 | $ 'P2 | ||
89 | $ VV='F$Verify(VV) | ||
90 | $Exit: | ||
91 | $ If V Then Set Verify | ||
92 | $ENDSUBROUTINE | ||
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/png2pnm.bat b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/png2pnm.bat new file mode 100644 index 0000000..85abe3c --- /dev/null +++ b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/png2pnm.bat | |||
@@ -0,0 +1,41 @@ | |||
1 | REM -- grayscale | ||
2 | png2pnm.exe -noraw ..\pngsuite\basn0g01.png basn0g01.pgm | ||
3 | png2pnm.exe -noraw ..\pngsuite\basn0g02.png basn0g02.pgm | ||
4 | png2pnm.exe -noraw ..\pngsuite\basn0g04.png basn0g04.pgm | ||
5 | png2pnm.exe -noraw ..\pngsuite\basn0g08.png basn0g08.pgm | ||
6 | png2pnm.exe -noraw ..\pngsuite\basn0g16.png basn0g16.pgm | ||
7 | REM -- full-color | ||
8 | png2pnm.exe -noraw ..\pngsuite\basn2c08.png basn2c08.ppm | ||
9 | png2pnm.exe -noraw ..\pngsuite\basn2c16.png basn2c16.ppm | ||
10 | REM -- palletted | ||
11 | png2pnm.exe -noraw ..\pngsuite\basn3p01.png basn3p01.ppm | ||
12 | png2pnm.exe -noraw ..\pngsuite\basn3p02.png basn3p02.ppm | ||
13 | png2pnm.exe -noraw ..\pngsuite\basn3p04.png basn3p04.ppm | ||
14 | png2pnm.exe -noraw ..\pngsuite\basn3p08.png basn3p08.ppm | ||
15 | REM -- gray with alpha-channel | ||
16 | png2pnm.exe -noraw ..\pngsuite\basn4a08.png basn4a08.pgm | ||
17 | png2pnm.exe -noraw ..\pngsuite\basn4a16.png basn4a16.pgm | ||
18 | REM -- color with alpha-channel | ||
19 | png2pnm.exe -noraw -alpha basn6a08.pgm ..\pngsuite\basn6a08.png basn6a08.ppm | ||
20 | png2pnm.exe -noraw -alpha basn6a16.pgm ..\pngsuite\basn6a16.png basn6a16.ppm | ||
21 | REM -- grayscale | ||
22 | png2pnm.exe -raw ..\pngsuite\basn0g01.png rawn0g01.pgm | ||
23 | png2pnm.exe -raw ..\pngsuite\basn0g02.png rawn0g02.pgm | ||
24 | png2pnm.exe -raw ..\pngsuite\basn0g04.png rawn0g04.pgm | ||
25 | png2pnm.exe -raw ..\pngsuite\basn0g08.png rawn0g08.pgm | ||
26 | png2pnm.exe -raw ..\pngsuite\basn0g16.png rawn0g16.pgm | ||
27 | REM -- full-color | ||
28 | png2pnm.exe -raw ..\pngsuite\basn2c08.png rawn2c08.ppm | ||
29 | png2pnm.exe -raw ..\pngsuite\basn2c16.png rawn2c16.ppm | ||
30 | REM -- palletted | ||
31 | png2pnm.exe -raw ..\pngsuite\basn3p01.png rawn3p01.ppm | ||
32 | png2pnm.exe -raw ..\pngsuite\basn3p02.png rawn3p02.ppm | ||
33 | png2pnm.exe -raw ..\pngsuite\basn3p04.png rawn3p04.ppm | ||
34 | png2pnm.exe -raw ..\pngsuite\basn3p08.png rawn3p08.ppm | ||
35 | REM -- gray with alpha-channel | ||
36 | png2pnm.exe -raw ..\pngsuite\basn4a08.png rawn4a08.pgm | ||
37 | png2pnm.exe -raw ..\pngsuite\basn4a16.png rawn4a16.pgm | ||
38 | REM -- color with alpha-channel | ||
39 | png2pnm.exe -noraw -alpha rawn6a08.pgm ..\pngsuite\basn6a08.png rawn6a08.ppm | ||
40 | png2pnm.exe -noraw -alpha rawn6a16.pgm ..\pngsuite\basn6a16.png rawn6a16.ppm | ||
41 | |||
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/png2pnm.c b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/png2pnm.c new file mode 100644 index 0000000..ef28d90 --- /dev/null +++ b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/png2pnm.c | |||
@@ -0,0 +1,430 @@ | |||
1 | /* | ||
2 | * png2pnm.c --- conversion from PNG-file to PGM/PPM-file | ||
3 | * copyright (C) 1999 by Willem van Schaik <willem@schaik.com> | ||
4 | * | ||
5 | * version 1.0 - 1999.10.15 - First version. | ||
6 | * | ||
7 | * Permission to use, copy, modify, and distribute this software and | ||
8 | * its documentation for any purpose and without fee is hereby granted, | ||
9 | * provided that the above copyright notice appear in all copies and | ||
10 | * that both that copyright notice and this permission notice appear in | ||
11 | * supporting documentation. This software is provided "as is" without | ||
12 | * express or implied warranty. | ||
13 | */ | ||
14 | |||
15 | #include <stdio.h> | ||
16 | #include <stdlib.h> | ||
17 | #ifdef __TURBOC__ | ||
18 | #include <mem.h> | ||
19 | #include <fcntl.h> | ||
20 | #endif | ||
21 | |||
22 | #ifndef BOOL | ||
23 | #define BOOL unsigned char | ||
24 | #endif | ||
25 | #ifndef TRUE | ||
26 | #define TRUE (BOOL) 1 | ||
27 | #endif | ||
28 | #ifndef FALSE | ||
29 | #define FALSE (BOOL) 0 | ||
30 | #endif | ||
31 | |||
32 | #ifdef __TURBOC__ | ||
33 | #define STDIN 0 | ||
34 | #define STDOUT 1 | ||
35 | #define STDERR 2 | ||
36 | #endif | ||
37 | |||
38 | /* to make png2pnm verbose so we can find problems (needs to be before png.h) */ | ||
39 | #ifndef PNG_DEBUG | ||
40 | #define PNG_DEBUG 0 | ||
41 | #endif | ||
42 | |||
43 | #include "png.h" | ||
44 | |||
45 | /* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */ | ||
46 | #ifndef png_jmpbuf | ||
47 | # define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) | ||
48 | #endif | ||
49 | |||
50 | /* function prototypes */ | ||
51 | |||
52 | int main (int argc, char *argv[]); | ||
53 | void usage (); | ||
54 | BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha); | ||
55 | |||
56 | /* | ||
57 | * main | ||
58 | */ | ||
59 | |||
60 | int main(int argc, char *argv[]) | ||
61 | { | ||
62 | FILE *fp_rd = stdin; | ||
63 | FILE *fp_wr = stdout; | ||
64 | FILE *fp_al = NULL; | ||
65 | BOOL raw = TRUE; | ||
66 | BOOL alpha = FALSE; | ||
67 | int argi; | ||
68 | |||
69 | for (argi = 1; argi < argc; argi++) | ||
70 | { | ||
71 | if (argv[argi][0] == '-') | ||
72 | { | ||
73 | switch (argv[argi][1]) | ||
74 | { | ||
75 | case 'n': | ||
76 | raw = FALSE; | ||
77 | break; | ||
78 | case 'r': | ||
79 | raw = TRUE; | ||
80 | break; | ||
81 | case 'a': | ||
82 | alpha = TRUE; | ||
83 | argi++; | ||
84 | if ((fp_al = fopen (argv[argi], "wb")) == NULL) | ||
85 | { | ||
86 | fprintf (stderr, "PNM2PNG\n"); | ||
87 | fprintf (stderr, "Error: can not create alpha-channel file %s\n", argv[argi]); | ||
88 | exit (1); | ||
89 | } | ||
90 | break; | ||
91 | case 'h': | ||
92 | case '?': | ||
93 | usage(); | ||
94 | exit(0); | ||
95 | break; | ||
96 | default: | ||
97 | fprintf (stderr, "PNG2PNM\n"); | ||
98 | fprintf (stderr, "Error: unknown option %s\n", argv[argi]); | ||
99 | usage(); | ||
100 | exit(1); | ||
101 | break; | ||
102 | } /* end switch */ | ||
103 | } | ||
104 | else if (fp_rd == stdin) | ||
105 | { | ||
106 | if ((fp_rd = fopen (argv[argi], "rb")) == NULL) | ||
107 | { | ||
108 | fprintf (stderr, "PNG2PNM\n"); | ||
109 | fprintf (stderr, "Error: file %s does not exist\n", argv[argi]); | ||
110 | exit (1); | ||
111 | } | ||
112 | } | ||
113 | else if (fp_wr == stdout) | ||
114 | { | ||
115 | if ((fp_wr = fopen (argv[argi], "wb")) == NULL) | ||
116 | { | ||
117 | fprintf (stderr, "PNG2PNM\n"); | ||
118 | fprintf (stderr, "Error: can not create file %s\n", argv[argi]); | ||
119 | exit (1); | ||
120 | } | ||
121 | } | ||
122 | else | ||
123 | { | ||
124 | fprintf (stderr, "PNG2PNM\n"); | ||
125 | fprintf (stderr, "Error: too many parameters\n"); | ||
126 | usage(); | ||
127 | exit(1); | ||
128 | } | ||
129 | } /* end for */ | ||
130 | |||
131 | #ifdef __TURBOC__ | ||
132 | /* set stdin/stdout if required to binary */ | ||
133 | if (fp_rd == stdin) | ||
134 | { | ||
135 | setmode (STDIN, O_BINARY); | ||
136 | } | ||
137 | if ((raw) && (fp_wr == stdout)) | ||
138 | { | ||
139 | setmode (STDOUT, O_BINARY); | ||
140 | } | ||
141 | #endif | ||
142 | |||
143 | /* call the conversion program itself */ | ||
144 | if (png2pnm (fp_rd, fp_wr, fp_al, raw, alpha) == FALSE) | ||
145 | { | ||
146 | fprintf (stderr, "PNG2PNM\n"); | ||
147 | fprintf (stderr, "Error: unsuccessful conversion of PNG-image\n"); | ||
148 | exit(1); | ||
149 | } | ||
150 | |||
151 | /* close input file */ | ||
152 | fclose (fp_rd); | ||
153 | /* close output file */ | ||
154 | fclose (fp_wr); | ||
155 | /* close alpha file */ | ||
156 | if (alpha) | ||
157 | fclose (fp_al); | ||
158 | |||
159 | return 0; | ||
160 | } | ||
161 | |||
162 | /* | ||
163 | * usage | ||
164 | */ | ||
165 | |||
166 | void usage() | ||
167 | { | ||
168 | fprintf (stderr, "PNG2PNM\n"); | ||
169 | fprintf (stderr, " by Willem van Schaik, 1999\n"); | ||
170 | #ifdef __TURBOC__ | ||
171 | fprintf (stderr, " for Turbo-C and Borland-C compilers\n"); | ||
172 | #else | ||
173 | fprintf (stderr, " for Linux (and Unix) compilers\n"); | ||
174 | #endif | ||
175 | fprintf (stderr, "Usage: png2pnm [options] <file>.png [<file>.pnm]\n"); | ||
176 | fprintf (stderr, " or: ... | png2pnm [options]\n"); | ||
177 | fprintf (stderr, "Options:\n"); | ||
178 | fprintf (stderr, " -r[aw] write pnm-file in binary format (P4/P5/P6) (default)\n"); | ||
179 | fprintf (stderr, " -n[oraw] write pnm-file in ascii format (P1/P2/P3)\n"); | ||
180 | fprintf (stderr, " -a[lpha] <file>.pgm write PNG alpha channel as pgm-file\n"); | ||
181 | fprintf (stderr, " -h | -? print this help-information\n"); | ||
182 | } | ||
183 | |||
184 | /* | ||
185 | * png2pnm | ||
186 | */ | ||
187 | |||
188 | BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha) | ||
189 | { | ||
190 | png_struct *png_ptr = NULL; | ||
191 | png_info *info_ptr = NULL; | ||
192 | png_byte buf[8]; | ||
193 | png_byte *png_pixels = NULL; | ||
194 | png_byte **row_pointers = NULL; | ||
195 | png_byte *pix_ptr = NULL; | ||
196 | png_uint_32 row_bytes; | ||
197 | |||
198 | png_uint_32 width; | ||
199 | png_uint_32 height; | ||
200 | int bit_depth; | ||
201 | int channels; | ||
202 | int color_type; | ||
203 | int alpha_present; | ||
204 | int row, col; | ||
205 | int ret; | ||
206 | int i; | ||
207 | long dep_16; | ||
208 | |||
209 | /* read and check signature in PNG file */ | ||
210 | ret = fread (buf, 1, 8, png_file); | ||
211 | if (ret != 8) | ||
212 | return FALSE; | ||
213 | |||
214 | ret = png_sig_cmp (buf, 0, 8); | ||
215 | if (ret) | ||
216 | return FALSE; | ||
217 | |||
218 | /* create png and info structures */ | ||
219 | |||
220 | png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, | ||
221 | NULL, NULL, NULL); | ||
222 | if (!png_ptr) | ||
223 | return FALSE; /* out of memory */ | ||
224 | |||
225 | info_ptr = png_create_info_struct (png_ptr); | ||
226 | if (!info_ptr) | ||
227 | { | ||
228 | png_destroy_read_struct (&png_ptr, NULL, NULL); | ||
229 | return FALSE; /* out of memory */ | ||
230 | } | ||
231 | |||
232 | if (setjmp (png_jmpbuf(png_ptr))) | ||
233 | { | ||
234 | png_destroy_read_struct (&png_ptr, &info_ptr, NULL); | ||
235 | return FALSE; | ||
236 | } | ||
237 | |||
238 | /* set up the input control for C streams */ | ||
239 | png_init_io (png_ptr, png_file); | ||
240 | png_set_sig_bytes (png_ptr, 8); /* we already read the 8 signature bytes */ | ||
241 | |||
242 | /* read the file information */ | ||
243 | png_read_info (png_ptr, info_ptr); | ||
244 | |||
245 | /* get size and bit-depth of the PNG-image */ | ||
246 | png_get_IHDR (png_ptr, info_ptr, | ||
247 | &width, &height, &bit_depth, &color_type, | ||
248 | NULL, NULL, NULL); | ||
249 | |||
250 | /* set-up the transformations */ | ||
251 | |||
252 | /* transform paletted images into full-color rgb */ | ||
253 | if (color_type == PNG_COLOR_TYPE_PALETTE) | ||
254 | png_set_expand (png_ptr); | ||
255 | /* expand images to bit-depth 8 (only applicable for grayscale images) */ | ||
256 | if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) | ||
257 | png_set_expand (png_ptr); | ||
258 | /* transform transparency maps into full alpha-channel */ | ||
259 | if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) | ||
260 | png_set_expand (png_ptr); | ||
261 | |||
262 | #ifdef NJET | ||
263 | /* downgrade 16-bit images to 8 bit */ | ||
264 | if (bit_depth == 16) | ||
265 | png_set_strip_16 (png_ptr); | ||
266 | /* transform grayscale images into full-color */ | ||
267 | if (color_type == PNG_COLOR_TYPE_GRAY || | ||
268 | color_type == PNG_COLOR_TYPE_GRAY_ALPHA) | ||
269 | png_set_gray_to_rgb (png_ptr); | ||
270 | /* only if file has a file gamma, we do a correction */ | ||
271 | if (png_get_gAMA (png_ptr, info_ptr, &file_gamma)) | ||
272 | png_set_gamma (png_ptr, (double) 2.2, file_gamma); | ||
273 | #endif | ||
274 | |||
275 | /* all transformations have been registered; now update info_ptr data, | ||
276 | * get rowbytes and channels, and allocate image memory */ | ||
277 | |||
278 | png_read_update_info (png_ptr, info_ptr); | ||
279 | |||
280 | /* get the new color-type and bit-depth (after expansion/stripping) */ | ||
281 | png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, | ||
282 | NULL, NULL, NULL); | ||
283 | |||
284 | /* check for 16-bit files */ | ||
285 | if (bit_depth == 16) | ||
286 | { | ||
287 | raw = FALSE; | ||
288 | #ifdef __TURBOC__ | ||
289 | pnm_file->flags &= ~((unsigned) _F_BIN); | ||
290 | #endif | ||
291 | } | ||
292 | |||
293 | /* calculate new number of channels and store alpha-presence */ | ||
294 | if (color_type == PNG_COLOR_TYPE_GRAY) | ||
295 | channels = 1; | ||
296 | else if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA) | ||
297 | channels = 2; | ||
298 | else if (color_type == PNG_COLOR_TYPE_RGB) | ||
299 | channels = 3; | ||
300 | else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) | ||
301 | channels = 4; | ||
302 | else | ||
303 | channels = 0; /* should never happen */ | ||
304 | alpha_present = (channels - 1) % 2; | ||
305 | |||
306 | /* check if alpha is expected to be present in file */ | ||
307 | if (alpha && !alpha_present) | ||
308 | { | ||
309 | fprintf (stderr, "PNG2PNM\n"); | ||
310 | fprintf (stderr, "Error: PNG-file doesn't contain alpha channel\n"); | ||
311 | exit (1); | ||
312 | } | ||
313 | |||
314 | /* row_bytes is the width x number of channels x (bit-depth / 8) */ | ||
315 | row_bytes = png_get_rowbytes (png_ptr, info_ptr); | ||
316 | |||
317 | if ((png_pixels = (png_byte *) malloc (row_bytes * height * sizeof (png_byte))) == NULL) { | ||
318 | png_destroy_read_struct (&png_ptr, &info_ptr, NULL); | ||
319 | return FALSE; | ||
320 | } | ||
321 | |||
322 | if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL) | ||
323 | { | ||
324 | png_destroy_read_struct (&png_ptr, &info_ptr, NULL); | ||
325 | free (png_pixels); | ||
326 | png_pixels = NULL; | ||
327 | return FALSE; | ||
328 | } | ||
329 | |||
330 | /* set the individual row_pointers to point at the correct offsets */ | ||
331 | for (i = 0; i < (height); i++) | ||
332 | row_pointers[i] = png_pixels + i * row_bytes; | ||
333 | |||
334 | /* now we can go ahead and just read the whole image */ | ||
335 | png_read_image (png_ptr, row_pointers); | ||
336 | |||
337 | /* read rest of file, and get additional chunks in info_ptr - REQUIRED */ | ||
338 | png_read_end (png_ptr, info_ptr); | ||
339 | |||
340 | /* clean up after the read, and free any memory allocated - REQUIRED */ | ||
341 | png_destroy_read_struct (&png_ptr, &info_ptr, (png_infopp) NULL); | ||
342 | |||
343 | /* write header of PNM file */ | ||
344 | |||
345 | if ((color_type == PNG_COLOR_TYPE_GRAY) || | ||
346 | (color_type == PNG_COLOR_TYPE_GRAY_ALPHA)) | ||
347 | { | ||
348 | fprintf (pnm_file, "%s\n", (raw) ? "P5" : "P2"); | ||
349 | fprintf (pnm_file, "%d %d\n", (int) width, (int) height); | ||
350 | fprintf (pnm_file, "%ld\n", ((1L << (int) bit_depth) - 1L)); | ||
351 | } | ||
352 | else if ((color_type == PNG_COLOR_TYPE_RGB) || | ||
353 | (color_type == PNG_COLOR_TYPE_RGB_ALPHA)) | ||
354 | { | ||
355 | fprintf (pnm_file, "%s\n", (raw) ? "P6" : "P3"); | ||
356 | fprintf (pnm_file, "%d %d\n", (int) width, (int) height); | ||
357 | fprintf (pnm_file, "%ld\n", ((1L << (int) bit_depth) - 1L)); | ||
358 | } | ||
359 | |||
360 | /* write header of PGM file with alpha channel */ | ||
361 | |||
362 | if ((alpha) && | ||
363 | ((color_type == PNG_COLOR_TYPE_GRAY_ALPHA) || | ||
364 | (color_type == PNG_COLOR_TYPE_RGB_ALPHA))) | ||
365 | { | ||
366 | fprintf (alpha_file, "%s\n", (raw) ? "P5" : "P2"); | ||
367 | fprintf (alpha_file, "%d %d\n", (int) width, (int) height); | ||
368 | fprintf (alpha_file, "%ld\n", ((1L << (int) bit_depth) - 1L)); | ||
369 | } | ||
370 | |||
371 | /* write data to PNM file */ | ||
372 | pix_ptr = png_pixels; | ||
373 | |||
374 | for (row = 0; row < height; row++) | ||
375 | { | ||
376 | for (col = 0; col < width; col++) | ||
377 | { | ||
378 | for (i = 0; i < (channels - alpha_present); i++) | ||
379 | { | ||
380 | if (raw) | ||
381 | fputc ((int) *pix_ptr++ , pnm_file); | ||
382 | else | ||
383 | if (bit_depth == 16){ | ||
384 | dep_16 = (long) *pix_ptr++; | ||
385 | fprintf (pnm_file, "%ld ", (dep_16 << 8) + ((long) *pix_ptr++)); | ||
386 | } | ||
387 | else | ||
388 | fprintf (pnm_file, "%ld ", (long) *pix_ptr++); | ||
389 | } | ||
390 | if (alpha_present) | ||
391 | { | ||
392 | if (!alpha) | ||
393 | { | ||
394 | pix_ptr++; /* alpha */ | ||
395 | if (bit_depth == 16) | ||
396 | pix_ptr++; | ||
397 | } | ||
398 | else /* output alpha-channel as pgm file */ | ||
399 | { | ||
400 | if (raw) | ||
401 | fputc ((int) *pix_ptr++ , alpha_file); | ||
402 | else | ||
403 | if (bit_depth == 16){ | ||
404 | dep_16 = (long) *pix_ptr++; | ||
405 | fprintf (alpha_file, "%ld ", (dep_16 << 8) + (long) *pix_ptr++); | ||
406 | } | ||
407 | else | ||
408 | fprintf (alpha_file, "%ld ", (long) *pix_ptr++); | ||
409 | } | ||
410 | } /* if alpha_present */ | ||
411 | |||
412 | if (!raw) | ||
413 | if (col % 4 == 3) | ||
414 | fprintf (pnm_file, "\n"); | ||
415 | } /* end for col */ | ||
416 | |||
417 | if (!raw) | ||
418 | if (col % 4 != 0) | ||
419 | fprintf (pnm_file, "\n"); | ||
420 | } /* end for row */ | ||
421 | |||
422 | if (row_pointers != (unsigned char**) NULL) | ||
423 | free (row_pointers); | ||
424 | if (png_pixels != (unsigned char*) NULL) | ||
425 | free (png_pixels); | ||
426 | |||
427 | return TRUE; | ||
428 | |||
429 | } /* end of source */ | ||
430 | |||
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/png2pnm.sh b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/png2pnm.sh new file mode 100755 index 0000000..ee39664 --- /dev/null +++ b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/png2pnm.sh | |||
@@ -0,0 +1,42 @@ | |||
1 | #!/bin/sh | ||
2 | # -- grayscale | ||
3 | ./png2pnm -noraw ../pngsuite/basn0g01.png basn0g01.pgm | ||
4 | ./png2pnm -noraw ../pngsuite/basn0g02.png basn0g02.pgm | ||
5 | ./png2pnm -noraw ../pngsuite/basn0g04.png basn0g04.pgm | ||
6 | ./png2pnm -noraw ../pngsuite/basn0g08.png basn0g08.pgm | ||
7 | ./png2pnm -noraw ../pngsuite/basn0g16.png basn0g16.pgm | ||
8 | # -- full-color | ||
9 | ./png2pnm -noraw ../pngsuite/basn2c08.png basn2c08.ppm | ||
10 | ./png2pnm -noraw ../pngsuite/basn2c16.png basn2c16.ppm | ||
11 | # -- palletted | ||
12 | ./png2pnm -noraw ../pngsuite/basn3p01.png basn3p01.ppm | ||
13 | ./png2pnm -noraw ../pngsuite/basn3p02.png basn3p02.ppm | ||
14 | ./png2pnm -noraw ../pngsuite/basn3p04.png basn3p04.ppm | ||
15 | ./png2pnm -noraw ../pngsuite/basn3p08.png basn3p08.ppm | ||
16 | # -- gray with alpha-channel | ||
17 | ./png2pnm -noraw ../pngsuite/basn4a08.png basn4a08.pgm | ||
18 | ./png2pnm -noraw ../pngsuite/basn4a16.png basn4a16.pgm | ||
19 | # -- color with alpha-channel | ||
20 | ./png2pnm -noraw -alpha basn6a08.pgm ../pngsuite/basn6a08.png basn6a08.ppm | ||
21 | ./png2pnm -noraw -alpha basn6a16.pgm ../pngsuite/basn6a16.png basn6a16.ppm | ||
22 | # -- grayscale | ||
23 | ./png2pnm -raw ../pngsuite/basn0g01.png rawn0g01.pgm | ||
24 | ./png2pnm -raw ../pngsuite/basn0g02.png rawn0g02.pgm | ||
25 | ./png2pnm -raw ../pngsuite/basn0g04.png rawn0g04.pgm | ||
26 | ./png2pnm -raw ../pngsuite/basn0g08.png rawn0g08.pgm | ||
27 | ./png2pnm -raw ../pngsuite/basn0g16.png rawn0g16.pgm | ||
28 | # -- full-color | ||
29 | ./png2pnm -raw ../pngsuite/basn2c08.png rawn2c08.ppm | ||
30 | ./png2pnm -raw ../pngsuite/basn2c16.png rawn2c16.ppm | ||
31 | # -- palletted | ||
32 | ./png2pnm -raw ../pngsuite/basn3p01.png rawn3p01.ppm | ||
33 | ./png2pnm -raw ../pngsuite/basn3p02.png rawn3p02.ppm | ||
34 | ./png2pnm -raw ../pngsuite/basn3p04.png rawn3p04.ppm | ||
35 | ./png2pnm -raw ../pngsuite/basn3p08.png rawn3p08.ppm | ||
36 | # -- gray with alpha-channel | ||
37 | ./png2pnm -raw ../pngsuite/basn4a08.png rawn4a08.pgm | ||
38 | ./png2pnm -raw ../pngsuite/basn4a16.png rawn4a16.pgm | ||
39 | # -- color with alpha-channel | ||
40 | ./png2pnm -noraw -alpha rawn6a08.pgm ../pngsuite/basn6a08.png rawn6a08.ppm | ||
41 | ./png2pnm -noraw -alpha rawn6a16.pgm ../pngsuite/basn6a16.png rawn6a16.ppm | ||
42 | |||
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/pngminus.bat b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/pngminus.bat new file mode 100644 index 0000000..5f8d2d4 --- /dev/null +++ b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/pngminus.bat | |||
@@ -0,0 +1,4 @@ | |||
1 | make -f makefile.tc3 | ||
2 | call png2pnm.bat | ||
3 | call pnm2png.bat | ||
4 | |||
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/pngminus.sh b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/pngminus.sh new file mode 100755 index 0000000..adcef55 --- /dev/null +++ b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/pngminus.sh | |||
@@ -0,0 +1,5 @@ | |||
1 | #!/bin/sh | ||
2 | make -f makefile.std | ||
3 | sh png2pnm.sh | ||
4 | sh pnm2png.sh | ||
5 | |||
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/pnm2png.bat b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/pnm2png.bat new file mode 100644 index 0000000..5b9977a --- /dev/null +++ b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/pnm2png.bat | |||
@@ -0,0 +1,41 @@ | |||
1 | REM -- grayscale | ||
2 | pnm2png.exe basn0g01.pgm basn0g01.png | ||
3 | pnm2png.exe basn0g02.pgm basn0g02.png | ||
4 | pnm2png.exe basn0g04.pgm basn0g04.png | ||
5 | pnm2png.exe basn0g08.pgm basn0g08.png | ||
6 | pnm2png.exe basn0g16.pgm basn0g16.png | ||
7 | REM -- full-color | ||
8 | pnm2png.exe basn2c08.ppm basn2c08.png | ||
9 | pnm2png.exe basn2c16.ppm basn2c16.png | ||
10 | REM -- palletted | ||
11 | pnm2png.exe basn3p01.ppm basn3p01.png | ||
12 | pnm2png.exe basn3p02.ppm basn3p02.png | ||
13 | pnm2png.exe basn3p04.ppm basn3p04.png | ||
14 | pnm2png.exe basn3p08.ppm basn3p08.png | ||
15 | REM -- gray with alpha-channel | ||
16 | pnm2png.exe -alpha basn6a08.pgm basn4a08.pgm basn4a08.png | ||
17 | pnm2png.exe -alpha basn6a16.pgm basn4a16.pgm basn4a16.png | ||
18 | REM -- color with alpha-channel | ||
19 | pnm2png.exe -alpha basn6a08.pgm basn6a08.ppm basn6a08.png | ||
20 | pnm2png.exe -alpha basn6a16.pgm basn6a16.ppm basn6a16.png | ||
21 | REM -- grayscale | ||
22 | pnm2png.exe rawn0g01.pgm rawn0g01.png | ||
23 | pnm2png.exe rawn0g02.pgm rawn0g02.png | ||
24 | pnm2png.exe rawn0g04.pgm rawn0g04.png | ||
25 | pnm2png.exe rawn0g08.pgm rawn0g08.png | ||
26 | pnm2png.exe rawn0g16.pgm rawn0g16.png | ||
27 | REM -- full-color | ||
28 | pnm2png.exe rawn2c08.ppm rawn2c08.png | ||
29 | pnm2png.exe rawn2c16.ppm rawn2c16.png | ||
30 | REM -- palletted | ||
31 | pnm2png.exe rawn3p01.ppm rawn3p01.png | ||
32 | pnm2png.exe rawn3p02.ppm rawn3p02.png | ||
33 | pnm2png.exe rawn3p04.ppm rawn3p04.png | ||
34 | pnm2png.exe rawn3p08.ppm rawn3p08.png | ||
35 | REM -- gray with alpha-channel | ||
36 | pnm2png.exe -alpha rawn6a08.pgm rawn4a08.pgm rawn4a08.png | ||
37 | pnm2png.exe -alpha rawn6a16.pgm rawn4a16.pgm rawn4a16.png | ||
38 | REM -- color with alpha-channel | ||
39 | pnm2png.exe -alpha rawn6a08.pgm rawn6a08.ppm rawn6a08.png | ||
40 | pnm2png.exe -alpha rawn6a16.pgm rawn6a16.ppm rawn6a16.png | ||
41 | |||
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/pnm2png.c b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/pnm2png.c new file mode 100644 index 0000000..2f321cc --- /dev/null +++ b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/pnm2png.c | |||
@@ -0,0 +1,533 @@ | |||
1 | /* | ||
2 | * pnm2png.c --- conversion from PBM/PGM/PPM-file to PNG-file | ||
3 | * copyright (C) 1999 by Willem van Schaik <willem@schaik.com> | ||
4 | * | ||
5 | * version 1.0 - 1999.10.15 - First version. | ||
6 | * | ||
7 | * Permission to use, copy, modify, and distribute this software and | ||
8 | * its documentation for any purpose and without fee is hereby granted, | ||
9 | * provided that the above copyright notice appear in all copies and | ||
10 | * that both that copyright notice and this permission notice appear in | ||
11 | * supporting documentation. This software is provided "as is" without | ||
12 | * express or implied warranty. | ||
13 | */ | ||
14 | |||
15 | #include <stdio.h> | ||
16 | #include <stdlib.h> | ||
17 | #ifdef __TURBOC__ | ||
18 | #include <mem.h> | ||
19 | #include <fcntl.h> | ||
20 | #endif | ||
21 | |||
22 | #ifndef BOOL | ||
23 | #define BOOL unsigned char | ||
24 | #endif | ||
25 | #ifndef TRUE | ||
26 | #define TRUE (BOOL) 1 | ||
27 | #endif | ||
28 | #ifndef FALSE | ||
29 | #define FALSE (BOOL) 0 | ||
30 | #endif | ||
31 | |||
32 | #define STDIN 0 | ||
33 | #define STDOUT 1 | ||
34 | #define STDERR 2 | ||
35 | |||
36 | /* to make pnm2png verbose so we can find problems (needs to be before png.h) */ | ||
37 | #ifndef PNG_DEBUG | ||
38 | #define PNG_DEBUG 0 | ||
39 | #endif | ||
40 | |||
41 | #include "png.h" | ||
42 | |||
43 | /* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */ | ||
44 | #ifndef png_jmpbuf | ||
45 | # define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) | ||
46 | #endif | ||
47 | |||
48 | /* function prototypes */ | ||
49 | |||
50 | int main (int argc, char *argv[]); | ||
51 | void usage (); | ||
52 | BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, BOOL alpha); | ||
53 | void get_token(FILE *pnm_file, char *token); | ||
54 | png_uint_32 get_data (FILE *pnm_file, int depth); | ||
55 | png_uint_32 get_value (FILE *pnm_file, int depth); | ||
56 | |||
57 | /* | ||
58 | * main | ||
59 | */ | ||
60 | |||
61 | int main(int argc, char *argv[]) | ||
62 | { | ||
63 | FILE *fp_rd = stdin; | ||
64 | FILE *fp_al = NULL; | ||
65 | FILE *fp_wr = stdout; | ||
66 | BOOL interlace = FALSE; | ||
67 | BOOL alpha = FALSE; | ||
68 | int argi; | ||
69 | |||
70 | for (argi = 1; argi < argc; argi++) | ||
71 | { | ||
72 | if (argv[argi][0] == '-') | ||
73 | { | ||
74 | switch (argv[argi][1]) | ||
75 | { | ||
76 | case 'i': | ||
77 | interlace = TRUE; | ||
78 | break; | ||
79 | case 'a': | ||
80 | alpha = TRUE; | ||
81 | argi++; | ||
82 | if ((fp_al = fopen (argv[argi], "rb")) == NULL) | ||
83 | { | ||
84 | fprintf (stderr, "PNM2PNG\n"); | ||
85 | fprintf (stderr, "Error: alpha-channel file %s does not exist\n", | ||
86 | argv[argi]); | ||
87 | exit (1); | ||
88 | } | ||
89 | break; | ||
90 | case 'h': | ||
91 | case '?': | ||
92 | usage(); | ||
93 | exit(0); | ||
94 | break; | ||
95 | default: | ||
96 | fprintf (stderr, "PNM2PNG\n"); | ||
97 | fprintf (stderr, "Error: unknown option %s\n", argv[argi]); | ||
98 | usage(); | ||
99 | exit(1); | ||
100 | break; | ||
101 | } /* end switch */ | ||
102 | } | ||
103 | else if (fp_rd == stdin) | ||
104 | { | ||
105 | if ((fp_rd = fopen (argv[argi], "rb")) == NULL) | ||
106 | { | ||
107 | fprintf (stderr, "PNM2PNG\n"); | ||
108 | fprintf (stderr, "Error: file %s does not exist\n", argv[argi]); | ||
109 | exit (1); | ||
110 | } | ||
111 | } | ||
112 | else if (fp_wr == stdout) | ||
113 | { | ||
114 | if ((fp_wr = fopen (argv[argi], "wb")) == NULL) | ||
115 | { | ||
116 | fprintf (stderr, "PNM2PNG\n"); | ||
117 | fprintf (stderr, "Error: can not create PNG-file %s\n", argv[argi]); | ||
118 | exit (1); | ||
119 | } | ||
120 | } | ||
121 | else | ||
122 | { | ||
123 | fprintf (stderr, "PNM2PNG\n"); | ||
124 | fprintf (stderr, "Error: too many parameters\n"); | ||
125 | usage(); | ||
126 | exit (1); | ||
127 | } | ||
128 | } /* end for */ | ||
129 | |||
130 | #ifdef __TURBOC__ | ||
131 | /* set stdin/stdout to binary, we're reading the PNM always! in binary format */ | ||
132 | if (fp_rd == stdin) | ||
133 | { | ||
134 | setmode (STDIN, O_BINARY); | ||
135 | } | ||
136 | if (fp_wr == stdout) | ||
137 | { | ||
138 | setmode (STDOUT, O_BINARY); | ||
139 | } | ||
140 | #endif | ||
141 | |||
142 | /* call the conversion program itself */ | ||
143 | if (pnm2png (fp_rd, fp_wr, fp_al, interlace, alpha) == FALSE) | ||
144 | { | ||
145 | fprintf (stderr, "PNM2PNG\n"); | ||
146 | fprintf (stderr, "Error: unsuccessful converting to PNG-image\n"); | ||
147 | exit (1); | ||
148 | } | ||
149 | |||
150 | /* close input file */ | ||
151 | fclose (fp_rd); | ||
152 | /* close output file */ | ||
153 | fclose (fp_wr); | ||
154 | /* close alpha file */ | ||
155 | if (alpha) | ||
156 | fclose (fp_al); | ||
157 | |||
158 | return 0; | ||
159 | } | ||
160 | |||
161 | /* | ||
162 | * usage | ||
163 | */ | ||
164 | |||
165 | void usage() | ||
166 | { | ||
167 | fprintf (stderr, "PNM2PNG\n"); | ||
168 | fprintf (stderr, " by Willem van Schaik, 1999\n"); | ||
169 | #ifdef __TURBOC__ | ||
170 | fprintf (stderr, " for Turbo-C and Borland-C compilers\n"); | ||
171 | #else | ||
172 | fprintf (stderr, " for Linux (and Unix) compilers\n"); | ||
173 | #endif | ||
174 | fprintf (stderr, "Usage: pnm2png [options] <file>.<pnm> [<file>.png]\n"); | ||
175 | fprintf (stderr, " or: ... | pnm2png [options]\n"); | ||
176 | fprintf (stderr, "Options:\n"); | ||
177 | fprintf (stderr, " -i[nterlace] write png-file with interlacing on\n"); | ||
178 | fprintf (stderr, " -a[lpha] <file>.pgm read PNG alpha channel as pgm-file\n"); | ||
179 | fprintf (stderr, " -h | -? print this help-information\n"); | ||
180 | } | ||
181 | |||
182 | /* | ||
183 | * pnm2png | ||
184 | */ | ||
185 | |||
186 | BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, BOOL alpha) | ||
187 | { | ||
188 | png_struct *png_ptr = NULL; | ||
189 | png_info *info_ptr = NULL; | ||
190 | png_byte *png_pixels = NULL; | ||
191 | png_byte **row_pointers = NULL; | ||
192 | png_byte *pix_ptr = NULL; | ||
193 | png_uint_32 row_bytes; | ||
194 | |||
195 | char type_token[16]; | ||
196 | char width_token[16]; | ||
197 | char height_token[16]; | ||
198 | char maxval_token[16]; | ||
199 | int color_type; | ||
200 | png_uint_32 width, alpha_width; | ||
201 | png_uint_32 height, alpha_height; | ||
202 | png_uint_32 maxval; | ||
203 | int bit_depth = 0; | ||
204 | int channels; | ||
205 | int alpha_depth = 0; | ||
206 | int alpha_present; | ||
207 | int row, col; | ||
208 | BOOL raw, alpha_raw = FALSE; | ||
209 | png_uint_32 tmp16; | ||
210 | int i; | ||
211 | |||
212 | /* read header of PNM file */ | ||
213 | |||
214 | get_token(pnm_file, type_token); | ||
215 | if (type_token[0] != 'P') | ||
216 | { | ||
217 | return FALSE; | ||
218 | } | ||
219 | else if ((type_token[1] == '1') || (type_token[1] == '4')) | ||
220 | { | ||
221 | raw = (type_token[1] == '4'); | ||
222 | color_type = PNG_COLOR_TYPE_GRAY; | ||
223 | bit_depth = 1; | ||
224 | } | ||
225 | else if ((type_token[1] == '2') || (type_token[1] == '5')) | ||
226 | { | ||
227 | raw = (type_token[1] == '5'); | ||
228 | color_type = PNG_COLOR_TYPE_GRAY; | ||
229 | get_token(pnm_file, width_token); | ||
230 | sscanf (width_token, "%lu", &width); | ||
231 | get_token(pnm_file, height_token); | ||
232 | sscanf (height_token, "%lu", &height); | ||
233 | get_token(pnm_file, maxval_token); | ||
234 | sscanf (maxval_token, "%lu", &maxval); | ||
235 | if (maxval <= 1) | ||
236 | bit_depth = 1; | ||
237 | else if (maxval <= 3) | ||
238 | bit_depth = 2; | ||
239 | else if (maxval <= 15) | ||
240 | bit_depth = 4; | ||
241 | else if (maxval <= 255) | ||
242 | bit_depth = 8; | ||
243 | else /* if (maxval <= 65535) */ | ||
244 | bit_depth = 16; | ||
245 | } | ||
246 | else if ((type_token[1] == '3') || (type_token[1] == '6')) | ||
247 | { | ||
248 | raw = (type_token[1] == '6'); | ||
249 | color_type = PNG_COLOR_TYPE_RGB; | ||
250 | get_token(pnm_file, width_token); | ||
251 | sscanf (width_token, "%lu", &width); | ||
252 | get_token(pnm_file, height_token); | ||
253 | sscanf (height_token, "%lu", &height); | ||
254 | get_token(pnm_file, maxval_token); | ||
255 | sscanf (maxval_token, "%lu", &maxval); | ||
256 | if (maxval <= 1) | ||
257 | bit_depth = 1; | ||
258 | else if (maxval <= 3) | ||
259 | bit_depth = 2; | ||
260 | else if (maxval <= 15) | ||
261 | bit_depth = 4; | ||
262 | else if (maxval <= 255) | ||
263 | bit_depth = 8; | ||
264 | else /* if (maxval <= 65535) */ | ||
265 | bit_depth = 16; | ||
266 | } | ||
267 | else | ||
268 | { | ||
269 | return FALSE; | ||
270 | } | ||
271 | |||
272 | /* read header of PGM file with alpha channel */ | ||
273 | |||
274 | if (alpha) | ||
275 | { | ||
276 | if (color_type == PNG_COLOR_TYPE_GRAY) | ||
277 | color_type = PNG_COLOR_TYPE_GRAY_ALPHA; | ||
278 | if (color_type == PNG_COLOR_TYPE_RGB) | ||
279 | color_type = PNG_COLOR_TYPE_RGB_ALPHA; | ||
280 | |||
281 | get_token(alpha_file, type_token); | ||
282 | if (type_token[0] != 'P') | ||
283 | { | ||
284 | return FALSE; | ||
285 | } | ||
286 | else if ((type_token[1] == '2') || (type_token[1] == '5')) | ||
287 | { | ||
288 | alpha_raw = (type_token[1] == '5'); | ||
289 | get_token(alpha_file, width_token); | ||
290 | sscanf (width_token, "%lu", &alpha_width); | ||
291 | if (alpha_width != width) | ||
292 | return FALSE; | ||
293 | get_token(alpha_file, height_token); | ||
294 | sscanf (height_token, "%lu", &alpha_height); | ||
295 | if (alpha_height != height) | ||
296 | return FALSE; | ||
297 | get_token(alpha_file, maxval_token); | ||
298 | sscanf (maxval_token, "%lu", &maxval); | ||
299 | if (maxval <= 1) | ||
300 | alpha_depth = 1; | ||
301 | else if (maxval <= 3) | ||
302 | alpha_depth = 2; | ||
303 | else if (maxval <= 15) | ||
304 | alpha_depth = 4; | ||
305 | else if (maxval <= 255) | ||
306 | alpha_depth = 8; | ||
307 | else /* if (maxval <= 65535) */ | ||
308 | alpha_depth = 16; | ||
309 | if (alpha_depth != bit_depth) | ||
310 | return FALSE; | ||
311 | } | ||
312 | else | ||
313 | { | ||
314 | return FALSE; | ||
315 | } | ||
316 | } /* end if alpha */ | ||
317 | |||
318 | /* calculate the number of channels and store alpha-presence */ | ||
319 | if (color_type == PNG_COLOR_TYPE_GRAY) | ||
320 | channels = 1; | ||
321 | else if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA) | ||
322 | channels = 2; | ||
323 | else if (color_type == PNG_COLOR_TYPE_RGB) | ||
324 | channels = 3; | ||
325 | else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) | ||
326 | channels = 4; | ||
327 | else | ||
328 | channels = 0; /* should not happen */ | ||
329 | |||
330 | alpha_present = (channels - 1) % 2; | ||
331 | |||
332 | /* row_bytes is the width x number of channels x (bit-depth / 8) */ | ||
333 | row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2); | ||
334 | |||
335 | if ((png_pixels = (png_byte *) malloc (row_bytes * height * sizeof (png_byte))) == NULL) | ||
336 | return FALSE; | ||
337 | |||
338 | /* read data from PNM file */ | ||
339 | pix_ptr = png_pixels; | ||
340 | |||
341 | for (row = 0; row < height; row++) | ||
342 | { | ||
343 | for (col = 0; col < width; col++) | ||
344 | { | ||
345 | for (i = 0; i < (channels - alpha_present); i++) | ||
346 | { | ||
347 | if (raw) | ||
348 | *pix_ptr++ = get_data (pnm_file, bit_depth); | ||
349 | else | ||
350 | if (bit_depth <= 8) | ||
351 | *pix_ptr++ = get_value (pnm_file, bit_depth); | ||
352 | else | ||
353 | { | ||
354 | tmp16 = get_value (pnm_file, bit_depth); | ||
355 | *pix_ptr = (png_byte) ((tmp16 >> 8) & 0xFF); | ||
356 | pix_ptr++; | ||
357 | *pix_ptr = (png_byte) (tmp16 & 0xFF); | ||
358 | pix_ptr++; | ||
359 | } | ||
360 | } | ||
361 | |||
362 | if (alpha) /* read alpha-channel from pgm file */ | ||
363 | { | ||
364 | if (alpha_raw) | ||
365 | *pix_ptr++ = get_data (alpha_file, alpha_depth); | ||
366 | else | ||
367 | if (alpha_depth <= 8) | ||
368 | *pix_ptr++ = get_value (alpha_file, bit_depth); | ||
369 | else | ||
370 | { | ||
371 | tmp16 = get_value (alpha_file, bit_depth); | ||
372 | *pix_ptr++ = (png_byte) ((tmp16 >> 8) & 0xFF); | ||
373 | *pix_ptr++ = (png_byte) (tmp16 & 0xFF); | ||
374 | } | ||
375 | } /* if alpha */ | ||
376 | |||
377 | } /* end for col */ | ||
378 | } /* end for row */ | ||
379 | |||
380 | /* prepare the standard PNG structures */ | ||
381 | png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); | ||
382 | if (!png_ptr) | ||
383 | { | ||
384 | return FALSE; | ||
385 | } | ||
386 | info_ptr = png_create_info_struct (png_ptr); | ||
387 | if (!info_ptr) | ||
388 | { | ||
389 | png_destroy_write_struct (&png_ptr, (png_infopp) NULL); | ||
390 | return FALSE; | ||
391 | } | ||
392 | |||
393 | /* setjmp() must be called in every function that calls a PNG-reading libpng function */ | ||
394 | if (setjmp (png_jmpbuf(png_ptr))) | ||
395 | { | ||
396 | png_destroy_write_struct (&png_ptr, (png_infopp) NULL); | ||
397 | return FALSE; | ||
398 | } | ||
399 | |||
400 | /* initialize the png structure */ | ||
401 | png_init_io (png_ptr, png_file); | ||
402 | |||
403 | /* we're going to write more or less the same PNG as the input file */ | ||
404 | png_set_IHDR (png_ptr, info_ptr, width, height, bit_depth, color_type, | ||
405 | (!interlace) ? PNG_INTERLACE_NONE : PNG_INTERLACE_ADAM7, | ||
406 | PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); | ||
407 | |||
408 | /* write the file header information */ | ||
409 | png_write_info (png_ptr, info_ptr); | ||
410 | |||
411 | /* if needed we will allocate memory for an new array of row-pointers */ | ||
412 | if (row_pointers == (unsigned char**) NULL) | ||
413 | { | ||
414 | if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL) | ||
415 | { | ||
416 | png_destroy_write_struct (&png_ptr, (png_infopp) NULL); | ||
417 | return FALSE; | ||
418 | } | ||
419 | } | ||
420 | |||
421 | /* set the individual row_pointers to point at the correct offsets */ | ||
422 | for (i = 0; i < (height); i++) | ||
423 | row_pointers[i] = png_pixels + i * row_bytes; | ||
424 | |||
425 | /* write out the entire image data in one call */ | ||
426 | png_write_image (png_ptr, row_pointers); | ||
427 | |||
428 | /* write the additional chuncks to the PNG file (not really needed) */ | ||
429 | png_write_end (png_ptr, info_ptr); | ||
430 | |||
431 | /* clean up after the write, and free any memory allocated */ | ||
432 | png_destroy_write_struct (&png_ptr, (png_infopp) NULL); | ||
433 | |||
434 | if (row_pointers != (unsigned char**) NULL) | ||
435 | free (row_pointers); | ||
436 | if (png_pixels != (unsigned char*) NULL) | ||
437 | free (png_pixels); | ||
438 | |||
439 | return TRUE; | ||
440 | } /* end of pnm2png */ | ||
441 | |||
442 | /* | ||
443 | * get_token() - gets the first string after whitespace | ||
444 | */ | ||
445 | |||
446 | void get_token(FILE *pnm_file, char *token) | ||
447 | { | ||
448 | int i = 0; | ||
449 | |||
450 | /* remove white-space */ | ||
451 | do | ||
452 | { | ||
453 | token[i] = (unsigned char) fgetc (pnm_file); | ||
454 | } | ||
455 | while ((token[i] == '\n') || (token[i] == '\r') || (token[i] == ' ')); | ||
456 | |||
457 | /* read string */ | ||
458 | do | ||
459 | { | ||
460 | i++; | ||
461 | token[i] = (unsigned char) fgetc (pnm_file); | ||
462 | } | ||
463 | while ((token[i] != '\n') && (token[i] != '\r') && (token[i] != ' ')); | ||
464 | |||
465 | token[i] = '\0'; | ||
466 | |||
467 | return; | ||
468 | } | ||
469 | |||
470 | /* | ||
471 | * get_data() - takes first byte and converts into next pixel value, | ||
472 | * taking as much bits as defined by bit-depth and | ||
473 | * using the bit-depth to fill up a byte (0Ah -> AAh) | ||
474 | */ | ||
475 | |||
476 | png_uint_32 get_data (FILE *pnm_file, int depth) | ||
477 | { | ||
478 | static int bits_left = 0; | ||
479 | static int old_value = 0; | ||
480 | static int mask = 0; | ||
481 | int i; | ||
482 | png_uint_32 ret_value; | ||
483 | |||
484 | if (mask == 0) | ||
485 | for (i = 0; i < depth; i++) | ||
486 | mask = (mask >> 1) | 0x80; | ||
487 | |||
488 | if (bits_left <= 0) | ||
489 | { | ||
490 | old_value = fgetc (pnm_file); | ||
491 | bits_left = 8; | ||
492 | } | ||
493 | |||
494 | ret_value = old_value & mask; | ||
495 | for (i = 1; i < (8 / depth); i++) | ||
496 | ret_value = ret_value || (ret_value >> depth); | ||
497 | |||
498 | old_value = (old_value << depth) & 0xFF; | ||
499 | bits_left -= depth; | ||
500 | |||
501 | return ret_value; | ||
502 | } | ||
503 | |||
504 | /* | ||
505 | * get_value() - takes first (numeric) string and converts into number, | ||
506 | * using the bit-depth to fill up a byte (0Ah -> AAh) | ||
507 | */ | ||
508 | |||
509 | png_uint_32 get_value (FILE *pnm_file, int depth) | ||
510 | { | ||
511 | static png_uint_32 mask = 0; | ||
512 | png_byte token[16]; | ||
513 | png_uint_32 ret_value; | ||
514 | int i = 0; | ||
515 | |||
516 | if (mask == 0) | ||
517 | for (i = 0; i < depth; i++) | ||
518 | mask = (mask << 1) | 0x01; | ||
519 | |||
520 | get_token (pnm_file, (char *) token); | ||
521 | sscanf ((const char *) token, "%lu", &ret_value); | ||
522 | |||
523 | ret_value &= mask; | ||
524 | |||
525 | if (depth < 8) | ||
526 | for (i = 0; i < (8 / depth); i++) | ||
527 | ret_value = (ret_value << depth) || ret_value; | ||
528 | |||
529 | return ret_value; | ||
530 | } | ||
531 | |||
532 | /* end of source */ | ||
533 | |||
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/pnm2png.sh b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/pnm2png.sh new file mode 100755 index 0000000..975f047 --- /dev/null +++ b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/pngminus/pnm2png.sh | |||
@@ -0,0 +1,42 @@ | |||
1 | #!/bin/sh | ||
2 | # -- grayscale | ||
3 | ./pnm2png basn0g01.pgm basn0g01.png | ||
4 | ./pnm2png basn0g02.pgm basn0g02.png | ||
5 | ./pnm2png basn0g04.pgm basn0g04.png | ||
6 | ./pnm2png basn0g08.pgm basn0g08.png | ||
7 | ./pnm2png basn0g16.pgm basn0g16.png | ||
8 | # -- full-color | ||
9 | ./pnm2png basn2c08.ppm basn2c08.png | ||
10 | ./pnm2png basn2c16.ppm basn2c16.png | ||
11 | # -- palletted | ||
12 | ./pnm2png basn3p01.ppm basn3p01.png | ||
13 | ./pnm2png basn3p02.ppm basn3p02.png | ||
14 | ./pnm2png basn3p04.ppm basn3p04.png | ||
15 | ./pnm2png basn3p08.ppm basn3p08.png | ||
16 | # -- gray with alpha-channel | ||
17 | ./pnm2png -alpha basn6a08.pgm basn4a08.pgm basn4a08.png | ||
18 | ./pnm2png -alpha basn6a16.pgm basn4a16.pgm basn4a16.png | ||
19 | # -- color with alpha-channel | ||
20 | ./pnm2png -alpha basn6a08.pgm basn6a08.ppm basn6a08.png | ||
21 | ./pnm2png -alpha basn6a16.pgm basn6a16.ppm basn6a16.png | ||
22 | # -- grayscale | ||
23 | ./pnm2png rawn0g01.pgm rawn0g01.png | ||
24 | ./pnm2png rawn0g02.pgm rawn0g02.png | ||
25 | ./pnm2png rawn0g04.pgm rawn0g04.png | ||
26 | ./pnm2png rawn0g08.pgm rawn0g08.png | ||
27 | ./pnm2png rawn0g16.pgm rawn0g16.png | ||
28 | # -- full-color | ||
29 | ./pnm2png rawn2c08.ppm rawn2c08.png | ||
30 | ./pnm2png rawn2c16.ppm rawn2c16.png | ||
31 | # -- palletted | ||
32 | ./pnm2png rawn3p01.ppm rawn3p01.png | ||
33 | ./pnm2png rawn3p02.ppm rawn3p02.png | ||
34 | ./pnm2png rawn3p04.ppm rawn3p04.png | ||
35 | ./pnm2png rawn3p08.ppm rawn3p08.png | ||
36 | # -- gray with alpha-channel | ||
37 | ./pnm2png -alpha rawn6a08.pgm rawn4a08.pgm rawn4a08.png | ||
38 | ./pnm2png -alpha rawn6a16.pgm rawn4a16.pgm rawn4a16.png | ||
39 | # -- color with alpha-channel | ||
40 | ./pnm2png -alpha rawn6a08.pgm rawn6a08.ppm rawn6a08.png | ||
41 | ./pnm2png -alpha rawn6a16.pgm rawn6a16.ppm rawn6a16.png | ||
42 | |||