]>
Commit | Line | Data |
---|---|---|
2079159c AG |
1 | --- widelands-build16-src/src/graphic/SDL_mng.cc.orig 2012-02-11 10:20:23.248971926 +0100 |
2 | +++ widelands-build16-src/src/graphic/SDL_mng.cc 2012-02-11 10:21:08.652535416 +0100 | |
3 | @@ -239,7 +239,7 @@ | |
4 | SDL_Surface * MNG_read_frame(SDL_RWops * const src) | |
5 | { | |
6 | png_uint_32 width, height; | |
7 | - int bit_depth, color_type, interlace_type; | |
8 | + int bit_depth, color_type, interlace_type, num_palette; | |
9 | Uint32 Rmask; | |
10 | Uint32 Gmask; | |
11 | Uint32 Bmask; | |
12 | @@ -247,6 +247,7 @@ | |
13 | SDL_Palette * palette; | |
14 | volatile int ckey = -1; | |
15 | png_color_16 * transv; | |
16 | + png_colorp png_palette; | |
17 | ||
18 | /* Initialize the data we will clean up when we're done */ | |
19 | png_structp png_ptr = 0; | |
20 | @@ -276,7 +277,7 @@ | |
21 | * the normal method of doing things with libpng). REQUIRED unless you | |
22 | * set up your own error handlers in png_create_read_struct() earlier. | |
23 | */ | |
24 | - if (setjmp(png_ptr->jmpbuf)) { | |
25 | + if (setjmp(png_jmpbuf(png_ptr))) { | |
26 | SDL_SetError("Error reading the PNG file."); | |
27 | goto done; | |
28 | } | |
29 | @@ -356,9 +357,9 @@ | |
30 | Rmask = 0x000000FF; | |
31 | Gmask = 0x0000FF00; | |
32 | Bmask = 0x00FF0000; | |
33 | - Amask = (info_ptr->channels == 4) ? 0xFF000000 : 0; | |
34 | + Amask = (png_get_channels(png_ptr, info_ptr) == 4) ? 0xFF000000 : 0; | |
35 | } else { | |
36 | - int const s = (info_ptr->channels == 4) ? 0 : 8; | |
37 | + int const s = (png_get_channels(png_ptr, info_ptr) == 4) ? 0 : 8; | |
38 | Rmask = 0xFF000000 >> s; | |
39 | Gmask = 0x00FF0000 >> s; | |
40 | Bmask = 0x0000FF00 >> s; | |
41 | @@ -370,7 +370,7 @@ | |
42 | SDL_AllocSurface | |
43 | (SDL_SWSURFACE, | |
44 | width, height, | |
45 | - bit_depth * info_ptr->channels, | |
46 | + bit_depth * png_get_channels(png_ptr, info_ptr), | |
47 | Rmask, Gmask, Bmask, Amask); | |
48 | if (not surface) { | |
49 | SDL_SetError("Out of memory"); | |
50 | @@ -408,6 +409,7 @@ | |
51 | png_read_end(png_ptr, info_ptr); | |
52 | ||
53 | /* Load the palette, if any */ | |
54 | + png_get_PLTE(png_ptr, info_ptr, &png_palette, &num_palette); | |
55 | if ((palette = surface->format->palette)) { | |
56 | if (color_type == PNG_COLOR_TYPE_GRAY) { | |
57 | palette->ncolors = 256; | |
58 | @@ -416,12 +418,12 @@ | |
59 | palette->colors[i].g = i; | |
60 | palette->colors[i].b = i; | |
61 | } | |
62 | - } else if (info_ptr->num_palette > 0) { | |
63 | - palette->ncolors = info_ptr->num_palette; | |
64 | - for (uint32_t i = 0; i < info_ptr->num_palette; ++i) { | |
65 | - palette->colors[i].b = info_ptr->palette[i].blue; | |
66 | - palette->colors[i].g = info_ptr->palette[i].green; | |
67 | - palette->colors[i].r = info_ptr->palette[i].red; | |
68 | + } else if (num_palette > 0) { | |
69 | + palette->ncolors = num_palette; | |
70 | + for (uint32_t i = 0; i < num_palette; ++i) { | |
71 | + palette->colors[i].b = png_palette[i].blue; | |
72 | + palette->colors[i].g = png_palette[i].green; | |
73 | + palette->colors[i].r = png_palette[i].red; | |
74 | } | |
75 | } | |
76 | } |