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