File pfstools-ImageMagick7.patch of Package pfstools

https://github.com/pld-linux/pfstools/commit/67bd2304e516545f2b203f975ac5dd30d2b479b3
Index: pfstools-2.0.4/src/fileformat/pfsinimgmagick.cpp
===================================================================
--- pfstools-2.0.4.orig/src/fileformat/pfsinimgmagick.cpp	2015-07-15 11:58:19.000000000 +0200
+++ pfstools-2.0.4/src/fileformat/pfsinimgmagick.cpp	2017-03-28 15:14:56.124621175 +0200
@@ -35,6 +35,7 @@
 
 #define PROG_NAME "pfsinimgmagick"
 
+using namespace Magick;
 
 class QuietException 
 {
@@ -112,7 +113,11 @@ void readFrames( int argc, char* argv[]
     Magick::Image imImage( ff.fileName );
 
     VERBOSE_STR << "input image gamma:  " << imImage.gamma() << std::endl;
+#if MagickLibVersion >= 0x700
+    bool hasAlpha = imImage.alpha();
+#else
     bool hasAlpha = imImage.matte();
+#endif
     if( hasAlpha )
       VERBOSE_STR << "alpha channel found" << std::endl;    
     
@@ -127,17 +132,30 @@ void readFrames( int argc, char* argv[]
     
     // Copy line by line to pfs::Frame
     int pixInd = 0;
-    const float maxValue = (float)(1<<QuantumDepth) - 1;
+    const float maxValue = (float)QuantumRange;
     for( int r = 0; r < imImage.rows(); r++ ) {
+#if MagickLibVersion >= 0x700
+      const Magick::Quantum *pixels =
+#else
       const Magick::PixelPacket *pixels =
+#endif
         imImage.getConstPixels( 0, r, imImage.columns(), 1 );
 
       for( int c = 0; c < imImage.columns(); c++ ) {
+#if MagickLibVersion >= 0x700
+        (*X)(pixInd) = (float)MagickCore::GetPixelRed(imImage.image(), pixels) / maxValue;
+        (*Y)(pixInd) = (float)MagickCore::GetPixelGreen(imImage.image(), pixels) / maxValue;
+        (*Z)(pixInd) = (float)MagickCore::GetPixelBlue(imImage.image(), pixels) / maxValue;
+        if( alpha != NULL )
+          (*alpha)(pixInd) = (float)MagickCore::GetPixelAlpha(imImage.image(), pixels) / maxValue;
+	pixels += MagickCore::GetPixelChannels(imImage.image());
+#else
         (*X)(pixInd) = (float)pixels[c].red / maxValue;
         (*Y)(pixInd) = (float)pixels[c].green / maxValue;
         (*Z)(pixInd) = (float)pixels[c].blue / maxValue;
         if( alpha != NULL )
           (*alpha)(pixInd) = (float)pixels[c].opacity / maxValue;
+#endif
         pixInd++;
       } 
     }    
openSUSE Build Service is sponsored by