Skip to content

Latest commit

 

History

History
520 lines (466 loc) · 15.4 KB

IMG_png.c

File metadata and controls

520 lines (466 loc) · 15.4 KB
 
Aug 10, 2000
Aug 10, 2000
1
/*
Dec 14, 2001
Dec 14, 2001
2
SDL_image: An example image loading library for use with SDL
Feb 4, 2006
Feb 4, 2006
3
Copyright (C) 1997-2006 Sam Lantinga
Aug 10, 2000
Aug 10, 2000
4
5
This library is free software; you can redistribute it and/or
Feb 4, 2006
Feb 4, 2006
6
modify it under the terms of the GNU Lesser General Public
Aug 10, 2000
Aug 10, 2000
7
License as published by the Free Software Foundation; either
Feb 4, 2006
Feb 4, 2006
8
version 2.1 of the License, or (at your option) any later version.
Aug 10, 2000
Aug 10, 2000
9
10
11
12
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Feb 4, 2006
Feb 4, 2006
13
Lesser General Public License for more details.
Aug 10, 2000
Aug 10, 2000
14
Feb 4, 2006
Feb 4, 2006
15
16
17
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Aug 10, 2000
Aug 10, 2000
18
19
Sam Lantinga
Dec 14, 2001
Dec 14, 2001
20
slouken@libsdl.org
Aug 10, 2000
Aug 10, 2000
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
*/
/* This is a PNG image file loading framework */
#include <stdlib.h>
#include <stdio.h>
#include "SDL_image.h"
#ifdef LOAD_PNG
/*=============================================================================
File: SDL_png.c
Purpose: A PNG loader and saver for the SDL library
Revision:
Created by: Philippe Lavoie (2 November 1998)
lavoie@zeus.genie.uottawa.ca
Modified by:
Copyright notice:
Copyright (C) 1998 Philippe Lavoie
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Comments: The load and save routine are basically the ones you can find
in the example.c file from the libpng distribution.
Changes:
5/17/99 - Modified to use the new SDL data sources - Sam Lantinga
=============================================================================*/
#include "SDL_endian.h"
Nov 30, 2000
Nov 30, 2000
67
68
69
#ifdef macintosh
#define MACOS
#endif
Aug 10, 2000
Aug 10, 2000
70
71
72
73
#include <png.h>
#define PNG_BYTES_TO_CHECK 4
May 12, 2006
May 12, 2006
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
static struct {
int loaded;
void *handle;
png_infop (*png_create_info_struct) (png_structp png_ptr);
png_structp (*png_create_read_struct) (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn);
void (*png_destroy_read_struct) (png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr);
png_uint_32 (*png_get_IHDR) (png_structp png_ptr, png_infop info_ptr, png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type, int *interlace_method, int *compression_method, int *filter_method);
png_voidp (*png_get_io_ptr) (png_structp png_ptr);
png_uint_32 (*png_get_tRNS) (png_structp png_ptr, png_infop info_ptr, png_bytep *trans, int *num_trans, png_color_16p *trans_values);
png_uint_32 (*png_get_valid) (png_structp png_ptr, png_infop info_ptr, png_uint_32 flag);
void (*png_read_image) (png_structp png_ptr, png_bytepp image);
void (*png_read_info) (png_structp png_ptr, png_infop info_ptr);
void (*png_read_update_info) (png_structp png_ptr, png_infop info_ptr);
void (*png_set_expand) (png_structp png_ptr);
void (*png_set_gray_to_rgb) (png_structp png_ptr);
void (*png_set_packing) (png_structp png_ptr);
void (*png_set_read_fn) (png_structp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn);
void (*png_set_strip_16) (png_structp png_ptr);
int (*png_sig_cmp) (png_bytep sig, png_size_t start, png_size_t num_to_check);
} lib;
#ifdef LOAD_PNG_DYNAMIC
int IMG_InitPNG()
{
if ( lib.loaded == 0 ) {
lib.handle = SDL_LoadObject(LOAD_PNG_DYNAMIC);
if ( lib.handle == NULL ) {
return -1;
}
lib.png_create_info_struct =
(png_infop (*) (png_structp))
SDL_LoadFunction(lib.handle, "png_create_info_struct");
if ( lib.png_create_info_struct == NULL ) {
SDL_UnloadObject(lib.handle);
return -1;
}
lib.png_create_read_struct =
(png_structp (*) (png_const_charp, png_voidp, png_error_ptr, png_error_ptr))
SDL_LoadFunction(lib.handle, "png_create_read_struct");
if ( lib.png_create_read_struct == NULL ) {
SDL_UnloadObject(lib.handle);
return -1;
}
lib.png_destroy_read_struct =
(void (*) (png_structpp, png_infopp, png_infopp))
SDL_LoadFunction(lib.handle, "png_destroy_read_struct");
if ( lib.png_destroy_read_struct == NULL ) {
SDL_UnloadObject(lib.handle);
return -1;
}
lib.png_get_IHDR =
(png_uint_32 (*) (png_structp, png_infop, png_uint_32 *, png_uint_32 *, int *, int *, int *, int *, int *))
SDL_LoadFunction(lib.handle, "png_get_IHDR");
if ( lib.png_get_IHDR == NULL ) {
SDL_UnloadObject(lib.handle);
return -1;
}
lib.png_get_io_ptr =
(png_voidp (*) (png_structp))
SDL_LoadFunction(lib.handle, "png_get_io_ptr");
if ( lib.png_get_io_ptr == NULL ) {
SDL_UnloadObject(lib.handle);
return -1;
}
lib.png_get_tRNS =
(png_uint_32 (*) (png_structp, png_infop, png_bytep *, int *, png_color_16p *))
SDL_LoadFunction(lib.handle, "png_get_tRNS");
if ( lib.png_get_tRNS == NULL ) {
SDL_UnloadObject(lib.handle);
return -1;
}
lib.png_get_valid =
(png_uint_32 (*) (png_structp, png_infop, png_uint_32))
SDL_LoadFunction(lib.handle, "png_get_valid");
if ( lib.png_get_valid == NULL ) {
SDL_UnloadObject(lib.handle);
return -1;
}
lib.png_read_image =
(void (*) (png_structp, png_bytepp))
SDL_LoadFunction(lib.handle, "png_read_image");
if ( lib.png_read_image == NULL ) {
SDL_UnloadObject(lib.handle);
return -1;
}
lib.png_read_info =
(void (*) (png_structp, png_infop))
SDL_LoadFunction(lib.handle, "png_read_info");
if ( lib.png_read_info == NULL ) {
SDL_UnloadObject(lib.handle);
return -1;
}
lib.png_read_update_info =
(void (*) (png_structp, png_infop))
SDL_LoadFunction(lib.handle, "png_read_update_info");
if ( lib.png_read_update_info == NULL ) {
SDL_UnloadObject(lib.handle);
return -1;
}
lib.png_set_expand =
(void (*) (png_structp))
SDL_LoadFunction(lib.handle, "png_set_expand");
if ( lib.png_set_expand == NULL ) {
SDL_UnloadObject(lib.handle);
return -1;
}
lib.png_set_gray_to_rgb =
(void (*) (png_structp))
SDL_LoadFunction(lib.handle, "png_set_gray_to_rgb");
if ( lib.png_set_gray_to_rgb == NULL ) {
SDL_UnloadObject(lib.handle);
return -1;
}
lib.png_set_packing =
(void (*) (png_structp))
SDL_LoadFunction(lib.handle, "png_set_packing");
if ( lib.png_set_packing == NULL ) {
SDL_UnloadObject(lib.handle);
return -1;
}
lib.png_set_read_fn =
(void (*) (png_structp, png_voidp, png_rw_ptr))
SDL_LoadFunction(lib.handle, "png_set_read_fn");
if ( lib.png_set_read_fn == NULL ) {
SDL_UnloadObject(lib.handle);
return -1;
}
lib.png_set_strip_16 =
(void (*) (png_structp))
SDL_LoadFunction(lib.handle, "png_set_strip_16");
if ( lib.png_set_strip_16 == NULL ) {
SDL_UnloadObject(lib.handle);
return -1;
}
lib.png_sig_cmp =
(int (*) (png_bytep, png_size_t, png_size_t))
SDL_LoadFunction(lib.handle, "png_sig_cmp");
if ( lib.png_sig_cmp == NULL ) {
SDL_UnloadObject(lib.handle);
return -1;
}
}
++lib.loaded;
return 0;
}
void IMG_QuitPNG()
{
if ( lib.loaded == 0 ) {
return;
}
if ( lib.loaded == 1 ) {
SDL_UnloadObject(lib.handle);
}
--lib.loaded;
}
#else
int IMG_InitPNG()
{
if ( lib.loaded == 0 ) {
lib.png_create_info_struct = png_create_info_struct;
lib.png_create_read_struct = png_create_read_struct;
lib.png_destroy_read_struct = png_destroy_read_struct;
lib.png_get_IHDR = png_get_IHDR;
lib.png_get_io_ptr = png_get_io_ptr;
lib.png_get_tRNS = png_get_tRNS;
lib.png_get_valid = png_get_valid;
lib.png_read_image = png_read_image;
lib.png_read_info = png_read_info;
lib.png_read_update_info = png_read_update_info;
lib.png_set_expand = png_set_expand;
lib.png_set_gray_to_rgb = png_set_gray_to_rgb;
lib.png_set_packing = png_set_packing;
lib.png_set_read_fn = png_set_read_fn;
lib.png_set_strip_16 = png_set_strip_16;
lib.png_sig_cmp = png_sig_cmp;
}
++lib.loaded;
May 13, 2006
May 13, 2006
252
253
return 0;
May 12, 2006
May 12, 2006
254
255
256
257
258
259
260
261
262
263
264
265
}
void IMG_QuitPNG()
{
if ( lib.loaded == 0 ) {
return;
}
if ( lib.loaded == 1 ) {
}
--lib.loaded;
}
#endif /* LOAD_PNG_DYNAMIC */
Aug 10, 2000
Aug 10, 2000
266
267
268
/* See if an image is contained in a data source */
int IMG_isPNG(SDL_RWops *src)
{
Feb 4, 2006
Feb 4, 2006
269
270
271
272
int start;
int is_PNG;
unsigned char buf[PNG_BYTES_TO_CHECK];
May 12, 2006
May 12, 2006
273
274
275
if ( IMG_InitPNG() < 0 ) {
return 0;
}
Feb 4, 2006
Feb 4, 2006
276
277
278
start = SDL_RWtell(src);
is_PNG = 0;
if ( SDL_RWread(src, buf, 1, PNG_BYTES_TO_CHECK) == PNG_BYTES_TO_CHECK ) {
May 12, 2006
May 12, 2006
279
is_PNG = (lib.png_sig_cmp(buf, (png_size_t)0, PNG_BYTES_TO_CHECK) == 0);
Feb 4, 2006
Feb 4, 2006
280
281
}
SDL_RWseek(src, start, SEEK_SET);
May 12, 2006
May 12, 2006
282
IMG_QuitPNG();
Feb 4, 2006
Feb 4, 2006
283
return(is_PNG);
Aug 10, 2000
Aug 10, 2000
284
285
286
287
288
289
290
}
/* Load a PNG type image from an SDL datasource */
static void png_read_data(png_structp ctx, png_bytep area, png_size_t size)
{
SDL_RWops *src;
May 12, 2006
May 12, 2006
291
src = (SDL_RWops *)lib.png_get_io_ptr(ctx);
Aug 10, 2000
Aug 10, 2000
292
293
294
295
SDL_RWread(src, area, size, 1);
}
SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src)
{
Feb 4, 2006
Feb 4, 2006
296
297
int start;
const char *error;
Nov 29, 2000
Nov 29, 2000
298
SDL_Surface *volatile surface;
Aug 10, 2000
Aug 10, 2000
299
300
301
302
303
304
305
306
307
png_structp png_ptr;
png_infop info_ptr;
png_uint_32 width, height;
int bit_depth, color_type, interlace_type;
Uint32 Rmask;
Uint32 Gmask;
Uint32 Bmask;
Uint32 Amask;
SDL_Palette *palette;
Nov 29, 2000
Nov 29, 2000
308
png_bytep *volatile row_pointers;
Aug 10, 2000
Aug 10, 2000
309
int row, i;
Nov 29, 2000
Nov 29, 2000
310
volatile int ckey = -1;
Aug 10, 2000
Aug 10, 2000
311
312
png_color_16 *transv;
Jan 4, 2004
Jan 4, 2004
313
314
315
316
if ( !src ) {
/* The error message has been set in SDL_RWFromFile */
return NULL;
}
Feb 4, 2006
Feb 4, 2006
317
start = SDL_RWtell(src);
Jan 4, 2004
Jan 4, 2004
318
May 12, 2006
May 12, 2006
319
320
321
322
if ( IMG_InitPNG() < 0 ) {
return NULL;
}
Aug 10, 2000
Aug 10, 2000
323
/* Initialize the data we will clean up when we're done */
Feb 4, 2006
Feb 4, 2006
324
error = NULL;
Aug 10, 2000
Aug 10, 2000
325
326
327
png_ptr = NULL; info_ptr = NULL; row_pointers = NULL; surface = NULL;
/* Create the PNG loading context structure */
May 12, 2006
May 12, 2006
328
png_ptr = lib.png_create_read_struct(PNG_LIBPNG_VER_STRING,
Aug 10, 2000
Aug 10, 2000
329
330
NULL,NULL,NULL);
if (png_ptr == NULL){
Feb 4, 2006
Feb 4, 2006
331
error = "Couldn't allocate memory for PNG file or incompatible PNG dll";
Aug 10, 2000
Aug 10, 2000
332
333
334
335
goto done;
}
/* Allocate/initialize the memory for image information. REQUIRED. */
May 12, 2006
May 12, 2006
336
info_ptr = lib.png_create_info_struct(png_ptr);
Aug 10, 2000
Aug 10, 2000
337
if (info_ptr == NULL) {
Feb 4, 2006
Feb 4, 2006
338
error = "Couldn't create image information for PNG file";
Aug 10, 2000
Aug 10, 2000
339
340
341
342
343
344
345
346
goto done;
}
/* Set error handling if you are using setjmp/longjmp method (this is
* the normal method of doing things with libpng). REQUIRED unless you
* set up your own error handlers in png_create_read_struct() earlier.
*/
if ( setjmp(png_ptr->jmpbuf) ) {
Feb 4, 2006
Feb 4, 2006
347
error = "Error reading the PNG file.";
Aug 10, 2000
Aug 10, 2000
348
349
350
351
goto done;
}
/* Set up the input control */
May 12, 2006
May 12, 2006
352
lib.png_set_read_fn(png_ptr, src, png_read_data);
Aug 10, 2000
Aug 10, 2000
353
354
/* Read PNG header info */
May 12, 2006
May 12, 2006
355
356
lib.png_read_info(png_ptr, info_ptr);
lib.png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth,
Aug 10, 2000
Aug 10, 2000
357
358
359
&color_type, &interlace_type, NULL, NULL);
/* tell libpng to strip 16 bit/color files down to 8 bits/color */
May 12, 2006
May 12, 2006
360
lib.png_set_strip_16(png_ptr) ;
Aug 10, 2000
Aug 10, 2000
361
362
363
364
/* Extract multiple pixels with bit depths of 1, 2, and 4 from a single
* byte into separate bytes (useful for paletted and grayscale images).
*/
May 12, 2006
May 12, 2006
365
lib.png_set_packing(png_ptr);
Aug 10, 2000
Aug 10, 2000
366
Sep 1, 2000
Sep 1, 2000
367
368
/* scale greyscale values to the range 0..255 */
if(color_type == PNG_COLOR_TYPE_GRAY)
May 12, 2006
May 12, 2006
369
lib.png_set_expand(png_ptr);
Aug 10, 2000
Aug 10, 2000
370
371
/* For images with a single "transparent colour", set colour key;
Jul 31, 2001
Jul 31, 2001
372
373
if more than one index has transparency, or if partially transparent
entries exist, use full alpha channel */
May 12, 2006
May 12, 2006
374
if (lib.png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
Aug 10, 2000
Aug 10, 2000
375
376
int num_trans;
Uint8 *trans;
May 12, 2006
May 12, 2006
377
lib.png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans,
Aug 10, 2000
Aug 10, 2000
378
379
&transv);
if(color_type == PNG_COLOR_TYPE_PALETTE) {
Jul 31, 2001
Jul 31, 2001
380
381
382
383
384
385
386
387
388
389
390
391
392
393
/* Check if all tRNS entries are opaque except one */
int i, t = -1;
for(i = 0; i < num_trans; i++)
if(trans[i] == 0) {
if(t >= 0)
break;
t = i;
} else if(trans[i] != 255)
break;
if(i == num_trans) {
/* exactly one transparent index */
ckey = t;
} else {
/* more than one transparent index, or translucency */
May 12, 2006
May 12, 2006
394
lib.png_set_expand(png_ptr);
Jul 31, 2001
Jul 31, 2001
395
}
Aug 10, 2000
Aug 10, 2000
396
397
398
399
} else
ckey = 0; /* actual value will be set later */
}
Sep 1, 2000
Sep 1, 2000
400
if ( color_type == PNG_COLOR_TYPE_GRAY_ALPHA )
May 12, 2006
May 12, 2006
401
lib.png_set_gray_to_rgb(png_ptr);
Aug 10, 2000
Aug 10, 2000
402
May 12, 2006
May 12, 2006
403
lib.png_read_update_info(png_ptr, info_ptr);
Aug 10, 2000
Aug 10, 2000
404
May 12, 2006
May 12, 2006
405
lib.png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth,
Aug 10, 2000
Aug 10, 2000
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
&color_type, &interlace_type, NULL, NULL);
/* Allocate the SDL surface to hold the image */
Rmask = Gmask = Bmask = Amask = 0 ;
if ( color_type != PNG_COLOR_TYPE_PALETTE ) {
if ( SDL_BYTEORDER == SDL_LIL_ENDIAN ) {
Rmask = 0x000000FF;
Gmask = 0x0000FF00;
Bmask = 0x00FF0000;
Amask = (info_ptr->channels == 4) ? 0xFF000000 : 0;
} else {
int s = (info_ptr->channels == 4) ? 0 : 8;
Rmask = 0xFF000000 >> s;
Gmask = 0x00FF0000 >> s;
Bmask = 0x0000FF00 >> s;
Amask = 0x000000FF >> s;
}
}
surface = SDL_AllocSurface(SDL_SWSURFACE, width, height,
bit_depth*info_ptr->channels, Rmask,Gmask,Bmask,Amask);
if ( surface == NULL ) {
Feb 4, 2006
Feb 4, 2006
427
error = "Out of memory";
Aug 10, 2000
Aug 10, 2000
428
429
430
431
432
goto done;
}
if(ckey != -1) {
if(color_type != PNG_COLOR_TYPE_PALETTE)
Nov 30, 2000
Nov 30, 2000
433
434
435
436
437
/* FIXME: Should these be truncated or shifted down? */
ckey = SDL_MapRGB(surface->format,
(Uint8)transv->red,
(Uint8)transv->green,
(Uint8)transv->blue);
Aug 10, 2000
Aug 10, 2000
438
439
440
441
442
443
SDL_SetColorKey(surface, SDL_SRCCOLORKEY, ckey);
}
/* Create the array of pointers to image data */
row_pointers = (png_bytep*) malloc(sizeof(png_bytep)*height);
if ( (row_pointers == NULL) ) {
Feb 4, 2006
Feb 4, 2006
444
error = "Out of memory";
Aug 10, 2000
Aug 10, 2000
445
446
goto done;
}
Nov 30, 2000
Nov 30, 2000
447
for (row = 0; row < (int)height; row++) {
Aug 10, 2000
Aug 10, 2000
448
449
450
451
452
row_pointers[row] = (png_bytep)
(Uint8 *)surface->pixels + row*surface->pitch;
}
/* Read the entire image in one go */
May 12, 2006
May 12, 2006
453
lib.png_read_image(png_ptr, row_pointers);
Aug 10, 2000
Aug 10, 2000
454
May 16, 2004
May 16, 2004
455
456
457
458
459
/* and we're done! (png_read_end() can be omitted if no processing of
* post-IDAT text/time/etc. is desired)
* In some cases it can't read PNG's created by some popular programs (ACDSEE),
* we do not want to process comments, so we omit png_read_end
May 12, 2006
May 12, 2006
460
lib.png_read_end(png_ptr, info_ptr);
May 16, 2004
May 16, 2004
461
*/
Aug 10, 2000
Aug 10, 2000
462
463
464
/* Load the palette, if any */
palette = surface->format->palette;
Sep 1, 2000
Sep 1, 2000
465
466
467
468
469
470
471
472
473
if ( palette ) {
if(color_type == PNG_COLOR_TYPE_GRAY) {
palette->ncolors = 256;
for(i = 0; i < 256; i++) {
palette->colors[i].r = i;
palette->colors[i].g = i;
palette->colors[i].b = i;
}
} else if (info_ptr->num_palette > 0 ) {
Aug 10, 2000
Aug 10, 2000
474
475
palette->ncolors = info_ptr->num_palette;
for( i=0; i<info_ptr->num_palette; ++i ) {
Sep 1, 2000
Sep 1, 2000
476
477
478
palette->colors[i].b = info_ptr->palette[i].blue;
palette->colors[i].g = info_ptr->palette[i].green;
palette->colors[i].r = info_ptr->palette[i].red;
Aug 10, 2000
Aug 10, 2000
479
}
Sep 1, 2000
Sep 1, 2000
480
}
Aug 10, 2000
Aug 10, 2000
481
482
483
}
done: /* Clean up and return */
Feb 4, 2006
Feb 4, 2006
484
if ( png_ptr ) {
May 12, 2006
May 12, 2006
485
lib.png_destroy_read_struct(&png_ptr,
Feb 4, 2006
Feb 4, 2006
486
info_ptr ? &info_ptr : (png_infopp)0,
Aug 10, 2000
Aug 10, 2000
487
(png_infopp)0);
Feb 4, 2006
Feb 4, 2006
488
}
Aug 10, 2000
Aug 10, 2000
489
490
491
if ( row_pointers ) {
free(row_pointers);
}
Feb 4, 2006
Feb 4, 2006
492
493
494
495
496
497
if ( error ) {
SDL_RWseek(src, start, SEEK_SET);
if ( surface ) {
SDL_FreeSurface(surface);
surface = NULL;
}
May 12, 2006
May 12, 2006
498
IMG_QuitPNG();
Feb 4, 2006
Feb 4, 2006
499
IMG_SetError(error);
May 12, 2006
May 12, 2006
500
501
} else {
IMG_QuitPNG();
Feb 4, 2006
Feb 4, 2006
502
}
Aug 10, 2000
Aug 10, 2000
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
return(surface);
}
#else
/* See if an image is contained in a data source */
int IMG_isPNG(SDL_RWops *src)
{
return(0);
}
/* Load a PNG type image from an SDL datasource */
SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src)
{
return(NULL);
}
#endif /* LOAD_PNG */