File: 47_pfstools-ImageMagick7.patch

package info (click to toggle)
pfstools 2.2.0-10
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,548 kB
  • sloc: cpp: 26,364; javascript: 3,814; ansic: 999; sh: 180; python: 65; makefile: 47
file content (63 lines) | stat: -rw-r--r-- 2,320 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
Description: Fix FTBFS against IM 7
Author: Neal Gompa <ngompa@fedoraproject.org>
Bug-Debian: https://bugs.debian.org/1086937
Origin: vendor https://src.fedoraproject.org/rpms/pfstools
Forwarded: https://sourceforge.net/p/pfstools/bugs/55/
Last-Update: 2024-11-12

diff --git a/src/fileformat/pfsinimgmagick.cpp b/src/fileformat/pfsinimgmagick.cpp
index 5dab440..f4358ce 100644
--- a/src/fileformat/pfsinimgmagick.cpp
+++ b/src/fileformat/pfsinimgmagick.cpp
@@ -35,6 +35,7 @@
 
 #define PROG_NAME "pfsinimgmagick"
 
+using namespace Magick;
 
 class QuietException 
 {
@@ -114,7 +115,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;    
     
@@ -129,17 +134,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++;
       } 
     }