|
Lines 28-33
Link Here
|
| 28 |
int row, i; |
28 |
int row, i; |
| 29 |
volatile int ckey = -1; |
29 |
volatile int ckey = -1; |
| 30 |
png_color_16 *transv; |
30 |
png_color_16 *transv; |
|
|
31 |
png_colorp png_palette; |
| 32 |
int num_palette; |
| 31 |
|
33 |
|
| 32 |
if ( !src ) { |
34 |
if ( !src ) { |
| 33 |
/* The error message has been set in SDL_RWFromFile */ |
35 |
/* The error message has been set in SDL_RWFromFile */ |
|
Lines 58-64
Link Here
|
| 58 |
* the normal method of doing things with libpng). REQUIRED unless you |
60 |
* the normal method of doing things with libpng). REQUIRED unless you |
| 59 |
* set up your own error handlers in png_create_read_struct() earlier. |
61 |
* set up your own error handlers in png_create_read_struct() earlier. |
| 60 |
*/ |
62 |
*/ |
| 61 |
if ( setjmp(png_ptr->jmpbuf) ) { |
63 |
if ( setjmp(png_jmpbuf(png_ptr)) ) { |
| 62 |
error = "Error reading the PNG file."; |
64 |
error = "Error reading the PNG file."; |
| 63 |
goto done; |
65 |
goto done; |
| 64 |
} |
66 |
} |
|
Lines 127-135
Link Here
|
| 127 |
Rmask = 0x000000FF; |
129 |
Rmask = 0x000000FF; |
| 128 |
Gmask = 0x0000FF00; |
130 |
Gmask = 0x0000FF00; |
| 129 |
Bmask = 0x00FF0000; |
131 |
Bmask = 0x00FF0000; |
| 130 |
Amask = (info_ptr->channels == 4) ? 0xFF000000 : 0; |
132 |
Amask = (png_get_channels(png_ptr, info_ptr) == 4) ? 0xFF000000 : 0; |
| 131 |
} else { |
133 |
} else { |
| 132 |
int s = (info_ptr->channels == 4) ? 0 : 8; |
134 |
int s = (png_get_channels(png_ptr, info_ptr) == 4) ? 0 : 8; |
| 133 |
Rmask = 0xFF000000 >> s; |
135 |
Rmask = 0xFF000000 >> s; |
| 134 |
Gmask = 0x00FF0000 >> s; |
136 |
Gmask = 0x00FF0000 >> s; |
| 135 |
Bmask = 0x0000FF00 >> s; |
137 |
Bmask = 0x0000FF00 >> s; |
|
Lines 137-143
Link Here
|
| 137 |
} |
139 |
} |
| 138 |
} |
140 |
} |
| 139 |
surface = SDL_AllocSurface(SDL_SWSURFACE, width, height, |
141 |
surface = SDL_AllocSurface(SDL_SWSURFACE, width, height, |
| 140 |
bit_depth*info_ptr->channels, Rmask,Gmask,Bmask,Amask); |
142 |
bit_depth*png_get_channels(png_ptr, info_ptr), Rmask,Gmask,Bmask,Amask); |
| 141 |
if ( surface == NULL ) { |
143 |
if ( surface == NULL ) { |
| 142 |
error = "Out of memory"; |
144 |
error = "Out of memory"; |
| 143 |
goto done; |
145 |
goto done; |
|
Lines 185-196
Link Here
|
| 185 |
palette->colors[i].g = i; |
187 |
palette->colors[i].g = i; |
| 186 |
palette->colors[i].b = i; |
188 |
palette->colors[i].b = i; |
| 187 |
} |
189 |
} |
| 188 |
} else if (info_ptr->num_palette > 0 ) { |
190 |
} else { |
| 189 |
palette->ncolors = info_ptr->num_palette; |
191 |
png_get_PLTE(png_ptr, info_ptr, &png_palette, &num_palette); |
| 190 |
for( i=0; i<info_ptr->num_palette; ++i ) { |
192 |
if (num_palette > 0 ) { |
| 191 |
palette->colors[i].b = info_ptr->palette[i].blue; |
193 |
palette->ncolors = num_palette; |
| 192 |
palette->colors[i].g = info_ptr->palette[i].green; |
194 |
for( i=0; i<num_palette; ++i ) { |
| 193 |
palette->colors[i].r = info_ptr->palette[i].red; |
195 |
palette->colors[i].b = png_palette[i].blue; |
|
|
196 |
palette->colors[i].g = png_palette[i].green; |
| 197 |
palette->colors[i].r = png_palette[i].red; |
| 198 |
} |
| 194 |
} |
199 |
} |
| 195 |
} |
200 |
} |
| 196 |
} |
201 |
} |