Fix build with png-1.5.

This commit is contained in:
wiz 2011-04-03 10:28:20 +00:00
parent 3b3f41c417
commit 85bf58377b
2 changed files with 73 additions and 1 deletions

View file

@ -1,4 +1,4 @@
$NetBSD: distinfo,v 1.6 2007/01/12 20:32:48 wiz Exp $
$NetBSD: distinfo,v 1.7 2011/04/03 10:28:20 wiz Exp $
SHA1 (stratagus-2.1-src.tar.gz) = 33181d57e018825a450f1e8c0ec31b0887cbd39c
RMD160 (stratagus-2.1-src.tar.gz) = f5f97854cad9f17104de34613012fd3aa2efbb9b
@ -8,3 +8,4 @@ SHA1 (patch-ab) = cd9235023dcb2bc05828857c8f1d538a0d06eab5
SHA1 (patch-ac) = 78aca58075dd730a799dc9d0fb79ca4c6c010a34
SHA1 (patch-ad) = 20dc341faf2fc160fbbd8b6ae68b1de1a9e21294
SHA1 (patch-af) = 06e264e6a3fb785285da503f240405dedf851ec5
SHA1 (patch-src_video_png.c) = fe1ac8d6c610b6f2e0dc259c98fc912b3259bfde

View file

@ -0,0 +1,71 @@
$NetBSD: patch-src_video_png.c,v 1.1 2011/04/03 10:28:21 wiz Exp $
Fix build with png-1.5.
--- src/video/png.c.orig 2004-06-26 22:38:20.000000000 +0000
+++ src/video/png.c
@@ -133,7 +133,7 @@ Graphic* LoadGraphicPNG(const char* name
* 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.");
goto done;
}
@@ -212,11 +212,11 @@ Graphic* LoadGraphicPNG(const char* name
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;
@@ -224,7 +224,7 @@ Graphic* LoadGraphicPNG(const char* name
}
}
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;
@@ -270,12 +270,17 @@ Graphic* LoadGraphicPNG(const char* name
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 {
+ png_colorp pngpalette;
+ int num_palette;
+ png_get_PLTE(png_ptr, info_ptr, &pngpalette, &num_palette);
+ if (num_palette > 0) {
+ palette->ncolors = num_palette;
+ for (i = 0; i < num_palette; ++i) {
+ palette->colors[i].b = pngpalette[i].blue;
+ palette->colors[i].g = pngpalette[i].green;
+ palette->colors[i].r = pngpalette[i].red;
+ }
}
}
}
@@ -331,7 +336,7 @@ void SaveScreenshotPNG(const char* name)
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);