diff options
author | David Walter Seikel | 2013-01-13 17:24:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2013-01-13 17:24:39 +1000 |
commit | 393b5cd1dc438872af89d334ef6e5fcc59f27d47 (patch) | |
tree | 6a14521219942a08a1b95cb2f5a923a9edd60f63 /libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng | |
parent | Add a note about rasters suggested start up code. (diff) | |
download | SledjHamr-393b5cd1dc438872af89d334ef6e5fcc59f27d47.zip SledjHamr-393b5cd1dc438872af89d334ef6e5fcc59f27d47.tar.gz SledjHamr-393b5cd1dc438872af89d334ef6e5fcc59f27d47.tar.bz2 SledjHamr-393b5cd1dc438872af89d334ef6e5fcc59f27d47.tar.xz |
Added Irrlicht 1.8, but without all the Windows binaries.
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng')
9 files changed, 1933 insertions, 0 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/PngFile.c b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/PngFile.c new file mode 100644 index 0000000..f3e440a --- /dev/null +++ b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/PngFile.c | |||
@@ -0,0 +1,450 @@ | |||
1 | /*------------------------------------- | ||
2 | * PNGFILE.C -- Image File Functions | ||
3 | *------------------------------------- | ||
4 | * | ||
5 | * Copyright 2000, Willem van Schaik. | ||
6 | * | ||
7 | * This code is released under the libpng license. | ||
8 | * For conditions of distribution and use, see the disclaimer | ||
9 | * and license in png.h | ||
10 | */ | ||
11 | |||
12 | #include <windows.h> | ||
13 | #include <commdlg.h> | ||
14 | #include <stdio.h> | ||
15 | #include <stdlib.h> | ||
16 | |||
17 | #include "png.h" | ||
18 | #include "pngfile.h" | ||
19 | #include "cexcept.h" | ||
20 | |||
21 | define_exception_type(const char *); | ||
22 | extern struct exception_context the_exception_context[1]; | ||
23 | struct exception_context the_exception_context[1]; | ||
24 | png_const_charp msg; | ||
25 | |||
26 | static OPENFILENAME ofn; | ||
27 | |||
28 | static png_structp png_ptr = NULL; | ||
29 | static png_infop info_ptr = NULL; | ||
30 | |||
31 | |||
32 | /* cexcept interface */ | ||
33 | |||
34 | static void | ||
35 | png_cexcept_error(png_structp png_ptr, png_const_charp msg) | ||
36 | { | ||
37 | if(png_ptr) | ||
38 | ; | ||
39 | #ifdef PNG_CONSOLE_IO_SUPPORTED | ||
40 | fprintf(stderr, "libpng error: %s\n", msg); | ||
41 | #endif | ||
42 | { | ||
43 | Throw msg; | ||
44 | } | ||
45 | } | ||
46 | |||
47 | /* Windows open-file functions */ | ||
48 | |||
49 | void PngFileInitialize (HWND hwnd) | ||
50 | { | ||
51 | static TCHAR szFilter[] = TEXT ("PNG Files (*.PNG)\0*.png\0") | ||
52 | TEXT ("All Files (*.*)\0*.*\0\0"); | ||
53 | |||
54 | ofn.lStructSize = sizeof (OPENFILENAME); | ||
55 | ofn.hwndOwner = hwnd; | ||
56 | ofn.hInstance = NULL; | ||
57 | ofn.lpstrFilter = szFilter; | ||
58 | ofn.lpstrCustomFilter = NULL; | ||
59 | ofn.nMaxCustFilter = 0; | ||
60 | ofn.nFilterIndex = 0; | ||
61 | ofn.lpstrFile = NULL; /* Set in Open and Close functions */ | ||
62 | ofn.nMaxFile = MAX_PATH; | ||
63 | ofn.lpstrFileTitle = NULL; /* Set in Open and Close functions */ | ||
64 | ofn.nMaxFileTitle = MAX_PATH; | ||
65 | ofn.lpstrInitialDir = NULL; | ||
66 | ofn.lpstrTitle = NULL; | ||
67 | ofn.Flags = 0; /* Set in Open and Close functions */ | ||
68 | ofn.nFileOffset = 0; | ||
69 | ofn.nFileExtension = 0; | ||
70 | ofn.lpstrDefExt = TEXT ("png"); | ||
71 | ofn.lCustData = 0; | ||
72 | ofn.lpfnHook = NULL; | ||
73 | ofn.lpTemplateName = NULL; | ||
74 | } | ||
75 | |||
76 | BOOL PngFileOpenDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) | ||
77 | { | ||
78 | ofn.hwndOwner = hwnd; | ||
79 | ofn.lpstrFile = pstrFileName; | ||
80 | ofn.lpstrFileTitle = pstrTitleName; | ||
81 | ofn.Flags = OFN_HIDEREADONLY; | ||
82 | |||
83 | return GetOpenFileName (&ofn); | ||
84 | } | ||
85 | |||
86 | BOOL PngFileSaveDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) | ||
87 | { | ||
88 | ofn.hwndOwner = hwnd; | ||
89 | ofn.lpstrFile = pstrFileName; | ||
90 | ofn.lpstrFileTitle = pstrTitleName; | ||
91 | ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; | ||
92 | |||
93 | return GetSaveFileName (&ofn); | ||
94 | } | ||
95 | |||
96 | /* PNG image handler functions */ | ||
97 | |||
98 | BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData, | ||
99 | int *piWidth, int *piHeight, int *piChannels, png_color *pBkgColor) | ||
100 | { | ||
101 | static FILE *pfFile; | ||
102 | png_byte pbSig[8]; | ||
103 | int iBitDepth; | ||
104 | int iColorType; | ||
105 | double dGamma; | ||
106 | png_color_16 *pBackground; | ||
107 | png_uint_32 ulChannels; | ||
108 | png_uint_32 ulRowBytes; | ||
109 | png_byte *pbImageData = *ppbImageData; | ||
110 | static png_byte **ppbRowPointers = NULL; | ||
111 | int i; | ||
112 | |||
113 | /* open the PNG input file */ | ||
114 | |||
115 | if (!pstrFileName) | ||
116 | { | ||
117 | *ppbImageData = pbImageData = NULL; | ||
118 | return FALSE; | ||
119 | } | ||
120 | |||
121 | if (!(pfFile = fopen(pstrFileName, "rb"))) | ||
122 | { | ||
123 | *ppbImageData = pbImageData = NULL; | ||
124 | return FALSE; | ||
125 | } | ||
126 | |||
127 | /* first check the eight byte PNG signature */ | ||
128 | |||
129 | fread(pbSig, 1, 8, pfFile); | ||
130 | if (png_sig_cmp(pbSig, 0, 8)) | ||
131 | { | ||
132 | *ppbImageData = pbImageData = NULL; | ||
133 | return FALSE; | ||
134 | } | ||
135 | |||
136 | /* create the two png(-info) structures */ | ||
137 | |||
138 | png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, | ||
139 | (png_error_ptr)png_cexcept_error, (png_error_ptr)NULL); | ||
140 | if (!png_ptr) | ||
141 | { | ||
142 | *ppbImageData = pbImageData = NULL; | ||
143 | return FALSE; | ||
144 | } | ||
145 | |||
146 | info_ptr = png_create_info_struct(png_ptr); | ||
147 | if (!info_ptr) | ||
148 | { | ||
149 | png_destroy_read_struct(&png_ptr, NULL, NULL); | ||
150 | *ppbImageData = pbImageData = NULL; | ||
151 | return FALSE; | ||
152 | } | ||
153 | |||
154 | Try | ||
155 | { | ||
156 | |||
157 | /* initialize the png structure */ | ||
158 | |||
159 | #ifdef PNG_STDIO_SUPPORTED | ||
160 | png_init_io(png_ptr, pfFile); | ||
161 | #else | ||
162 | png_set_read_fn(png_ptr, (png_voidp)pfFile, png_read_data); | ||
163 | #endif | ||
164 | |||
165 | png_set_sig_bytes(png_ptr, 8); | ||
166 | |||
167 | /* read all PNG info up to image data */ | ||
168 | |||
169 | png_read_info(png_ptr, info_ptr); | ||
170 | |||
171 | /* get width, height, bit-depth and color-type */ | ||
172 | |||
173 | png_get_IHDR(png_ptr, info_ptr, piWidth, piHeight, &iBitDepth, | ||
174 | &iColorType, NULL, NULL, NULL); | ||
175 | |||
176 | /* expand images of all color-type and bit-depth to 3x8-bit RGB */ | ||
177 | /* let the library process alpha, transparency, background, etc. */ | ||
178 | |||
179 | #ifdef PNG_READ_16_TO_8_SUPPORTED | ||
180 | if (iBitDepth == 16) | ||
181 | # ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED | ||
182 | png_set_scale_16(png_ptr); | ||
183 | # else | ||
184 | png_set_strip_16(png_ptr); | ||
185 | # endif | ||
186 | #endif | ||
187 | if (iColorType == PNG_COLOR_TYPE_PALETTE) | ||
188 | png_set_expand(png_ptr); | ||
189 | if (iBitDepth < 8) | ||
190 | png_set_expand(png_ptr); | ||
191 | if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) | ||
192 | png_set_expand(png_ptr); | ||
193 | if (iColorType == PNG_COLOR_TYPE_GRAY || | ||
194 | iColorType == PNG_COLOR_TYPE_GRAY_ALPHA) | ||
195 | png_set_gray_to_rgb(png_ptr); | ||
196 | |||
197 | /* set the background color to draw transparent and alpha images over */ | ||
198 | if (png_get_bKGD(png_ptr, info_ptr, &pBackground)) | ||
199 | { | ||
200 | png_set_background(png_ptr, pBackground, PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); | ||
201 | pBkgColor->red = (byte) pBackground->red; | ||
202 | pBkgColor->green = (byte) pBackground->green; | ||
203 | pBkgColor->blue = (byte) pBackground->blue; | ||
204 | } | ||
205 | else | ||
206 | { | ||
207 | pBkgColor = NULL; | ||
208 | } | ||
209 | |||
210 | /* if required set gamma conversion */ | ||
211 | if (png_get_gAMA(png_ptr, info_ptr, &dGamma)) | ||
212 | png_set_gamma(png_ptr, (double) 2.2, dGamma); | ||
213 | |||
214 | /* after the transformations are registered, update info_ptr data */ | ||
215 | |||
216 | png_read_update_info(png_ptr, info_ptr); | ||
217 | |||
218 | /* get again width, height and the new bit-depth and color-type */ | ||
219 | |||
220 | png_get_IHDR(png_ptr, info_ptr, piWidth, piHeight, &iBitDepth, | ||
221 | &iColorType, NULL, NULL, NULL); | ||
222 | |||
223 | |||
224 | /* row_bytes is the width x number of channels */ | ||
225 | |||
226 | ulRowBytes = png_get_rowbytes(png_ptr, info_ptr); | ||
227 | ulChannels = png_get_channels(png_ptr, info_ptr); | ||
228 | |||
229 | *piChannels = ulChannels; | ||
230 | |||
231 | /* now we can allocate memory to store the image */ | ||
232 | |||
233 | if (pbImageData) | ||
234 | { | ||
235 | free (pbImageData); | ||
236 | pbImageData = NULL; | ||
237 | } | ||
238 | if ((pbImageData = (png_byte *) malloc(ulRowBytes * (*piHeight) | ||
239 | * sizeof(png_byte))) == NULL) | ||
240 | { | ||
241 | png_error(png_ptr, "Visual PNG: out of memory"); | ||
242 | } | ||
243 | *ppbImageData = pbImageData; | ||
244 | |||
245 | /* and allocate memory for an array of row-pointers */ | ||
246 | |||
247 | if ((ppbRowPointers = (png_bytepp) malloc((*piHeight) | ||
248 | * sizeof(png_bytep))) == NULL) | ||
249 | { | ||
250 | png_error(png_ptr, "Visual PNG: out of memory"); | ||
251 | } | ||
252 | |||
253 | /* set the individual row-pointers to point at the correct offsets */ | ||
254 | |||
255 | for (i = 0; i < (*piHeight); i++) | ||
256 | ppbRowPointers[i] = pbImageData + i * ulRowBytes; | ||
257 | |||
258 | /* now we can go ahead and just read the whole image */ | ||
259 | |||
260 | png_read_image(png_ptr, ppbRowPointers); | ||
261 | |||
262 | /* read the additional chunks in the PNG file (not really needed) */ | ||
263 | |||
264 | png_read_end(png_ptr, NULL); | ||
265 | |||
266 | /* and we're done */ | ||
267 | |||
268 | free (ppbRowPointers); | ||
269 | ppbRowPointers = NULL; | ||
270 | |||
271 | /* yepp, done */ | ||
272 | } | ||
273 | |||
274 | Catch (msg) | ||
275 | { | ||
276 | png_destroy_read_struct(&png_ptr, &info_ptr, NULL); | ||
277 | |||
278 | *ppbImageData = pbImageData = NULL; | ||
279 | |||
280 | if(ppbRowPointers) | ||
281 | free (ppbRowPointers); | ||
282 | |||
283 | fclose(pfFile); | ||
284 | |||
285 | return FALSE; | ||
286 | } | ||
287 | |||
288 | fclose (pfFile); | ||
289 | |||
290 | return TRUE; | ||
291 | } | ||
292 | |||
293 | |||
294 | BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData, | ||
295 | int iWidth, int iHeight, png_color bkgColor) | ||
296 | { | ||
297 | const int ciBitDepth = 8; | ||
298 | const int ciChannels = 3; | ||
299 | |||
300 | static FILE *pfFile; | ||
301 | png_uint_32 ulRowBytes; | ||
302 | static png_byte **ppbRowPointers = NULL; | ||
303 | int i; | ||
304 | |||
305 | /* open the PNG output file */ | ||
306 | |||
307 | if (!pstrFileName) | ||
308 | return FALSE; | ||
309 | |||
310 | if (!(pfFile = fopen(pstrFileName, "wb"))) | ||
311 | return FALSE; | ||
312 | |||
313 | /* prepare the standard PNG structures */ | ||
314 | |||
315 | png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, | ||
316 | (png_error_ptr)png_cexcept_error, (png_error_ptr)NULL); | ||
317 | if (!png_ptr) | ||
318 | { | ||
319 | fclose(pfFile); | ||
320 | return FALSE; | ||
321 | } | ||
322 | |||
323 | info_ptr = png_create_info_struct(png_ptr); | ||
324 | if (!info_ptr) { | ||
325 | fclose(pfFile); | ||
326 | png_destroy_write_struct(&png_ptr, (png_infopp) NULL); | ||
327 | return FALSE; | ||
328 | } | ||
329 | |||
330 | Try | ||
331 | { | ||
332 | /* initialize the png structure */ | ||
333 | |||
334 | #ifdef PNG_STDIO_SUPPORTED | ||
335 | png_init_io(png_ptr, pfFile); | ||
336 | #else | ||
337 | png_set_write_fn(png_ptr, (png_voidp)pfFile, png_write_data, png_flush); | ||
338 | #endif | ||
339 | |||
340 | /* we're going to write a very simple 3x8-bit RGB image */ | ||
341 | |||
342 | png_set_IHDR(png_ptr, info_ptr, iWidth, iHeight, ciBitDepth, | ||
343 | PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, | ||
344 | PNG_FILTER_TYPE_BASE); | ||
345 | |||
346 | /* write the file header information */ | ||
347 | |||
348 | png_write_info(png_ptr, info_ptr); | ||
349 | |||
350 | /* swap the BGR pixels in the DiData structure to RGB */ | ||
351 | |||
352 | png_set_bgr(png_ptr); | ||
353 | |||
354 | /* row_bytes is the width x number of channels */ | ||
355 | |||
356 | ulRowBytes = iWidth * ciChannels; | ||
357 | |||
358 | /* we can allocate memory for an array of row-pointers */ | ||
359 | |||
360 | if ((ppbRowPointers = (png_bytepp) malloc(iHeight * sizeof(png_bytep))) == NULL) | ||
361 | Throw "Visualpng: Out of memory"; | ||
362 | |||
363 | /* set the individual row-pointers to point at the correct offsets */ | ||
364 | |||
365 | for (i = 0; i < iHeight; i++) | ||
366 | ppbRowPointers[i] = pDiData + i * (((ulRowBytes + 3) >> 2) << 2); | ||
367 | |||
368 | /* write out the entire image data in one call */ | ||
369 | |||
370 | png_write_image (png_ptr, ppbRowPointers); | ||
371 | |||
372 | /* write the additional chunks to the PNG file (not really needed) */ | ||
373 | |||
374 | png_write_end(png_ptr, info_ptr); | ||
375 | |||
376 | /* and we're done */ | ||
377 | |||
378 | free (ppbRowPointers); | ||
379 | ppbRowPointers = NULL; | ||
380 | |||
381 | /* clean up after the write, and free any memory allocated */ | ||
382 | |||
383 | png_destroy_write_struct(&png_ptr, (png_infopp) NULL); | ||
384 | |||
385 | /* yepp, done */ | ||
386 | } | ||
387 | |||
388 | Catch (msg) | ||
389 | { | ||
390 | png_destroy_write_struct(&png_ptr, (png_infopp) NULL); | ||
391 | |||
392 | if(ppbRowPointers) | ||
393 | free (ppbRowPointers); | ||
394 | |||
395 | fclose(pfFile); | ||
396 | |||
397 | return FALSE; | ||
398 | } | ||
399 | |||
400 | fclose (pfFile); | ||
401 | |||
402 | return TRUE; | ||
403 | } | ||
404 | |||
405 | #ifndef PNG_STDIO_SUPPORTED | ||
406 | |||
407 | static void | ||
408 | png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) | ||
409 | { | ||
410 | png_size_t check; | ||
411 | |||
412 | /* fread() returns 0 on error, so it is OK to store this in a png_size_t | ||
413 | * instead of an int, which is what fread() actually returns. | ||
414 | */ | ||
415 | check = (png_size_t)fread(data, (png_size_t)1, length, | ||
416 | (FILE *)png_ptr->io_ptr); | ||
417 | |||
418 | if (check != length) | ||
419 | { | ||
420 | png_error(png_ptr, "Read Error"); | ||
421 | } | ||
422 | } | ||
423 | |||
424 | static void | ||
425 | png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) | ||
426 | { | ||
427 | png_uint_32 check; | ||
428 | |||
429 | check = fwrite(data, 1, length, (FILE *)(png_ptr->io_ptr)); | ||
430 | if (check != length) | ||
431 | { | ||
432 | png_error(png_ptr, "Write Error"); | ||
433 | } | ||
434 | } | ||
435 | |||
436 | static void | ||
437 | png_flush(png_structp png_ptr) | ||
438 | { | ||
439 | FILE *io_ptr; | ||
440 | io_ptr = (FILE *)CVT_PTR((png_ptr->io_ptr)); | ||
441 | if (io_ptr != NULL) | ||
442 | fflush(io_ptr); | ||
443 | } | ||
444 | |||
445 | #endif | ||
446 | |||
447 | /*----------------- | ||
448 | * end of source | ||
449 | *----------------- | ||
450 | */ | ||
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/PngFile.h b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/PngFile.h new file mode 100644 index 0000000..66f8472 --- /dev/null +++ b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/PngFile.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /*------------------------------------------*/ | ||
2 | /* PNGFILE.H -- Header File for pngfile.c*/ | ||
3 | /*------------------------------------------*/ | ||
4 | |||
5 | /* Copyright 2000, Willem van Schaik.*/ | ||
6 | |||
7 | /* This code is released under the libpng license.*/ | ||
8 | /* For conditions of distribution and use, see the disclaimer*/ | ||
9 | /* and license in png.h*/ | ||
10 | |||
11 | #include <stdio.h> | ||
12 | #include <stdlib.h> | ||
13 | #include <string.h> | ||
14 | #include <windows.h> | ||
15 | |||
16 | void PngFileInitialize (HWND hwnd) ; | ||
17 | BOOL PngFileOpenDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) ; | ||
18 | BOOL PngFileSaveDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) ; | ||
19 | |||
20 | BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData, | ||
21 | int *piWidth, int *piHeight, int *piChannels, png_color *pBkgColor); | ||
22 | BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData, | ||
23 | int iWidth, int iHeight, png_color BkgColor); | ||
24 | |||
25 | #ifndef PNG_STDIO_SUPPORTED | ||
26 | static void png_read_data(png_structp png_ptr, png_bytep data, png_size_t length); | ||
27 | static void png_write_data(png_structp png_ptr, png_bytep data, png_size_t length); | ||
28 | static void png_flush(png_structp png_ptr); | ||
29 | #endif | ||
30 | |||
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/README.txt b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/README.txt new file mode 100644 index 0000000..7291bb2 --- /dev/null +++ b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/README.txt | |||
@@ -0,0 +1,61 @@ | |||
1 | Microsoft Developer Studio Build File, Format Version 6.00 for VisualPng | ||
2 | ------------------------------------------------------------------------ | ||
3 | |||
4 | Copyright 2000, Willem van Schaik. | ||
5 | |||
6 | This code is released under the libpng license. | ||
7 | For conditions of distribution and use, see the disclaimer | ||
8 | and license in png.h | ||
9 | |||
10 | As a PNG .dll demo VisualPng is finished. More features would only hinder | ||
11 | the program's objective. However, further extensions (like support for other | ||
12 | graphics formats) are in development. To get these, or for pre-compiled | ||
13 | binaries, go to "http://www.schaik.com/png/visualpng.html". | ||
14 | |||
15 | ------------------------------------------------------------------------ | ||
16 | |||
17 | Assumes that | ||
18 | |||
19 | libpng DLLs and LIBs are in ..\..\projects\msvc\win32\libpng | ||
20 | zlib DLLs and LIBs are in ..\..\projects\msvc\win32\zlib | ||
21 | libpng header files are in ..\..\..\libpng | ||
22 | zlib header files are in ..\..\..\zlib | ||
23 | the pngsuite images are in ..\pngsuite | ||
24 | |||
25 | To build: | ||
26 | |||
27 | 1) On the main menu Select "Build|Set Active configuration". | ||
28 | Choose the configuration that corresponds to the library you want to test. | ||
29 | This library must have been built using the libpng MS project located in | ||
30 | the "..\..\mscv" subdirectory. | ||
31 | |||
32 | 2) Select "Build|Clean" | ||
33 | |||
34 | 3) Select "Build|Rebuild All" | ||
35 | |||
36 | 4) After compiling and linking VisualPng will be started to view an image | ||
37 | from the PngSuite directory. Press Ctrl-N (and Ctrl-V) for other images. | ||
38 | |||
39 | |||
40 | To install: | ||
41 | |||
42 | When distributing VisualPng (or a further development) the following options | ||
43 | are available: | ||
44 | |||
45 | 1) Build the program with the configuration "Win32 LIB" and you only need to | ||
46 | include the executable from the ./lib directory in your distribution. | ||
47 | |||
48 | 2) Build the program with the configuration "Win32 DLL" and you need to put | ||
49 | in your distribution the executable from the ./dll directory and the dll's | ||
50 | libpng1.dll, zlib.dll and msvcrt.dll. These need to be in the user's PATH. | ||
51 | |||
52 | |||
53 | Willem van Schaik | ||
54 | Calgary, June 6th 2000 | ||
55 | |||
56 | P.S. VisualPng was written based on preliminary work of: | ||
57 | |||
58 | - Simon-Pierre Cadieux | ||
59 | - Glenn Randers-Pehrson | ||
60 | - Greg Roelofs | ||
61 | |||
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/VisualPng.c b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/VisualPng.c new file mode 100644 index 0000000..e672ce0 --- /dev/null +++ b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/VisualPng.c | |||
@@ -0,0 +1,969 @@ | |||
1 | /*------------------------------------ | ||
2 | * VisualPng.C -- Shows a PNG image | ||
3 | *------------------------------------ | ||
4 | * | ||
5 | * Copyright 2000, Willem van Schaik. | ||
6 | * | ||
7 | * This code is released under the libpng license. | ||
8 | * For conditions of distribution and use, see the disclaimer | ||
9 | * and license in png.h | ||
10 | */ | ||
11 | |||
12 | /* switches */ | ||
13 | |||
14 | /* defines */ | ||
15 | |||
16 | #define PROGNAME "VisualPng" | ||
17 | #define LONGNAME "Win32 Viewer for PNG-files" | ||
18 | #define VERSION "1.0 of 2000 June 07" | ||
19 | |||
20 | /* constants */ | ||
21 | |||
22 | #define MARGIN 8 | ||
23 | |||
24 | /* standard includes */ | ||
25 | |||
26 | #include <stdio.h> | ||
27 | #include <stdlib.h> | ||
28 | #include <string.h> | ||
29 | #include <windows.h> | ||
30 | |||
31 | /* application includes */ | ||
32 | |||
33 | #include "png.h" | ||
34 | #include "pngfile.h" | ||
35 | #include "resource.h" | ||
36 | |||
37 | /* macros */ | ||
38 | |||
39 | /* function prototypes */ | ||
40 | |||
41 | LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM); | ||
42 | BOOL CALLBACK AboutDlgProc (HWND, UINT, WPARAM, LPARAM) ; | ||
43 | |||
44 | BOOL CenterAbout (HWND hwndChild, HWND hwndParent); | ||
45 | |||
46 | BOOL BuildPngList (PTSTR pstrPathName, TCHAR **ppFileList, int *pFileCount, | ||
47 | int *pFileIndex); | ||
48 | |||
49 | BOOL SearchPngList (TCHAR *pFileList, int FileCount, int *pFileIndex, | ||
50 | PTSTR pstrPrevName, PTSTR pstrNextName); | ||
51 | |||
52 | BOOL LoadImageFile(HWND hwnd, PTSTR pstrPathName, | ||
53 | png_byte **ppbImage, int *pxImgSize, int *pyImgSize, int *piChannels, | ||
54 | png_color *pBkgColor); | ||
55 | |||
56 | BOOL DisplayImage (HWND hwnd, BYTE **ppDib, | ||
57 | BYTE **ppDiData, int cxWinSize, int cyWinSize, | ||
58 | BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels, | ||
59 | BOOL bStretched); | ||
60 | |||
61 | BOOL InitBitmap ( | ||
62 | BYTE *pDiData, int cxWinSize, int cyWinSize); | ||
63 | |||
64 | BOOL FillBitmap ( | ||
65 | BYTE *pDiData, int cxWinSize, int cyWinSize, | ||
66 | BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels, | ||
67 | BOOL bStretched); | ||
68 | |||
69 | /* a few global variables */ | ||
70 | |||
71 | static char *szProgName = PROGNAME; | ||
72 | static char *szAppName = LONGNAME; | ||
73 | static char *szIconName = PROGNAME; | ||
74 | static char szCmdFileName [MAX_PATH]; | ||
75 | |||
76 | /* MAIN routine */ | ||
77 | |||
78 | int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, | ||
79 | PSTR szCmdLine, int iCmdShow) | ||
80 | { | ||
81 | HACCEL hAccel; | ||
82 | HWND hwnd; | ||
83 | MSG msg; | ||
84 | WNDCLASS wndclass; | ||
85 | int ixBorders, iyBorders; | ||
86 | |||
87 | wndclass.style = CS_HREDRAW | CS_VREDRAW; | ||
88 | wndclass.lpfnWndProc = WndProc; | ||
89 | wndclass.cbClsExtra = 0; | ||
90 | wndclass.cbWndExtra = 0; | ||
91 | wndclass.hInstance = hInstance; | ||
92 | wndclass.hIcon = LoadIcon (hInstance, szIconName) ; | ||
93 | wndclass.hCursor = LoadCursor (NULL, IDC_ARROW); | ||
94 | wndclass.hbrBackground = NULL; /* (HBRUSH) GetStockObject (GRAY_BRUSH); */ | ||
95 | wndclass.lpszMenuName = szProgName; | ||
96 | wndclass.lpszClassName = szProgName; | ||
97 | |||
98 | if (!RegisterClass (&wndclass)) | ||
99 | { | ||
100 | MessageBox (NULL, TEXT ("Error: this program requires Windows NT!"), | ||
101 | szProgName, MB_ICONERROR); | ||
102 | return 0; | ||
103 | } | ||
104 | |||
105 | /* if filename given on commandline, store it */ | ||
106 | if ((szCmdLine != NULL) && (*szCmdLine != '\0')) | ||
107 | if (szCmdLine[0] == '"') | ||
108 | strncpy (szCmdFileName, szCmdLine + 1, strlen(szCmdLine) - 2); | ||
109 | else | ||
110 | strcpy (szCmdFileName, szCmdLine); | ||
111 | else | ||
112 | strcpy (szCmdFileName, ""); | ||
113 | |||
114 | /* calculate size of window-borders */ | ||
115 | ixBorders = 2 * (GetSystemMetrics (SM_CXBORDER) + | ||
116 | GetSystemMetrics (SM_CXDLGFRAME)); | ||
117 | iyBorders = 2 * (GetSystemMetrics (SM_CYBORDER) + | ||
118 | GetSystemMetrics (SM_CYDLGFRAME)) + | ||
119 | GetSystemMetrics (SM_CYCAPTION) + | ||
120 | GetSystemMetrics (SM_CYMENUSIZE) + | ||
121 | 1; /* WvS: don't ask me why? */ | ||
122 | |||
123 | hwnd = CreateWindow (szProgName, szAppName, | ||
124 | WS_OVERLAPPEDWINDOW, | ||
125 | CW_USEDEFAULT, CW_USEDEFAULT, | ||
126 | 512 + 2 * MARGIN + ixBorders, 384 + 2 * MARGIN + iyBorders, | ||
127 | /* CW_USEDEFAULT, CW_USEDEFAULT, */ | ||
128 | NULL, NULL, hInstance, NULL); | ||
129 | |||
130 | ShowWindow (hwnd, iCmdShow); | ||
131 | UpdateWindow (hwnd); | ||
132 | |||
133 | hAccel = LoadAccelerators (hInstance, szProgName); | ||
134 | |||
135 | while (GetMessage (&msg, NULL, 0, 0)) | ||
136 | { | ||
137 | if (!TranslateAccelerator (hwnd, hAccel, &msg)) | ||
138 | { | ||
139 | TranslateMessage (&msg); | ||
140 | DispatchMessage (&msg); | ||
141 | } | ||
142 | } | ||
143 | return msg.wParam; | ||
144 | } | ||
145 | |||
146 | LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, | ||
147 | LPARAM lParam) | ||
148 | { | ||
149 | static HINSTANCE hInstance ; | ||
150 | static HDC hdc; | ||
151 | static PAINTSTRUCT ps; | ||
152 | static HMENU hMenu; | ||
153 | |||
154 | static BITMAPFILEHEADER *pbmfh; | ||
155 | static BITMAPINFOHEADER *pbmih; | ||
156 | static BYTE *pbImage; | ||
157 | static int cxWinSize, cyWinSize; | ||
158 | static int cxImgSize, cyImgSize; | ||
159 | static int cImgChannels; | ||
160 | static png_color bkgColor = {127, 127, 127}; | ||
161 | |||
162 | static BOOL bStretched = TRUE; | ||
163 | |||
164 | static BYTE *pDib = NULL; | ||
165 | static BYTE *pDiData = NULL; | ||
166 | |||
167 | static TCHAR szImgPathName [MAX_PATH]; | ||
168 | static TCHAR szTitleName [MAX_PATH]; | ||
169 | |||
170 | static TCHAR *pPngFileList = NULL; | ||
171 | static int iPngFileCount; | ||
172 | static int iPngFileIndex; | ||
173 | |||
174 | BOOL bOk; | ||
175 | |||
176 | switch (message) | ||
177 | { | ||
178 | case WM_CREATE: | ||
179 | hInstance = ((LPCREATESTRUCT) lParam)->hInstance ; | ||
180 | PngFileInitialize (hwnd); | ||
181 | |||
182 | strcpy (szImgPathName, ""); | ||
183 | |||
184 | /* in case we process file given on command-line */ | ||
185 | |||
186 | if (szCmdFileName[0] != '\0') | ||
187 | { | ||
188 | strcpy (szImgPathName, szCmdFileName); | ||
189 | |||
190 | /* read the other png-files in the directory for later */ | ||
191 | /* next/previous commands */ | ||
192 | |||
193 | BuildPngList (szImgPathName, &pPngFileList, &iPngFileCount, | ||
194 | &iPngFileIndex); | ||
195 | |||
196 | /* load the image from file */ | ||
197 | |||
198 | if (!LoadImageFile (hwnd, szImgPathName, | ||
199 | &pbImage, &cxImgSize, &cyImgSize, &cImgChannels, &bkgColor)) | ||
200 | return 0; | ||
201 | |||
202 | /* invalidate the client area for later update */ | ||
203 | |||
204 | InvalidateRect (hwnd, NULL, TRUE); | ||
205 | |||
206 | /* display the PNG into the DIBitmap */ | ||
207 | |||
208 | DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize, | ||
209 | pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched); | ||
210 | } | ||
211 | |||
212 | return 0; | ||
213 | |||
214 | case WM_SIZE: | ||
215 | cxWinSize = LOWORD (lParam); | ||
216 | cyWinSize = HIWORD (lParam); | ||
217 | |||
218 | /* invalidate the client area for later update */ | ||
219 | |||
220 | InvalidateRect (hwnd, NULL, TRUE); | ||
221 | |||
222 | /* display the PNG into the DIBitmap */ | ||
223 | |||
224 | DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize, | ||
225 | pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched); | ||
226 | |||
227 | return 0; | ||
228 | |||
229 | case WM_INITMENUPOPUP: | ||
230 | hMenu = GetMenu (hwnd); | ||
231 | |||
232 | if (pbImage) | ||
233 | EnableMenuItem (hMenu, IDM_FILE_SAVE, MF_ENABLED); | ||
234 | else | ||
235 | EnableMenuItem (hMenu, IDM_FILE_SAVE, MF_GRAYED); | ||
236 | |||
237 | return 0; | ||
238 | |||
239 | case WM_COMMAND: | ||
240 | hMenu = GetMenu (hwnd); | ||
241 | |||
242 | switch (LOWORD (wParam)) | ||
243 | { | ||
244 | case IDM_FILE_OPEN: | ||
245 | |||
246 | /* show the File Open dialog box */ | ||
247 | |||
248 | if (!PngFileOpenDlg (hwnd, szImgPathName, szTitleName)) | ||
249 | return 0; | ||
250 | |||
251 | /* read the other png-files in the directory for later */ | ||
252 | /* next/previous commands */ | ||
253 | |||
254 | BuildPngList (szImgPathName, &pPngFileList, &iPngFileCount, | ||
255 | &iPngFileIndex); | ||
256 | |||
257 | /* load the image from file */ | ||
258 | |||
259 | if (!LoadImageFile (hwnd, szImgPathName, | ||
260 | &pbImage, &cxImgSize, &cyImgSize, &cImgChannels, &bkgColor)) | ||
261 | return 0; | ||
262 | |||
263 | /* invalidate the client area for later update */ | ||
264 | |||
265 | InvalidateRect (hwnd, NULL, TRUE); | ||
266 | |||
267 | /* display the PNG into the DIBitmap */ | ||
268 | |||
269 | DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize, | ||
270 | pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched); | ||
271 | |||
272 | return 0; | ||
273 | |||
274 | case IDM_FILE_SAVE: | ||
275 | |||
276 | /* show the File Save dialog box */ | ||
277 | |||
278 | if (!PngFileSaveDlg (hwnd, szImgPathName, szTitleName)) | ||
279 | return 0; | ||
280 | |||
281 | /* save the PNG to a disk file */ | ||
282 | |||
283 | SetCursor (LoadCursor (NULL, IDC_WAIT)); | ||
284 | ShowCursor (TRUE); | ||
285 | |||
286 | bOk = PngSaveImage (szImgPathName, pDiData, cxWinSize, cyWinSize, | ||
287 | bkgColor); | ||
288 | |||
289 | ShowCursor (FALSE); | ||
290 | SetCursor (LoadCursor (NULL, IDC_ARROW)); | ||
291 | |||
292 | if (!bOk) | ||
293 | MessageBox (hwnd, TEXT ("Error in saving the PNG image"), | ||
294 | szProgName, MB_ICONEXCLAMATION | MB_OK); | ||
295 | return 0; | ||
296 | |||
297 | case IDM_FILE_NEXT: | ||
298 | |||
299 | /* read next entry in the directory */ | ||
300 | |||
301 | if (SearchPngList (pPngFileList, iPngFileCount, &iPngFileIndex, | ||
302 | NULL, szImgPathName)) | ||
303 | { | ||
304 | if (strcmp (szImgPathName, "") == 0) | ||
305 | return 0; | ||
306 | |||
307 | /* load the image from file */ | ||
308 | |||
309 | if (!LoadImageFile (hwnd, szImgPathName, &pbImage, | ||
310 | &cxImgSize, &cyImgSize, &cImgChannels, &bkgColor)) | ||
311 | return 0; | ||
312 | |||
313 | /* invalidate the client area for later update */ | ||
314 | |||
315 | InvalidateRect (hwnd, NULL, TRUE); | ||
316 | |||
317 | /* display the PNG into the DIBitmap */ | ||
318 | |||
319 | DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize, | ||
320 | pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched); | ||
321 | } | ||
322 | |||
323 | return 0; | ||
324 | |||
325 | case IDM_FILE_PREVIOUS: | ||
326 | |||
327 | /* read previous entry in the directory */ | ||
328 | |||
329 | if (SearchPngList (pPngFileList, iPngFileCount, &iPngFileIndex, | ||
330 | szImgPathName, NULL)) | ||
331 | { | ||
332 | |||
333 | if (strcmp (szImgPathName, "") == 0) | ||
334 | return 0; | ||
335 | |||
336 | /* load the image from file */ | ||
337 | |||
338 | if (!LoadImageFile (hwnd, szImgPathName, &pbImage, &cxImgSize, | ||
339 | &cyImgSize, &cImgChannels, &bkgColor)) | ||
340 | return 0; | ||
341 | |||
342 | /* invalidate the client area for later update */ | ||
343 | |||
344 | InvalidateRect (hwnd, NULL, TRUE); | ||
345 | |||
346 | /* display the PNG into the DIBitmap */ | ||
347 | |||
348 | DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize, | ||
349 | pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched); | ||
350 | } | ||
351 | |||
352 | return 0; | ||
353 | |||
354 | case IDM_FILE_EXIT: | ||
355 | |||
356 | /* more cleanup needed... */ | ||
357 | |||
358 | /* free image buffer */ | ||
359 | |||
360 | if (pDib != NULL) | ||
361 | { | ||
362 | free (pDib); | ||
363 | pDib = NULL; | ||
364 | } | ||
365 | |||
366 | /* free file-list */ | ||
367 | |||
368 | if (pPngFileList != NULL) | ||
369 | { | ||
370 | free (pPngFileList); | ||
371 | pPngFileList = NULL; | ||
372 | } | ||
373 | |||
374 | /* let's go ... */ | ||
375 | |||
376 | exit (0); | ||
377 | |||
378 | return 0; | ||
379 | |||
380 | case IDM_OPTIONS_STRETCH: | ||
381 | bStretched = !bStretched; | ||
382 | if (bStretched) | ||
383 | CheckMenuItem (hMenu, IDM_OPTIONS_STRETCH, MF_CHECKED); | ||
384 | else | ||
385 | CheckMenuItem (hMenu, IDM_OPTIONS_STRETCH, MF_UNCHECKED); | ||
386 | |||
387 | /* invalidate the client area for later update */ | ||
388 | |||
389 | InvalidateRect (hwnd, NULL, TRUE); | ||
390 | |||
391 | /* display the PNG into the DIBitmap */ | ||
392 | |||
393 | DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize, | ||
394 | pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched); | ||
395 | |||
396 | return 0; | ||
397 | |||
398 | case IDM_HELP_ABOUT: | ||
399 | DialogBox (hInstance, TEXT ("AboutBox"), hwnd, AboutDlgProc) ; | ||
400 | return 0; | ||
401 | |||
402 | } /* end switch */ | ||
403 | |||
404 | break; | ||
405 | |||
406 | case WM_PAINT: | ||
407 | hdc = BeginPaint (hwnd, &ps); | ||
408 | |||
409 | if (pDib) | ||
410 | SetDIBitsToDevice (hdc, 0, 0, cxWinSize, cyWinSize, 0, 0, | ||
411 | 0, cyWinSize, pDiData, (BITMAPINFO *) pDib, DIB_RGB_COLORS); | ||
412 | |||
413 | EndPaint (hwnd, &ps); | ||
414 | return 0; | ||
415 | |||
416 | case WM_DESTROY: | ||
417 | if (pbmfh) | ||
418 | { | ||
419 | free (pbmfh); | ||
420 | pbmfh = NULL; | ||
421 | } | ||
422 | |||
423 | PostQuitMessage (0); | ||
424 | return 0; | ||
425 | } | ||
426 | |||
427 | return DefWindowProc (hwnd, message, wParam, lParam); | ||
428 | } | ||
429 | |||
430 | BOOL CALLBACK AboutDlgProc (HWND hDlg, UINT message, | ||
431 | WPARAM wParam, LPARAM lParam) | ||
432 | { | ||
433 | switch (message) | ||
434 | { | ||
435 | case WM_INITDIALOG : | ||
436 | ShowWindow (hDlg, SW_HIDE); | ||
437 | CenterAbout (hDlg, GetWindow (hDlg, GW_OWNER)); | ||
438 | ShowWindow (hDlg, SW_SHOW); | ||
439 | return TRUE ; | ||
440 | |||
441 | case WM_COMMAND : | ||
442 | switch (LOWORD (wParam)) | ||
443 | { | ||
444 | case IDOK : | ||
445 | case IDCANCEL : | ||
446 | EndDialog (hDlg, 0) ; | ||
447 | return TRUE ; | ||
448 | } | ||
449 | break ; | ||
450 | } | ||
451 | return FALSE ; | ||
452 | } | ||
453 | |||
454 | /*--------------- | ||
455 | * CenterAbout | ||
456 | *--------------- | ||
457 | */ | ||
458 | BOOL CenterAbout (HWND hwndChild, HWND hwndParent) | ||
459 | { | ||
460 | RECT rChild, rParent, rWorkArea; | ||
461 | int wChild, hChild, wParent, hParent; | ||
462 | int xNew, yNew; | ||
463 | BOOL bResult; | ||
464 | |||
465 | /* Get the Height and Width of the child window */ | ||
466 | GetWindowRect (hwndChild, &rChild); | ||
467 | wChild = rChild.right - rChild.left; | ||
468 | hChild = rChild.bottom - rChild.top; | ||
469 | |||
470 | /* Get the Height and Width of the parent window */ | ||
471 | GetWindowRect (hwndParent, &rParent); | ||
472 | wParent = rParent.right - rParent.left; | ||
473 | hParent = rParent.bottom - rParent.top; | ||
474 | |||
475 | /* Get the limits of the 'workarea' */ | ||
476 | bResult = SystemParametersInfo( | ||
477 | SPI_GETWORKAREA, /* system parameter to query or set */ | ||
478 | sizeof(RECT), | ||
479 | &rWorkArea, | ||
480 | 0); | ||
481 | if (!bResult) { | ||
482 | rWorkArea.left = rWorkArea.top = 0; | ||
483 | rWorkArea.right = GetSystemMetrics(SM_CXSCREEN); | ||
484 | rWorkArea.bottom = GetSystemMetrics(SM_CYSCREEN); | ||
485 | } | ||
486 | |||
487 | /* Calculate new X position, then adjust for workarea */ | ||
488 | xNew = rParent.left + ((wParent - wChild) /2); | ||
489 | if (xNew < rWorkArea.left) { | ||
490 | xNew = rWorkArea.left; | ||
491 | } else if ((xNew+wChild) > rWorkArea.right) { | ||
492 | xNew = rWorkArea.right - wChild; | ||
493 | } | ||
494 | |||
495 | /* Calculate new Y position, then adjust for workarea */ | ||
496 | yNew = rParent.top + ((hParent - hChild) /2); | ||
497 | if (yNew < rWorkArea.top) { | ||
498 | yNew = rWorkArea.top; | ||
499 | } else if ((yNew+hChild) > rWorkArea.bottom) { | ||
500 | yNew = rWorkArea.bottom - hChild; | ||
501 | } | ||
502 | |||
503 | /* Set it, and return */ | ||
504 | return SetWindowPos (hwndChild, NULL, xNew, yNew, 0, 0, SWP_NOSIZE | | ||
505 | SWP_NOZORDER); | ||
506 | } | ||
507 | |||
508 | /*---------------- | ||
509 | * BuildPngList | ||
510 | *---------------- | ||
511 | */ | ||
512 | BOOL BuildPngList (PTSTR pstrPathName, TCHAR **ppFileList, int *pFileCount, | ||
513 | int *pFileIndex) | ||
514 | { | ||
515 | static TCHAR szImgPathName [MAX_PATH]; | ||
516 | static TCHAR szImgFileName [MAX_PATH]; | ||
517 | static TCHAR szImgFindName [MAX_PATH]; | ||
518 | |||
519 | WIN32_FIND_DATA finddata; | ||
520 | HANDLE hFind; | ||
521 | |||
522 | static TCHAR szTmp [MAX_PATH]; | ||
523 | BOOL bOk; | ||
524 | int i, ii; | ||
525 | int j, jj; | ||
526 | |||
527 | /* free previous file-list */ | ||
528 | |||
529 | if (*ppFileList != NULL) | ||
530 | { | ||
531 | free (*ppFileList); | ||
532 | *ppFileList = NULL; | ||
533 | } | ||
534 | |||
535 | /* extract foldername, filename and search-name */ | ||
536 | |||
537 | strcpy (szImgPathName, pstrPathName); | ||
538 | strcpy (szImgFileName, strrchr (pstrPathName, '\\') + 1); | ||
539 | |||
540 | strcpy (szImgFindName, szImgPathName); | ||
541 | *(strrchr (szImgFindName, '\\') + 1) = '\0'; | ||
542 | strcat (szImgFindName, "*.png"); | ||
543 | |||
544 | /* first cycle: count number of files in directory for memory allocation */ | ||
545 | |||
546 | *pFileCount = 0; | ||
547 | |||
548 | hFind = FindFirstFile(szImgFindName, &finddata); | ||
549 | bOk = (hFind != (HANDLE) -1); | ||
550 | |||
551 | while (bOk) | ||
552 | { | ||
553 | *pFileCount += 1; | ||
554 | bOk = FindNextFile(hFind, &finddata); | ||
555 | } | ||
556 | FindClose(hFind); | ||
557 | |||
558 | /* allocation memory for file-list */ | ||
559 | |||
560 | *ppFileList = (TCHAR *) malloc (*pFileCount * MAX_PATH); | ||
561 | |||
562 | /* second cycle: read directory and store filenames in file-list */ | ||
563 | |||
564 | hFind = FindFirstFile(szImgFindName, &finddata); | ||
565 | bOk = (hFind != (HANDLE) -1); | ||
566 | |||
567 | i = 0; | ||
568 | ii = 0; | ||
569 | while (bOk) | ||
570 | { | ||
571 | strcpy (*ppFileList + ii, szImgPathName); | ||
572 | strcpy (strrchr(*ppFileList + ii, '\\') + 1, finddata.cFileName); | ||
573 | |||
574 | if (strcmp(pstrPathName, *ppFileList + ii) == 0) | ||
575 | *pFileIndex = i; | ||
576 | |||
577 | ii += MAX_PATH; | ||
578 | i++; | ||
579 | |||
580 | bOk = FindNextFile(hFind, &finddata); | ||
581 | } | ||
582 | FindClose(hFind); | ||
583 | |||
584 | /* finally we must sort the file-list */ | ||
585 | |||
586 | for (i = 0; i < *pFileCount - 1; i++) | ||
587 | { | ||
588 | ii = i * MAX_PATH; | ||
589 | for (j = i+1; j < *pFileCount; j++) | ||
590 | { | ||
591 | jj = j * MAX_PATH; | ||
592 | if (strcmp (*ppFileList + ii, *ppFileList + jj) > 0) | ||
593 | { | ||
594 | strcpy (szTmp, *ppFileList + jj); | ||
595 | strcpy (*ppFileList + jj, *ppFileList + ii); | ||
596 | strcpy (*ppFileList + ii, szTmp); | ||
597 | |||
598 | /* check if this was the current image that we moved */ | ||
599 | |||
600 | if (*pFileIndex == i) | ||
601 | *pFileIndex = j; | ||
602 | else | ||
603 | if (*pFileIndex == j) | ||
604 | *pFileIndex = i; | ||
605 | } | ||
606 | } | ||
607 | } | ||
608 | |||
609 | return TRUE; | ||
610 | } | ||
611 | |||
612 | /*---------------- | ||
613 | * SearchPngList | ||
614 | *---------------- | ||
615 | */ | ||
616 | |||
617 | BOOL SearchPngList ( | ||
618 | TCHAR *pFileList, int FileCount, int *pFileIndex, | ||
619 | PTSTR pstrPrevName, PTSTR pstrNextName) | ||
620 | { | ||
621 | if (FileCount > 0) | ||
622 | { | ||
623 | /* get previous entry */ | ||
624 | |||
625 | if (pstrPrevName != NULL) | ||
626 | { | ||
627 | if (*pFileIndex > 0) | ||
628 | *pFileIndex -= 1; | ||
629 | else | ||
630 | *pFileIndex = FileCount - 1; | ||
631 | |||
632 | strcpy (pstrPrevName, pFileList + (*pFileIndex * MAX_PATH)); | ||
633 | } | ||
634 | |||
635 | /* get next entry */ | ||
636 | |||
637 | if (pstrNextName != NULL) | ||
638 | { | ||
639 | if (*pFileIndex < FileCount - 1) | ||
640 | *pFileIndex += 1; | ||
641 | else | ||
642 | *pFileIndex = 0; | ||
643 | |||
644 | strcpy (pstrNextName, pFileList + (*pFileIndex * MAX_PATH)); | ||
645 | } | ||
646 | |||
647 | return TRUE; | ||
648 | } | ||
649 | else | ||
650 | { | ||
651 | return FALSE; | ||
652 | } | ||
653 | } | ||
654 | |||
655 | /*----------------- | ||
656 | * LoadImageFile | ||
657 | *----------------- | ||
658 | */ | ||
659 | |||
660 | BOOL LoadImageFile (HWND hwnd, PTSTR pstrPathName, | ||
661 | png_byte **ppbImage, int *pxImgSize, int *pyImgSize, | ||
662 | int *piChannels, png_color *pBkgColor) | ||
663 | { | ||
664 | static TCHAR szTmp [MAX_PATH]; | ||
665 | |||
666 | /* if there's an existing PNG, free the memory */ | ||
667 | |||
668 | if (*ppbImage) | ||
669 | { | ||
670 | free (*ppbImage); | ||
671 | *ppbImage = NULL; | ||
672 | } | ||
673 | |||
674 | /* Load the entire PNG into memory */ | ||
675 | |||
676 | SetCursor (LoadCursor (NULL, IDC_WAIT)); | ||
677 | ShowCursor (TRUE); | ||
678 | |||
679 | PngLoadImage (pstrPathName, ppbImage, pxImgSize, pyImgSize, piChannels, | ||
680 | pBkgColor); | ||
681 | |||
682 | ShowCursor (FALSE); | ||
683 | SetCursor (LoadCursor (NULL, IDC_ARROW)); | ||
684 | |||
685 | if (*ppbImage != NULL) | ||
686 | { | ||
687 | sprintf (szTmp, "VisualPng - %s", strrchr(pstrPathName, '\\') + 1); | ||
688 | SetWindowText (hwnd, szTmp); | ||
689 | } | ||
690 | else | ||
691 | { | ||
692 | MessageBox (hwnd, TEXT ("Error in loading the PNG image"), | ||
693 | szProgName, MB_ICONEXCLAMATION | MB_OK); | ||
694 | return FALSE; | ||
695 | } | ||
696 | |||
697 | return TRUE; | ||
698 | } | ||
699 | |||
700 | /*---------------- | ||
701 | * DisplayImage | ||
702 | *---------------- | ||
703 | */ | ||
704 | BOOL DisplayImage (HWND hwnd, BYTE **ppDib, | ||
705 | BYTE **ppDiData, int cxWinSize, int cyWinSize, | ||
706 | BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels, | ||
707 | BOOL bStretched) | ||
708 | { | ||
709 | BYTE *pDib = *ppDib; | ||
710 | BYTE *pDiData = *ppDiData; | ||
711 | /* BITMAPFILEHEADER *pbmfh; */ | ||
712 | BITMAPINFOHEADER *pbmih; | ||
713 | WORD wDIRowBytes; | ||
714 | png_color bkgBlack = {0, 0, 0}; | ||
715 | png_color bkgGray = {127, 127, 127}; | ||
716 | png_color bkgWhite = {255, 255, 255}; | ||
717 | |||
718 | /* allocate memory for the Device Independant bitmap */ | ||
719 | |||
720 | wDIRowBytes = (WORD) ((3 * cxWinSize + 3L) >> 2) << 2; | ||
721 | |||
722 | if (pDib) | ||
723 | { | ||
724 | free (pDib); | ||
725 | pDib = NULL; | ||
726 | } | ||
727 | |||
728 | if (!(pDib = (BYTE *) malloc (sizeof(BITMAPINFOHEADER) + | ||
729 | wDIRowBytes * cyWinSize))) | ||
730 | { | ||
731 | MessageBox (hwnd, TEXT ("Error in displaying the PNG image"), | ||
732 | szProgName, MB_ICONEXCLAMATION | MB_OK); | ||
733 | *ppDib = pDib = NULL; | ||
734 | return FALSE; | ||
735 | } | ||
736 | *ppDib = pDib; | ||
737 | memset (pDib, 0, sizeof(BITMAPINFOHEADER)); | ||
738 | |||
739 | /* initialize the dib-structure */ | ||
740 | |||
741 | pbmih = (BITMAPINFOHEADER *) pDib; | ||
742 | pbmih->biSize = sizeof(BITMAPINFOHEADER); | ||
743 | pbmih->biWidth = cxWinSize; | ||
744 | pbmih->biHeight = -((long) cyWinSize); | ||
745 | pbmih->biPlanes = 1; | ||
746 | pbmih->biBitCount = 24; | ||
747 | pbmih->biCompression = 0; | ||
748 | pDiData = pDib + sizeof(BITMAPINFOHEADER); | ||
749 | *ppDiData = pDiData; | ||
750 | |||
751 | /* first fill bitmap with gray and image border */ | ||
752 | |||
753 | InitBitmap (pDiData, cxWinSize, cyWinSize); | ||
754 | |||
755 | /* then fill bitmap with image */ | ||
756 | |||
757 | if (pbImage) | ||
758 | { | ||
759 | FillBitmap ( | ||
760 | pDiData, cxWinSize, cyWinSize, | ||
761 | pbImage, cxImgSize, cyImgSize, cImgChannels, | ||
762 | bStretched); | ||
763 | } | ||
764 | |||
765 | return TRUE; | ||
766 | } | ||
767 | |||
768 | /*-------------- | ||
769 | * InitBitmap | ||
770 | *-------------- | ||
771 | */ | ||
772 | BOOL InitBitmap (BYTE *pDiData, int cxWinSize, int cyWinSize) | ||
773 | { | ||
774 | BYTE *dst; | ||
775 | int x, y, col; | ||
776 | |||
777 | /* initialize the background with gray */ | ||
778 | |||
779 | dst = pDiData; | ||
780 | for (y = 0; y < cyWinSize; y++) | ||
781 | { | ||
782 | col = 0; | ||
783 | for (x = 0; x < cxWinSize; x++) | ||
784 | { | ||
785 | /* fill with GRAY */ | ||
786 | *dst++ = 127; | ||
787 | *dst++ = 127; | ||
788 | *dst++ = 127; | ||
789 | col += 3; | ||
790 | } | ||
791 | /* rows start on 4 byte boundaries */ | ||
792 | while ((col % 4) != 0) | ||
793 | { | ||
794 | dst++; | ||
795 | col++; | ||
796 | } | ||
797 | } | ||
798 | |||
799 | return TRUE; | ||
800 | } | ||
801 | |||
802 | /*-------------- | ||
803 | * FillBitmap | ||
804 | *-------------- | ||
805 | */ | ||
806 | BOOL FillBitmap ( | ||
807 | BYTE *pDiData, int cxWinSize, int cyWinSize, | ||
808 | BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels, | ||
809 | BOOL bStretched) | ||
810 | { | ||
811 | BYTE *pStretchedImage; | ||
812 | BYTE *pImg; | ||
813 | BYTE *src, *dst; | ||
814 | BYTE r, g, b, a; | ||
815 | const int cDIChannels = 3; | ||
816 | WORD wImgRowBytes; | ||
817 | WORD wDIRowBytes; | ||
818 | int cxNewSize, cyNewSize; | ||
819 | int cxImgPos, cyImgPos; | ||
820 | int xImg, yImg; | ||
821 | int xWin, yWin; | ||
822 | int xOld, yOld; | ||
823 | int xNew, yNew; | ||
824 | |||
825 | if (bStretched) | ||
826 | { | ||
827 | cxNewSize = cxWinSize - 2 * MARGIN; | ||
828 | cyNewSize = cyWinSize - 2 * MARGIN; | ||
829 | |||
830 | /* stretch the image to it's window determined size */ | ||
831 | |||
832 | /* the following two are mathematically the same, but the first | ||
833 | * has side-effects because of rounding | ||
834 | */ | ||
835 | /* if ((cyNewSize / cxNewSize) > (cyImgSize / cxImgSize)) */ | ||
836 | if ((cyNewSize * cxImgSize) > (cyImgSize * cxNewSize)) | ||
837 | { | ||
838 | cyNewSize = cxNewSize * cyImgSize / cxImgSize; | ||
839 | cxImgPos = MARGIN; | ||
840 | cyImgPos = (cyWinSize - cyNewSize) / 2; | ||
841 | } | ||
842 | else | ||
843 | { | ||
844 | cxNewSize = cyNewSize * cxImgSize / cyImgSize; | ||
845 | cyImgPos = MARGIN; | ||
846 | cxImgPos = (cxWinSize - cxNewSize) / 2; | ||
847 | } | ||
848 | |||
849 | pStretchedImage = malloc (cImgChannels * cxNewSize * cyNewSize); | ||
850 | pImg = pStretchedImage; | ||
851 | |||
852 | for (yNew = 0; yNew < cyNewSize; yNew++) | ||
853 | { | ||
854 | yOld = yNew * cyImgSize / cyNewSize; | ||
855 | for (xNew = 0; xNew < cxNewSize; xNew++) | ||
856 | { | ||
857 | xOld = xNew * cxImgSize / cxNewSize; | ||
858 | |||
859 | r = *(pbImage + cImgChannels * ((yOld * cxImgSize) + xOld) + 0); | ||
860 | g = *(pbImage + cImgChannels * ((yOld * cxImgSize) + xOld) + 1); | ||
861 | b = *(pbImage + cImgChannels * ((yOld * cxImgSize) + xOld) + 2); | ||
862 | *pImg++ = r; | ||
863 | *pImg++ = g; | ||
864 | *pImg++ = b; | ||
865 | if (cImgChannels == 4) | ||
866 | { | ||
867 | a = *(pbImage + cImgChannels * ((yOld * cxImgSize) + xOld) | ||
868 | + 3); | ||
869 | *pImg++ = a; | ||
870 | } | ||
871 | } | ||
872 | } | ||
873 | |||
874 | /* calculate row-bytes */ | ||
875 | |||
876 | wImgRowBytes = cImgChannels * cxNewSize; | ||
877 | wDIRowBytes = (WORD) ((cDIChannels * cxWinSize + 3L) >> 2) << 2; | ||
878 | |||
879 | /* copy image to screen */ | ||
880 | |||
881 | for (yImg = 0, yWin = cyImgPos; yImg < cyNewSize; yImg++, yWin++) | ||
882 | { | ||
883 | if (yWin >= cyWinSize - cyImgPos) | ||
884 | break; | ||
885 | src = pStretchedImage + yImg * wImgRowBytes; | ||
886 | dst = pDiData + yWin * wDIRowBytes + cxImgPos * cDIChannels; | ||
887 | |||
888 | for (xImg = 0, xWin = cxImgPos; xImg < cxNewSize; xImg++, xWin++) | ||
889 | { | ||
890 | if (xWin >= cxWinSize - cxImgPos) | ||
891 | break; | ||
892 | r = *src++; | ||
893 | g = *src++; | ||
894 | b = *src++; | ||
895 | *dst++ = b; /* note the reverse order */ | ||
896 | *dst++ = g; | ||
897 | *dst++ = r; | ||
898 | if (cImgChannels == 4) | ||
899 | { | ||
900 | a = *src++; | ||
901 | } | ||
902 | } | ||
903 | } | ||
904 | |||
905 | /* free memory */ | ||
906 | |||
907 | if (pStretchedImage != NULL) | ||
908 | { | ||
909 | free (pStretchedImage); | ||
910 | pStretchedImage = NULL; | ||
911 | } | ||
912 | |||
913 | } | ||
914 | |||
915 | /* process the image not-stretched */ | ||
916 | |||
917 | else | ||
918 | { | ||
919 | /* calculate the central position */ | ||
920 | |||
921 | cxImgPos = (cxWinSize - cxImgSize) / 2; | ||
922 | cyImgPos = (cyWinSize - cyImgSize) / 2; | ||
923 | |||
924 | /* check for image larger than window */ | ||
925 | |||
926 | if (cxImgPos < MARGIN) | ||
927 | cxImgPos = MARGIN; | ||
928 | if (cyImgPos < MARGIN) | ||
929 | cyImgPos = MARGIN; | ||
930 | |||
931 | /* calculate both row-bytes */ | ||
932 | |||
933 | wImgRowBytes = cImgChannels * cxImgSize; | ||
934 | wDIRowBytes = (WORD) ((cDIChannels * cxWinSize + 3L) >> 2) << 2; | ||
935 | |||
936 | /* copy image to screen */ | ||
937 | |||
938 | for (yImg = 0, yWin = cyImgPos; yImg < cyImgSize; yImg++, yWin++) | ||
939 | { | ||
940 | if (yWin >= cyWinSize - MARGIN) | ||
941 | break; | ||
942 | src = pbImage + yImg * wImgRowBytes; | ||
943 | dst = pDiData + yWin * wDIRowBytes + cxImgPos * cDIChannels; | ||
944 | |||
945 | for (xImg = 0, xWin = cxImgPos; xImg < cxImgSize; xImg++, xWin++) | ||
946 | { | ||
947 | if (xWin >= cxWinSize - MARGIN) | ||
948 | break; | ||
949 | r = *src++; | ||
950 | g = *src++; | ||
951 | b = *src++; | ||
952 | *dst++ = b; /* note the reverse order */ | ||
953 | *dst++ = g; | ||
954 | *dst++ = r; | ||
955 | if (cImgChannels == 4) | ||
956 | { | ||
957 | a = *src++; | ||
958 | } | ||
959 | } | ||
960 | } | ||
961 | } | ||
962 | |||
963 | return TRUE; | ||
964 | } | ||
965 | |||
966 | /*----------------- | ||
967 | * end of source | ||
968 | *----------------- | ||
969 | */ | ||
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/VisualPng.ico b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/VisualPng.ico new file mode 100644 index 0000000..68aa371 --- /dev/null +++ b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/VisualPng.ico | |||
Binary files differ | |||
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/VisualPng.png b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/VisualPng.png new file mode 100644 index 0000000..c6aa80a --- /dev/null +++ b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/VisualPng.png | |||
Binary files differ | |||
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/VisualPng.rc b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/VisualPng.rc new file mode 100644 index 0000000..6e0623a --- /dev/null +++ b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/VisualPng.rc | |||
@@ -0,0 +1,152 @@ | |||
1 | //Microsoft Developer Studio generated resource script. | ||
2 | // | ||
3 | #include "resource.h" | ||
4 | |||
5 | #define APSTUDIO_READONLY_SYMBOLS | ||
6 | ///////////////////////////////////////////////////////////////////////////// | ||
7 | // | ||
8 | // Generated from the TEXTINCLUDE 2 resource. | ||
9 | // | ||
10 | #include "afxres.h" | ||
11 | |||
12 | ///////////////////////////////////////////////////////////////////////////// | ||
13 | #undef APSTUDIO_READONLY_SYMBOLS | ||
14 | |||
15 | ///////////////////////////////////////////////////////////////////////////// | ||
16 | // English (U.S.) resources | ||
17 | |||
18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) | ||
19 | #ifdef _WIN32 | ||
20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US | ||
21 | #pragma code_page(1252) | ||
22 | #endif //_WIN32 | ||
23 | |||
24 | #ifdef APSTUDIO_INVOKED | ||
25 | ///////////////////////////////////////////////////////////////////////////// | ||
26 | // | ||
27 | // TEXTINCLUDE | ||
28 | // | ||
29 | |||
30 | 1 TEXTINCLUDE DISCARDABLE | ||
31 | BEGIN | ||
32 | "resource.h\0" | ||
33 | END | ||
34 | |||
35 | 2 TEXTINCLUDE DISCARDABLE | ||
36 | BEGIN | ||
37 | "#include ""afxres.h""\r\n" | ||
38 | "\0" | ||
39 | END | ||
40 | |||
41 | 3 TEXTINCLUDE DISCARDABLE | ||
42 | BEGIN | ||
43 | "\r\n" | ||
44 | "\0" | ||
45 | END | ||
46 | |||
47 | #endif // APSTUDIO_INVOKED | ||
48 | |||
49 | |||
50 | ///////////////////////////////////////////////////////////////////////////// | ||
51 | // | ||
52 | // Menu | ||
53 | // | ||
54 | |||
55 | VISUALPNG MENU DISCARDABLE | ||
56 | BEGIN | ||
57 | POPUP "&File" | ||
58 | BEGIN | ||
59 | MENUITEM "&Open Image...\tCtrl+O", IDM_FILE_OPEN | ||
60 | MENUITEM "Save &As...", IDM_FILE_SAVE | ||
61 | MENUITEM SEPARATOR | ||
62 | MENUITEM "&Next Image\tCtrl+N", IDM_FILE_NEXT | ||
63 | MENUITEM "Pre&vious Image\tCtrl+V", IDM_FILE_PREVIOUS | ||
64 | MENUITEM SEPARATOR | ||
65 | MENUITEM "E&xit\tAlt+X", IDM_FILE_EXIT | ||
66 | END | ||
67 | POPUP "&Options" | ||
68 | BEGIN | ||
69 | MENUITEM "&Stretch", IDM_OPTIONS_STRETCH, CHECKED | ||
70 | END | ||
71 | POPUP "&Help" | ||
72 | BEGIN | ||
73 | MENUITEM "&About", IDM_HELP_ABOUT | ||
74 | END | ||
75 | END | ||
76 | |||
77 | |||
78 | ///////////////////////////////////////////////////////////////////////////// | ||
79 | // | ||
80 | // Accelerator | ||
81 | // | ||
82 | |||
83 | VISUALPNG ACCELERATORS DISCARDABLE | ||
84 | BEGIN | ||
85 | "N", IDM_FILE_NEXT, VIRTKEY, CONTROL, NOINVERT | ||
86 | "O", IDM_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT | ||
87 | "P", IDM_FILE_PREVIOUS, VIRTKEY, CONTROL, NOINVERT | ||
88 | "V", IDM_FILE_PREVIOUS, VIRTKEY, CONTROL, NOINVERT | ||
89 | "X", IDM_FILE_EXIT, VIRTKEY, ALT, NOINVERT | ||
90 | END | ||
91 | |||
92 | |||
93 | ///////////////////////////////////////////////////////////////////////////// | ||
94 | // | ||
95 | // Icon | ||
96 | // | ||
97 | |||
98 | // Icon with lowest ID value placed first to ensure application icon | ||
99 | // remains consistent on all systems. | ||
100 | VISUALPNG ICON DISCARDABLE "VisualPng.ico" | ||
101 | |||
102 | ///////////////////////////////////////////////////////////////////////////// | ||
103 | // | ||
104 | // Dialog | ||
105 | // | ||
106 | |||
107 | ABOUTBOX DIALOG DISCARDABLE 0, 0, 186, 94 | ||
108 | STYLE DS_MODALFRAME | WS_POPUP | ||
109 | FONT 8, "MS Sans Serif" | ||
110 | BEGIN | ||
111 | DEFPUSHBUTTON "OK",IDOK,68,67,50,14 | ||
112 | CTEXT "VisualPng 1.0 - June 2000",IDC_STATIC,49,14,88,8 | ||
113 | LTEXT "a PNG image viewer",IDC_STATIC,60,30,66,8 | ||
114 | LTEXT "(c) Willem van Schaik, 2000",IDC_STATIC,48,52,90,8 | ||
115 | LTEXT "to demonstrate the use of libpng in Visual C", | ||
116 | IDC_STATIC,25,38,136,8 | ||
117 | END | ||
118 | |||
119 | |||
120 | ///////////////////////////////////////////////////////////////////////////// | ||
121 | // | ||
122 | // DESIGNINFO | ||
123 | // | ||
124 | |||
125 | #ifdef APSTUDIO_INVOKED | ||
126 | GUIDELINES DESIGNINFO DISCARDABLE | ||
127 | BEGIN | ||
128 | "ABOUTBOX", DIALOG | ||
129 | BEGIN | ||
130 | LEFTMARGIN, 7 | ||
131 | RIGHTMARGIN, 179 | ||
132 | TOPMARGIN, 7 | ||
133 | BOTTOMMARGIN, 87 | ||
134 | END | ||
135 | END | ||
136 | #endif // APSTUDIO_INVOKED | ||
137 | |||
138 | #endif // English (U.S.) resources | ||
139 | ///////////////////////////////////////////////////////////////////////////// | ||
140 | |||
141 | |||
142 | |||
143 | #ifndef APSTUDIO_INVOKED | ||
144 | ///////////////////////////////////////////////////////////////////////////// | ||
145 | // | ||
146 | // Generated from the TEXTINCLUDE 3 resource. | ||
147 | // | ||
148 | |||
149 | |||
150 | ///////////////////////////////////////////////////////////////////////////// | ||
151 | #endif // not APSTUDIO_INVOKED | ||
152 | |||
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/cexcept.h b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/cexcept.h new file mode 100644 index 0000000..83c8bfe --- /dev/null +++ b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/cexcept.h | |||
@@ -0,0 +1,248 @@ | |||
1 | /*=== | ||
2 | cexcept.h 2.0.1 (2008-Jul-19-Sat) | ||
3 | http://www.nicemice.net/cexcept/ | ||
4 | Adam M. Costello | ||
5 | http://www.nicemice.net/amc/ | ||
6 | |||
7 | An interface for exception-handling in ANSI C (C89 and subsequent ISO | ||
8 | standards), developed jointly with Cosmin Truta. | ||
9 | |||
10 | Copyright (c) 2000-2008 Adam M. Costello and Cosmin Truta. | ||
11 | This software may be modified only if its author and version | ||
12 | information is updated accurately, and may be redistributed | ||
13 | only if accompanied by this unaltered notice. Subject to those | ||
14 | restrictions, permission is granted to anyone to do anything | ||
15 | with this software. The copyright holders make no guarantees | ||
16 | regarding this software, and are not responsible for any damage | ||
17 | resulting from its use. | ||
18 | |||
19 | The cexcept interface is not compatible with and cannot interact | ||
20 | with system exceptions (like division by zero or memory segmentation | ||
21 | violation), compiler-generated exceptions (like C++ exceptions), or | ||
22 | other exception-handling interfaces. | ||
23 | |||
24 | When using this interface across multiple .c files, do not include | ||
25 | this header file directly. Instead, create a wrapper header file that | ||
26 | includes this header file and then invokes the define_exception_type | ||
27 | macro (see below). The .c files should then include that header file. | ||
28 | |||
29 | The interface consists of one type, one well-known name, and six macros. | ||
30 | |||
31 | |||
32 | define_exception_type(type_name); | ||
33 | |||
34 | This macro is used like an external declaration. It specifies | ||
35 | the type of object that gets copied from the exception thrower to | ||
36 | the exception catcher. The type_name can be any type that can be | ||
37 | assigned to, that is, a non-constant arithmetic type, struct, union, | ||
38 | or pointer. Examples: | ||
39 | |||
40 | define_exception_type(int); | ||
41 | |||
42 | enum exception { out_of_memory, bad_arguments, disk_full }; | ||
43 | define_exception_type(enum exception); | ||
44 | |||
45 | struct exception { int code; const char *msg; }; | ||
46 | define_exception_type(struct exception); | ||
47 | |||
48 | Because throwing an exception causes the object to be copied (not | ||
49 | just once, but twice), programmers may wish to consider size when | ||
50 | choosing the exception type. | ||
51 | |||
52 | |||
53 | struct exception_context; | ||
54 | |||
55 | This type may be used after the define_exception_type() macro has | ||
56 | been invoked. A struct exception_context must be known to both | ||
57 | the thrower and the catcher. It is expected that there be one | ||
58 | context for each thread that uses exceptions. It would certainly | ||
59 | be dangerous for multiple threads to access the same context. | ||
60 | One thread can use multiple contexts, but that is likely to be | ||
61 | confusing and not typically useful. The application can allocate | ||
62 | this structure in any way it pleases--automatic, static, or dynamic. | ||
63 | The application programmer should pretend not to know the structure | ||
64 | members, which are subject to change. | ||
65 | |||
66 | |||
67 | struct exception_context *the_exception_context; | ||
68 | |||
69 | The Try/Catch and Throw statements (described below) implicitly | ||
70 | refer to a context, using the name the_exception_context. It is | ||
71 | the application's responsibility to make sure that this name yields | ||
72 | the address of a mutable (non-constant) struct exception_context | ||
73 | wherever those statements are used. Subject to that constraint, the | ||
74 | application may declare a variable of this name anywhere it likes | ||
75 | (inside a function, in a parameter list, or externally), and may | ||
76 | use whatever storage class specifiers (static, extern, etc) or type | ||
77 | qualifiers (const, volatile, etc) it likes. Examples: | ||
78 | |||
79 | static struct exception_context | ||
80 | * const the_exception_context = &foo; | ||
81 | |||
82 | { struct exception_context *the_exception_context = bar; ... } | ||
83 | |||
84 | int blah(struct exception_context *the_exception_context, ...); | ||
85 | |||
86 | extern struct exception_context the_exception_context[1]; | ||
87 | |||
88 | The last example illustrates a trick that avoids creating a pointer | ||
89 | object separate from the structure object. | ||
90 | |||
91 | The name could even be a macro, for example: | ||
92 | |||
93 | struct exception_context ec_array[numthreads]; | ||
94 | #define the_exception_context (ec_array + thread_id) | ||
95 | |||
96 | Be aware that the_exception_context is used several times by the | ||
97 | Try/Catch/Throw macros, so it shouldn't be expensive or have side | ||
98 | effects. The expansion must be a drop-in replacement for an | ||
99 | identifier, so it's safest to put parentheses around it. | ||
100 | |||
101 | |||
102 | void init_exception_context(struct exception_context *ec); | ||
103 | |||
104 | For context structures allocated statically (by an external | ||
105 | definition or using the "static" keyword), the implicit | ||
106 | initialization to all zeros is sufficient, but contexts allocated | ||
107 | by other means must be initialized using this macro before they | ||
108 | are used by a Try/Catch statement. It does no harm to initialize | ||
109 | a context more than once (by using this macro on a statically | ||
110 | allocated context, or using this macro twice on the same context), | ||
111 | but a context must not be re-initialized after it has been used by a | ||
112 | Try/Catch statement. | ||
113 | |||
114 | |||
115 | Try statement | ||
116 | Catch (expression) statement | ||
117 | |||
118 | The Try/Catch/Throw macros are capitalized in order to avoid | ||
119 | confusion with the C++ keywords, which have subtly different | ||
120 | semantics. | ||
121 | |||
122 | A Try/Catch statement has a syntax similar to an if/else statement, | ||
123 | except that the parenthesized expression goes after the second | ||
124 | keyword rather than the first. As with if/else, there are two | ||
125 | clauses, each of which may be a simple statement ending with a | ||
126 | semicolon or a brace-enclosed compound statement. But whereas | ||
127 | the else clause is optional, the Catch clause is required. The | ||
128 | expression must be a modifiable lvalue (something capable of being | ||
129 | assigned to) of the same type (disregarding type qualifiers) that | ||
130 | was passed to define_exception_type(). | ||
131 | |||
132 | If a Throw that uses the same exception context as the Try/Catch is | ||
133 | executed within the Try clause (typically within a function called | ||
134 | by the Try clause), and the exception is not caught by a nested | ||
135 | Try/Catch statement, then a copy of the exception will be assigned | ||
136 | to the expression, and control will jump to the Catch clause. If no | ||
137 | such Throw is executed, then the assignment is not performed, and | ||
138 | the Catch clause is not executed. | ||
139 | |||
140 | The expression is not evaluated unless and until the exception is | ||
141 | caught, which is significant if it has side effects, for example: | ||
142 | |||
143 | Try foo(); | ||
144 | Catch (p[++i].e) { ... } | ||
145 | |||
146 | IMPORTANT: Jumping into or out of a Try clause (for example via | ||
147 | return, break, continue, goto, longjmp) is forbidden--the compiler | ||
148 | will not complain, but bad things will happen at run-time. Jumping | ||
149 | into or out of a Catch clause is okay, and so is jumping around | ||
150 | inside a Try clause. In many cases where one is tempted to return | ||
151 | from a Try clause, it will suffice to use Throw, and then return | ||
152 | from the Catch clause. Another option is to set a flag variable and | ||
153 | use goto to jump to the end of the Try clause, then check the flag | ||
154 | after the Try/Catch statement. | ||
155 | |||
156 | IMPORTANT: The values of any non-volatile automatic variables | ||
157 | changed within the Try clause are undefined after an exception is | ||
158 | caught. Therefore, variables modified inside the Try block whose | ||
159 | values are needed later outside the Try block must either use static | ||
160 | storage or be declared with the "volatile" type qualifier. | ||
161 | |||
162 | |||
163 | Throw expression; | ||
164 | |||
165 | A Throw statement is very much like a return statement, except that | ||
166 | the expression is required. Whereas return jumps back to the place | ||
167 | where the current function was called, Throw jumps back to the Catch | ||
168 | clause of the innermost enclosing Try clause. The expression must | ||
169 | be compatible with the type passed to define_exception_type(). The | ||
170 | exception must be caught, otherwise the program may crash. | ||
171 | |||
172 | Slight limitation: If the expression is a comma-expression, it must | ||
173 | be enclosed in parentheses. | ||
174 | |||
175 | |||
176 | Try statement | ||
177 | Catch_anonymous statement | ||
178 | |||
179 | When the value of the exception is not needed, a Try/Catch statement | ||
180 | can use Catch_anonymous instead of Catch (expression). | ||
181 | |||
182 | |||
183 | Everything below this point is for the benefit of the compiler. The | ||
184 | application programmer should pretend not to know any of it, because it | ||
185 | is subject to change. | ||
186 | |||
187 | ===*/ | ||
188 | |||
189 | |||
190 | #ifndef CEXCEPT_H | ||
191 | #define CEXCEPT_H | ||
192 | |||
193 | |||
194 | #include <setjmp.h> | ||
195 | |||
196 | #define define_exception_type(etype) \ | ||
197 | struct exception_context { \ | ||
198 | jmp_buf *penv; \ | ||
199 | int caught; \ | ||
200 | volatile struct { etype etmp; } v; \ | ||
201 | } | ||
202 | |||
203 | /* etmp must be volatile because the application might use automatic */ | ||
204 | /* storage for the_exception_context, and etmp is modified between */ | ||
205 | /* the calls to setjmp() and longjmp(). A wrapper struct is used to */ | ||
206 | /* avoid warnings about a duplicate volatile qualifier in case etype */ | ||
207 | /* already includes it. */ | ||
208 | |||
209 | #define init_exception_context(ec) ((void)((ec)->penv = 0)) | ||
210 | |||
211 | #define Try \ | ||
212 | { \ | ||
213 | jmp_buf *exception__prev, exception__env; \ | ||
214 | exception__prev = the_exception_context->penv; \ | ||
215 | the_exception_context->penv = &exception__env; \ | ||
216 | if (setjmp(exception__env) == 0) { \ | ||
217 | do | ||
218 | |||
219 | #define exception__catch(action) \ | ||
220 | while (the_exception_context->caught = 0, \ | ||
221 | the_exception_context->caught); \ | ||
222 | } \ | ||
223 | else { \ | ||
224 | the_exception_context->caught = 1; \ | ||
225 | } \ | ||
226 | the_exception_context->penv = exception__prev; \ | ||
227 | } \ | ||
228 | if (!the_exception_context->caught || action) { } \ | ||
229 | else | ||
230 | |||
231 | #define Catch(e) exception__catch(((e) = the_exception_context->v.etmp, 0)) | ||
232 | #define Catch_anonymous exception__catch(0) | ||
233 | |||
234 | /* Try ends with do, and Catch begins with while(0) and ends with */ | ||
235 | /* else, to ensure that Try/Catch syntax is similar to if/else */ | ||
236 | /* syntax. */ | ||
237 | /* */ | ||
238 | /* The 0 in while(0) is expressed as x=0,x in order to appease */ | ||
239 | /* compilers that warn about constant expressions inside while(). */ | ||
240 | /* Most compilers should still recognize that the condition is always */ | ||
241 | /* false and avoid generating code for it. */ | ||
242 | |||
243 | #define Throw \ | ||
244 | for (;; longjmp(*the_exception_context->penv, 1)) \ | ||
245 | the_exception_context->v.etmp = | ||
246 | |||
247 | |||
248 | #endif /* CEXCEPT_H */ | ||
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/resource.h b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/resource.h new file mode 100644 index 0000000..a06050a --- /dev/null +++ b/libraries/irrlicht-1.8/source/Irrlicht/libpng/contrib/visupng/resource.h | |||
@@ -0,0 +1,23 @@ | |||
1 | //{{NO_DEPENDENCIES}} | ||
2 | // Microsoft Developer Studio generated include file. | ||
3 | // Used by VisualPng.rc | ||
4 | // | ||
5 | #define IDM_FILE_OPEN 40001 | ||
6 | #define IDM_FILE_SAVE 40002 | ||
7 | #define IDM_FILE_NEXT 40003 | ||
8 | #define IDM_FILE_PREVIOUS 40004 | ||
9 | #define IDM_FILE_EXIT 40005 | ||
10 | #define IDM_OPTIONS_BACKGROUND 40006 | ||
11 | #define IDM_OPTIONS_STRETCH 40007 | ||
12 | #define IDM_HELP_ABOUT 40008 | ||
13 | |||
14 | // Next default values for new objects | ||
15 | // | ||
16 | #ifdef APSTUDIO_INVOKED | ||
17 | #ifndef APSTUDIO_READONLY_SYMBOLS | ||
18 | #define _APS_NEXT_RESOURCE_VALUE 113 | ||
19 | #define _APS_NEXT_COMMAND_VALUE 40009 | ||
20 | #define _APS_NEXT_CONTROL_VALUE 1001 | ||
21 | #define _APS_NEXT_SYMED_VALUE 101 | ||
22 | #endif | ||
23 | #endif | ||