Lines 144-150
Link Here
|
144 |
* the normal method of doing things with libpng). REQUIRED unless you |
144 |
* the normal method of doing things with libpng). REQUIRED unless you |
145 |
* set up your own error handlers in png_create_read_struct() earlier. |
145 |
* set up your own error handlers in png_create_read_struct() earlier. |
146 |
*/ |
146 |
*/ |
147 |
if ( setjmp(png_ptr->jmpbuf) ) { |
147 |
if ( setjmp(png_jmpbuf(png_ptr)) ) { |
148 |
IMG_SetError("Error reading the PNG file."); |
148 |
IMG_SetError("Error reading the PNG file."); |
149 |
goto done; |
149 |
goto done; |
150 |
} |
150 |
} |
Lines 213-221
Link Here
|
213 |
Rmask = 0x000000FF; |
213 |
Rmask = 0x000000FF; |
214 |
Gmask = 0x0000FF00; |
214 |
Gmask = 0x0000FF00; |
215 |
Bmask = 0x00FF0000; |
215 |
Bmask = 0x00FF0000; |
216 |
Amask = (info_ptr->channels == 4) ? 0xFF000000 : 0; |
216 |
Amask = (png_get_channels(png_ptr, info_ptr) == 4) ? 0xFF000000 : 0; |
217 |
} else { |
217 |
} else { |
218 |
int s = (info_ptr->channels == 4) ? 0 : 8; |
218 |
int s = (png_get_channels(png_ptr, info_ptr) == 4) ? 0 : 8; |
219 |
Rmask = 0xFF000000 >> s; |
219 |
Rmask = 0xFF000000 >> s; |
220 |
Gmask = 0x00FF0000 >> s; |
220 |
Gmask = 0x00FF0000 >> s; |
221 |
Bmask = 0x0000FF00 >> s; |
221 |
Bmask = 0x0000FF00 >> s; |
Lines 223-229
Link Here
|
223 |
} |
223 |
} |
224 |
} |
224 |
} |
225 |
surface = SDL_AllocSurface(SDL_SWSURFACE, width, height, |
225 |
surface = SDL_AllocSurface(SDL_SWSURFACE, width, height, |
226 |
bit_depth*info_ptr->channels, Rmask,Gmask,Bmask,Amask); |
226 |
bit_depth*png_get_channels(png_ptr, info_ptr), Rmask,Gmask,Bmask,Amask); |
227 |
if ( surface == NULL ) { |
227 |
if ( surface == NULL ) { |
228 |
IMG_SetError("Out of memory"); |
228 |
IMG_SetError("Out of memory"); |
229 |
goto done; |
229 |
goto done; |
Lines 264-269
Link Here
|
264 |
*/ |
264 |
*/ |
265 |
|
265 |
|
266 |
/* Load the palette, if any */ |
266 |
/* Load the palette, if any */ |
|
|
267 |
int num_palette; |
267 |
palette = surface->format->palette; |
268 |
palette = surface->format->palette; |
268 |
if ( palette ) { |
269 |
if ( palette ) { |
269 |
if(color_type == PNG_COLOR_TYPE_GRAY) { |
270 |
if(color_type == PNG_COLOR_TYPE_GRAY) { |
Lines 273-284
Link Here
|
273 |
palette->colors[i].g = i; |
274 |
palette->colors[i].g = i; |
274 |
palette->colors[i].b = i; |
275 |
palette->colors[i].b = i; |
275 |
} |
276 |
} |
276 |
} else if (info_ptr->num_palette > 0 ) { |
277 |
} else if (num_palette > 0 ) { |
277 |
palette->ncolors = info_ptr->num_palette; |
278 |
palette->ncolors = num_palette; |
278 |
for( i=0; i<info_ptr->num_palette; ++i ) { |
279 |
for( i=0; i<num_palette; ++i ) { |
279 |
palette->colors[i].b = info_ptr->palette[i].blue; |
280 |
palette->colors[i].b = palette[i].blue; |
280 |
palette->colors[i].g = info_ptr->palette[i].green; |
281 |
palette->colors[i].g = palette[i].green; |
281 |
palette->colors[i].r = info_ptr->palette[i].red; |
282 |
palette->colors[i].r = palette[i].red; |
282 |
} |
283 |
} |
283 |
} |
284 |
} |
284 |
} |
285 |
} |