File gwenview-1.4.2-alt-libpng15.patch of Package kde3-gwenview

diff --git a/gwenview/src/gvcore/pngformattype.cpp b/gwenview/src/gvcore/pngformattype.cpp
index 36c1064..eb5cfd8 100644
--- a/gwenview/src/gvcore/pngformattype.cpp
+++ b/gwenview/src/gvcore/pngformattype.cpp
@@ -206,12 +206,19 @@ void setup_qt( QImage& image, png_structp png_ptr, png_infop info_ptr )
     png_uint_32 height;
     int bit_depth;
     int color_type;
+		png_colorp png_palette;
+		int num_palette;
+		png_bytep trans_alpha;
+		int num_trans;
+		png_color_16p trans_values;
     png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
 	0, 0, 0);
+		png_get_PLTE(png_ptr, info_ptr, &png_palette, &num_palette);
+		png_get_tRNS(png_ptr, info_ptr, &trans_alpha, &num_trans, &trans_values);
 
     if ( color_type == PNG_COLOR_TYPE_GRAY ) {
 	// Black & White or 8-bit grayscale
-	if ( bit_depth == 1 && info_ptr->channels == 1 ) {
+	if ( bit_depth == 1 && png_get_channels(png_ptr, info_ptr) == 1 ) {
 	    png_set_invert_mono( png_ptr );
 	    png_read_update_info( png_ptr, info_ptr );
 	    if (!image.create( width, height, 1, 2, QImage::BigEndian ))
@@ -245,7 +252,7 @@ void setup_qt( QImage& image, png_structp png_ptr, png_infop info_ptr )
 		image.setColor( i, qRgba(c,c,c,0xff) );
 	    }
 	    if ( png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS) ) {
-		const int g = info_ptr->trans_values.gray;
+		const int g = trans_values->gray;
 		if (g < ncols) {
 		    image.setAlphaBuffer(TRUE);
 		    image.setColor(g, image.color(g) & RGB_MASK);
@@ -254,7 +261,7 @@ void setup_qt( QImage& image, png_structp png_ptr, png_infop info_ptr )
 	}
     } else if ( color_type == PNG_COLOR_TYPE_PALETTE
      && png_get_valid(png_ptr, info_ptr, PNG_INFO_PLTE)
-     && info_ptr->num_palette <= 256 )
+     && num_palette <= 256 )
     {
 	// 1-bit and 8-bit color
 	if ( bit_depth != 1 )
@@ -262,28 +269,28 @@ void setup_qt( QImage& image, png_structp png_ptr, png_infop info_ptr )
 	png_read_update_info( png_ptr, info_ptr );
 	png_get_IHDR(png_ptr, info_ptr,
 	    &width, &height, &bit_depth, &color_type, 0, 0, 0);
-	if (!image.create(width, height, bit_depth, info_ptr->num_palette,
+	if (!image.create(width, height, bit_depth, num_palette,
 	    QImage::BigEndian))
 	    return;
 	int i = 0;
 	if ( png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS) ) {
 	    image.setAlphaBuffer( TRUE );
-	    while ( i < info_ptr->num_trans ) {
+	    while ( i < num_trans ) {
 		image.setColor(i, qRgba(
-		    info_ptr->palette[i].red,
-		    info_ptr->palette[i].green,
-		    info_ptr->palette[i].blue,
-		    info_ptr->trans[i]
+		    png_palette[i].red,
+		    png_palette[i].green,
+		    png_palette[i].blue,
+		    trans_alpha[i]
 		    )
 		);
 		i++;
 	    }
 	}
-	while ( i < info_ptr->num_palette ) {
+	while ( i < num_palette ) {
 	    image.setColor(i, qRgba(
-		info_ptr->palette[i].red,
-		info_ptr->palette[i].green,
-		info_ptr->palette[i].blue,
+		png_palette[i].red,
+		png_palette[i].green,
+		png_palette[i].blue,
 		0xff
 		)
 	    );
@@ -381,7 +388,7 @@ int PNGFormat::decode(QImage& img, QImageConsumer* cons,
 	    return -1;
 	}
 
-	if (setjmp((png_ptr)->jmpbuf)) {
+	if (setjmp(png_jmpbuf(png_ptr))) {
 	    png_destroy_read_struct(&png_ptr, &info_ptr, 0);
 	    image = 0;
 	    return -1;
@@ -409,7 +416,7 @@ int PNGFormat::decode(QImage& img, QImageConsumer* cons,
 
     if ( !png_ptr ) return 0;
 
-    if (setjmp(png_ptr->jmpbuf)) {
+    if (setjmp(png_jmpbuf(png_ptr))) {
 	png_destroy_read_struct(&png_ptr, &info_ptr, 0);
 	image = 0;
 	state = MovieStart;
@@ -476,7 +483,7 @@ void PNGFormat::end(png_structp png, png_infop info)
     consumer->frameDone(QPoint(offx,offy),r);
     consumer->end();
     state = FrameStart;
-    unused_data = (int)png->buffer_size; // Since libpng doesn't tell us
+    unused_data = (int)png_get_compression_buffer_size(png); // Since libpng doesn't tell us
 }
 
 #ifdef PNG_USER_CHUNKS_SUPPORTED
openSUSE Build Service is sponsored by