80 lines
2.5 KiB
Text
80 lines
2.5 KiB
Text
$NetBSD: patch-af,v 1.2 2006/04/19 17:04:31 wiz Exp $
|
|
|
|
--- rw/readPNG.c.orig 1996-08-29 07:24:48.000000000 +0200
|
|
+++ rw/readPNG.c
|
|
@@ -46,8 +46,8 @@ Image *
|
|
ReadPNG(char *file)
|
|
{
|
|
FILE *fp;
|
|
- png_structp png_ptr;
|
|
- png_infop info_ptr;
|
|
+ png_structp png_ptr = NULL;
|
|
+ png_infop info_ptr = NULL;
|
|
int i, hasAlpha=FALSE;
|
|
int width, height, level, bit_depth, npasses;
|
|
Image *image = NULL;
|
|
@@ -59,14 +59,15 @@ ReadPNG(char *file)
|
|
return NULL;
|
|
}
|
|
|
|
- png_ptr = (png_structp)malloc(sizeof(png_struct));
|
|
+ png_ptr = (png_structp)png_create_read_struct(PNG_LIBPNG_VER_STRING,
|
|
+ NULL, NULL, NULL);
|
|
if (!png_ptr) {
|
|
RWSetMsg("Error allocating PNG png_ptr memory");
|
|
fclose(fp);
|
|
return NULL;
|
|
}
|
|
|
|
- info_ptr = (png_infop)malloc(sizeof(png_info));
|
|
+ info_ptr = (png_infop)png_create_info_struct(png_ptr);
|
|
if (!info_ptr) {
|
|
RWSetMsg("Error allocating PNG info_ptr memory");
|
|
free(png_ptr);
|
|
@@ -74,17 +75,13 @@ ReadPNG(char *file)
|
|
return NULL;
|
|
}
|
|
|
|
- if (setjmp(png_ptr->jmpbuf)) {
|
|
+ if (setjmp(png_jmpbuf(png_ptr))) {
|
|
RWSetMsg("Error setting longjmp error handler");
|
|
- png_read_destroy(png_ptr, info_ptr, (png_info *)0);
|
|
- free(png_ptr);
|
|
- free(info_ptr);
|
|
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
|
fclose(fp);
|
|
return NULL;
|
|
}
|
|
|
|
- png_info_init(info_ptr);
|
|
- png_read_init(png_ptr);
|
|
png_init_io(png_ptr, fp);
|
|
png_read_info(png_ptr, info_ptr);
|
|
|
|
@@ -183,7 +180,7 @@ ReadPNG(char *file)
|
|
info_ptr->color_type);
|
|
fflush(stderr);
|
|
RWSetMsg("Unknown PNG image type");
|
|
- png_read_destroy(png_ptr, info_ptr, (png_infop)NULL);
|
|
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
|
free(png_ptr);
|
|
free(info_ptr);
|
|
fclose(fp);
|
|
@@ -217,7 +214,7 @@ ReadPNG(char *file)
|
|
fprintf(stderr, "ReadPNG error: unable to malloc png_data\n");
|
|
fflush(stderr);
|
|
ImageDelete(image);
|
|
- png_read_destroy(png_ptr, info_ptr, (png_infop)NULL);
|
|
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
|
free(png_ptr);
|
|
free(info_ptr);
|
|
fclose(fp);
|
|
@@ -271,7 +268,7 @@ ReadPNG(char *file)
|
|
*/
|
|
|
|
png_read_end(png_ptr, info_ptr);
|
|
- png_read_destroy(png_ptr, info_ptr, (png_infop)NULL);
|
|
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
|
free(png_ptr);
|
|
free(info_ptr);
|
|
fclose(fp);
|