You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
2.2 KiB
72 lines
2.2 KiB
13 years ago
|
--- src/video/png.cpp
|
||
|
+++ src/video/png.cpp
|
||
|
@@ -147,7 +147,7 @@
|
||
|
* 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)) {
|
||
|
+ if (setjmp(png_jmpbuf(png_ptr))) {
|
||
|
fprintf(stderr, "Error reading the PNG file.\n");
|
||
|
ret = -1;
|
||
|
goto done;
|
||
|
@@ -227,11 +227,11 @@
|
||
|
Rmask = 0x000000FF;
|
||
|
Gmask = 0x0000FF00;
|
||
|
Bmask = 0x00FF0000;
|
||
|
- Amask = (info_ptr->channels == 4) ? 0xFF000000 : 0;
|
||
|
+ Amask = (png_get_channels(png_ptr, info_ptr) == 4) ? 0xFF000000 : 0;
|
||
|
} else {
|
||
|
int s;
|
||
|
|
||
|
- s = (info_ptr->channels == 4) ? 0 : 8;
|
||
|
+ s = (png_get_channels(png_ptr, info_ptr) == 4) ? 0 : 8;
|
||
|
Rmask = 0xFF000000 >> s;
|
||
|
Gmask = 0x00FF0000 >> s;
|
||
|
Bmask = 0x0000FF00 >> s;
|
||
|
@@ -239,7 +239,7 @@
|
||
|
}
|
||
|
}
|
||
|
surface = SDL_AllocSurface(SDL_SWSURFACE, width, height,
|
||
|
- bit_depth * info_ptr->channels, Rmask, Gmask, Bmask, Amask);
|
||
|
+ bit_depth * png_get_channels(png_ptr, info_ptr), Rmask, Gmask, Bmask, Amask);
|
||
|
if (surface == NULL) {
|
||
|
fprintf(stderr, "Out of memory");
|
||
|
goto done;
|
||
|
@@ -276,6 +276,8 @@
|
||
|
png_read_end(png_ptr, info_ptr);
|
||
|
|
||
|
/* Load the palette, if any */
|
||
|
+ int png_num_palette;
|
||
|
+ png_colorp png_palette;
|
||
|
palette = surface->format->palette;
|
||
|
if (palette) {
|
||
|
if (color_type == PNG_COLOR_TYPE_GRAY) {
|
||
|
@@ -285,12 +287,12 @@
|
||
|
palette->colors[i].g = i;
|
||
|
palette->colors[i].b = i;
|
||
|
}
|
||
|
- } else if (info_ptr->num_palette > 0) {
|
||
|
- palette->ncolors = info_ptr->num_palette;
|
||
|
- for (i = 0; i < info_ptr->num_palette; ++i) {
|
||
|
- 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;
|
||
|
+ } else if (png_num_palette > 0) {
|
||
|
+ palette->ncolors = png_num_palette;
|
||
|
+ for (i = 0; i < png_num_palette; ++i) {
|
||
|
+ palette->colors[i].b = png_palette[i].blue;
|
||
|
+ palette->colors[i].g = png_palette[i].green;
|
||
|
+ palette->colors[i].r = png_palette[i].red;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
@@ -343,7 +345,7 @@
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
- if (setjmp(png_ptr->jmpbuf)) {
|
||
|
+ if (setjmp(png_jmpbuf(png_ptr))) {
|
||
|
/* If we get here, we had a problem reading the file */
|
||
|
fclose(fp);
|
||
|
png_destroy_write_struct(&png_ptr, &info_ptr);
|