tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: [HEADS UP] png update to 1.5 branch



graphics/gwenview accesses struct component buffer_size. This is now
private and there is no accessor in the png api. 

In work/gwenview-1.4.2/src/gvcore/pngformattype.cpp in function
PNGFormat::end(png_structp png, png_infop info)

    496     consumer->end();
    497     state = FrameStart;
    498     unused_data = (int)png->buffer_size; // Since libpng doesn't tell us
    499 }

apart from this:

$NetBSD$

--- src/gvcore/pngformattype.cpp.orig   2007-09-15 09:46:13.000000000 -0400
+++ src/gvcore/pngformattype.cpp
@@ -211,7 +211,7 @@ void setup_qt( QImage& image, png_struct
 
     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,16 +245,24 @@ void setup_qt( QImage& image, png_struct
                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;
+             png_bytep trans_alpha; 
+             int num_trans;
+             png_color_16p trans_color;
+             png_get_tRNS(png_ptr, info_ptr, &trans_alpha, &num_trans, 
&trans_color);
+               const int g = trans_color->gray;
                if (g < ncols) {
                    image.setAlphaBuffer(TRUE);
                    image.setColor(g, image.color(g) & RGB_MASK);
                }
            }
        }
-    } else if ( color_type == PNG_COLOR_TYPE_PALETTE
+    } else {
+      png_colorp palette;
+      int num_palette;
+      png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette);
+      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 +270,38 @@ void setup_qt( QImage& image, png_struct
        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 ) {
+           png_bytep trans_alpha; 
+           int num_trans;
+           png_color_16p trans_color;
+           png_get_tRNS(png_ptr, info_ptr, &trans_alpha, &num_trans, 
&trans_color);
+           png_colorp palette;
+           int num_palette;
+           png_get_PLTE(png_ptr,info_ptr, &palette, &num_palette);
+           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]
+                   palette[i].red,
+                   palette[i].green,
+                   palette[i].blue,
+                   trans_alpha[i]
                    )
                );
                i++;
            }
        }
-       while ( i < info_ptr->num_palette ) {
+       png_colorp palette;
+       int num_palette;
+       png_get_PLTE(png_ptr,info_ptr, &palette, &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,
+               palette[i].red,
+               palette[i].green,
+               palette[i].blue,
                0xff
                )
            );
@@ -318,12 +336,13 @@ void setup_qt( QImage& image, png_struct
        }
 
        png_read_update_info(png_ptr, info_ptr);
-    }
+      }
 
     // Qt==ARGB==Big(ARGB)==Little(BGRA)
     if ( QImage::systemByteOrder() == QImage::LittleEndian ) {
        png_set_bgr(png_ptr);
     }
+    }
 }
 
 
@@ -381,7 +400,7 @@ int PNGFormat::decode(QImage& img, QImag
            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 +428,7 @@ int PNGFormat::decode(QImage& img, QImag
 
     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;


Best regards,

Marko

Attachment: pgpm7jmq28IJ_.pgp
Description: PGP signature



Home | Main Index | Thread Index | Old Index