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