[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/graphics/digikam/libs
From:       Johannes Wienke <languitar () semipol ! de>
Date:       2010-02-02 0:05:36
Message-ID: 1265069136.401320.6182.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1083821 by jwienke:

fix compilation with libpng >= 1.4.0

 M  +17 -1     dimg/loaders/pngloader.cpp  
 M  +22 -3     threadimageio/thumbnailbasic.cpp  


--- trunk/extragear/graphics/digikam/libs/dimg/loaders/pngloader.cpp #1083820:1083821
@@ -105,7 +105,11 @@
     unsigned char buf[PNG_BYTES_TO_CHECK];
 
     size_t membersRead = fread(buf, 1, PNG_BYTES_TO_CHECK, f);
+#if PNG_LIBPNG_VER >= 10400
+    if ((membersRead != PNG_BYTES_TO_CHECK) || png_sig_cmp(buf, 0, PNG_BYTES_TO_CHECK))
+#else
     if ((membersRead != PNG_BYTES_TO_CHECK) || !png_check_sig(buf, PNG_BYTES_TO_CHECK))
+#endif
     {
         kDebug() << "Not a PNG image file.";
         fclose(f);
@@ -165,7 +169,11 @@
     CleanupData *cleanupData = new CleanupData;
     cleanupData->setFile(f);
 
+#if PNG_LIBPNG_VER >= 10400
+    if (setjmp(png_jmpbuf(png_ptr)))
+#else
     if (setjmp(png_ptr->jmpbuf))
+#endif
     {
         kDebug() << "Internal libPNG error during reading file. Process aborted!";
         png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
@@ -322,7 +330,11 @@
 #ifdef ENABLE_DEBUG_MESSAGES
                     kDebug() << "PNG in PNG_COLOR_TYPE_GRAY";
 #endif
+#if PNG_LIBPNG_VER >= 10400
+                    png_set_expand_gray_1_2_4_to_8(png_ptr);
+#else
                     png_set_gray_1_2_4_to_8(png_ptr);
+#endif
                     png_set_gray_to_rgb(png_ptr);
 
                     if (QSysInfo::ByteOrder == QSysInfo::LittleEndian)           // Intel
@@ -627,7 +639,11 @@
     CleanupData *cleanupData = new CleanupData;
     cleanupData->setFile(f);
 
-    if (setjmp(png_ptr->jmpbuf))
+#if PNG_LIBPNG_VER >= 10400
+    if (setjmp(png_jmpbuf(png_ptr)))
+#else
+     if (setjmp(png_ptr->jmpbuf))
+#endif
     {
         kDebug() << "Internal libPNG error during writing file. Process aborted!";
         png_destroy_write_struct(&png_ptr, (png_infopp) & info_ptr);
--- trunk/extragear/graphics/digikam/libs/threadimageio/thumbnailbasic.cpp #1083820:1083821
@@ -137,7 +137,11 @@
     unsigned char buf[PNG_BYTES_TO_CHECK];
 
     size_t itemsRead = fread(buf, 1, PNG_BYTES_TO_CHECK, f);
+#if PNG_LIBPNG_VER >= 10400
+    if (itemsRead != 1 || png_sig_cmp(buf, 0, PNG_BYTES_TO_CHECK))
+#else
     if (itemsRead != 1 || !png_check_sig(buf, PNG_BYTES_TO_CHECK))
+#endif
     {
         fclose(f);
         return qimage;
@@ -159,7 +163,11 @@
         return qimage;
     }
 
+#if PNG_LIBPNG_VER >= 10400
+    if (setjmp(png_jmpbuf(png_ptr)))
+#else
     if (setjmp(png_ptr->jmpbuf))
+#endif
     {
         png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
         fclose(f);
@@ -180,16 +188,23 @@
     if (color_type == PNG_COLOR_TYPE_PALETTE)
         png_set_expand(png_ptr);
 
-    if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
+
+#if PNG_LIBPNG_VER >= 10400
+    png_byte info_color_type = png_get_color_type(png_ptr, info_ptr);
+#else
+    png_byte info_color_type = info_ptr->color_type;
+#endif
+
+    if (info_color_type == PNG_COLOR_TYPE_RGB_ALPHA)
         has_alpha = 1;
 
-    if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
+    if (info_color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
     {
         has_alpha = 1;
         has_grey = 1;
     }
 
-    if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY)
+    if (info_color_type == PNG_COLOR_TYPE_GRAY)
         has_grey = 1;
 
     unsigned char **lines;
@@ -232,7 +247,11 @@
     {
         png_set_gray_to_rgb(png_ptr);
         if (png_get_bit_depth(png_ptr, info_ptr) < 8)
+#if PNG_LIBPNG_VER >= 10400
+            png_set_expand_gray_1_2_4_to_8(png_ptr);
+#else
             png_set_gray_1_2_4_to_8(png_ptr);
+#endif
     }
 
     int sizeOfUint = sizeof(unsigned int);
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic