Package: exactimage / 1.0.2-1

giflib5.patch Patch series | 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
From: Matthias Klose <doko@ubuntu.com>
Date: Wed, 28 Oct 2015 16:09:31 +0100
Subject: Build using giflib5

Forwarded: no
---
 codecs/gif.cc | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 63 insertions(+), 10 deletions(-)

diff --git a/codecs/gif.cc b/codecs/gif.cc
index f670619..37cd8b8 100644
--- a/codecs/gif.cc
+++ b/codecs/gif.cc
@@ -17,6 +17,12 @@
 
 #include <gif_lib.h>
 
+#if (GIFLIB_MAJOR > 5) || (GIFLIB_MINOR >= 1)
+#define Internal_EGifCloseFile(f) EGifCloseFile(f, NULL)
+#else
+#define Internal_EGifCloseFile(f) EGifCloseFile(f)
+#endif
+
 #include "gif.hh"
 #include "Colorspace.hh"
 
@@ -57,12 +63,20 @@ int GIFCodec::readImage (std::istream* stream, Image& image, const std::string&
   GifFileType* GifFile;
   GifRecordType RecordType;
   GifByteType* Extension;
-  ColorMapObject *ColorMap = 0;
+  ColorMapObject *ColorMap = NULL;
   int GifError, ExtCode;
   
-  if ((GifFile = DGifOpen (stream, &GIFInputFunc, &GifError)) == 0)
+#if (GIFLIB_MAJOR > 5) || (GIFLIB_MINOR >= 1)
+  if ((GifFile = DGifOpen (stream, &GIFInputFunc, &GifError)) == NULL)
+#else
+  if ((GifFile = DGifOpen (stream, &GIFInputFunc)) == NULL)
+#endif
     {
+#if (GIFLIB_MAJOR > 5) || (GIFLIB_MINOR >= 1)
+      //std::cerr << "Error: " << GifErrorString(GifError) << std::endl;
+#else
       //PrintGifError();
+#endif
       return false;
     }
   
@@ -74,7 +88,11 @@ int GIFCodec::readImage (std::istream* stream, Image& image, const std::string&
   /* Scan the content of the GIF file and load the image(s) in: */
   do {
     if (DGifGetRecordType(GifFile, &RecordType) == GIF_ERROR) {
+#if (GIFLIB_MAJOR > 5) || (GIFLIB_MINOR >= 1)
+      //std::cerr << "DGifGetRecordType error: " << GifErrorString(GifFile->Error) << std::endl;
+#else
       //PrintGifError();
+#endif
       return false;
     }
     
@@ -83,7 +101,11 @@ int GIFCodec::readImage (std::istream* stream, Image& image, const std::string&
     switch (RecordType) {
     case IMAGE_DESC_RECORD_TYPE:
       if (DGifGetImageDesc(GifFile) == GIF_ERROR) {
-	//PrintGifError();
+#if (GIFLIB_MAJOR > 5) || (GIFLIB_MINOR >= 1)
+        //std::cerr << "DGifGetImageDesc error: " << GifErrorString(GifFile->Error) << std::endl;
+#else
+        //PrintGifError();
+#endif
 	return false;
       }
       
@@ -104,7 +126,11 @@ int GIFCodec::readImage (std::istream* stream, Image& image, const std::string&
 	       j += InterlacedJumps[i]) {
 	    if (DGifGetLine(GifFile, &image.getRawData()[j*image.stride()+Col],
 			    Width) == GIF_ERROR) {
+#if (GIFLIB_MAJOR > 5) || (GIFLIB_MINOR >= 1)
+	      //std::cerr << "DGifGetLine error: " << GifErrorString(GifFile->Error) << std::endl;
+#else
 	      //PrintGifError();
+#endif
 	      return false;
 	    }
 	  }
@@ -113,7 +139,11 @@ int GIFCodec::readImage (std::istream* stream, Image& image, const std::string&
 	for (int i = 0; i < Height; ++i) {
 	  if (DGifGetLine(GifFile, &image.getRawData()[Row++ * image.stride()+Col],
 			  Width) == GIF_ERROR) {
+#if (GIFLIB_MAJOR > 5) || (GIFLIB_MINOR >= 1)
+	    //std::cerr << "DGifGetLine error: " << GifErrorString(GifFile->Error) << std::endl;
+#else
 	    //PrintGifError();
+#endif
 	    return false;
 	  }
 	}
@@ -122,12 +152,20 @@ int GIFCodec::readImage (std::istream* stream, Image& image, const std::string&
     case EXTENSION_RECORD_TYPE:
       /* Skip any extension blocks in file: */
       if (DGifGetExtension(GifFile, &ExtCode, &Extension) == GIF_ERROR) {
+#if (GIFLIB_MAJOR > 5) || (GIFLIB_MINOR >= 1)
+	//std::cerr << "DGifGetExtension error: " << GifErrorString(GifFile->Error) << std::endl;
+#else
 	//PrintGifError();
+#endif
 	return false;
       }
       while (Extension != 0) {
 	if (DGifGetExtensionNext(GifFile, &Extension) == GIF_ERROR) {
+#if (GIFLIB_MAJOR > 5) || (GIFLIB_MINOR >= 1)
+	  //std::cerr << "DGifGetExtensionNext error: " << GifErrorString(GifFile->Error) << std::endl;
+#else
 	  //PrintGifError();
+#endif
 	  return false;
 	}
       }
@@ -155,7 +193,7 @@ int GIFCodec::readImage (std::istream* stream, Image& image, const std::string&
   // convert colormap to our 16bit "TIFF"format
   colorspace_de_palette (image, ColorMap->ColorCount, rmap, gmap, bmap);
   
-  EGifCloseFile(GifFile, &GifError);
+  Internal_EGifCloseFile(GifFile);
 
   return true;
 }
@@ -166,17 +204,29 @@ bool GIFCodec::writeImage (std::ostream* stream, Image& image, int quality,
   GifFileType* GifFile;
   GifByteType* Ptr;
   int GifError;
-  
-  if ((GifFile = EGifOpen(stream, &GIFOutputFunc, &GifError)) == 0)
+
+#if (GIFLIB_MAJOR > 5) || (GIFLIB_MINOR >= 1)
+  if ((GifFile = EGifOpen (stream, &GIFOutputFunc, &GifError)) == NULL)
+#else
+  if ((GifFile = EGifOpen (stream, &GIFOutputFunc)) == NULL)
+#endif
     {
+#if (GIFLIB_MAJOR > 5) || (GIFLIB_MINOR >= 1)
+      std::cerr << "Error preparing GIF file for writing: " << GifErrorString(GifError) << std::endl;
+#else
       std::cerr << "Error preparing GIF file for writing." << std::endl;
+#endif
       return false;
     }
   
   int ColorMapSize = 256;
   
   // later use our own colormap generation
-  ColorMapObject* OutputColorMap = GifMakeMapObject(ColorMapSize, 0);
+#if (GIFLIB_MAJOR > 5) || (GIFLIB_MINOR >= 1)
+  ColorMapObject* OutputColorMap = GifMakeMapObject(ColorMapSize, NULL);
+#else
+  ColorMapObject* OutputColorMap = MakeMapObject(ColorMapSize, NULL);
+#endif
   if (!OutputColorMap)
     return false;
   
@@ -203,8 +253,11 @@ bool GIFCodec::writeImage (std::ostream* stream, Image& image, int quality,
     *bptr++ = b;
   }
    
-  
+#if (GIFLIB_MAJOR > 5) || (GIFLIB_MINOR >= 1)
   if (GifQuantizeBuffer(image.w, image.h, &ColorMapSize,
+#else
+  if (QuantizeBuffer(image.w, image.h, &ColorMapSize,
+#endif
 		     RedBuffer, GreenBuffer, BlueBuffer,
 		     OutputBuffer, OutputColorMap->Colors) == GIF_ERROR) {
     return false;
@@ -216,7 +269,7 @@ bool GIFCodec::writeImage (std::ostream* stream, Image& image, int quality,
   if (EGifPutScreenDesc(GifFile, image.w, image.h,
 			ColorMapSize, 0, OutputColorMap) == GIF_ERROR ||
       EGifPutImageDesc(GifFile, 0, 0, image.w, image.h,
-		       false, 0) == GIF_ERROR)
+		       false, NULL) == GIF_ERROR)
     {
       std::cerr << "Error writing GIF header." << std::endl;
       return false;
@@ -235,7 +288,7 @@ bool GIFCodec::writeImage (std::ostream* stream, Image& image, int quality,
 
   delete[] RedBuffer; delete[] GreenBuffer; delete[] BlueBuffer;
 
-  EGifCloseFile(GifFile, &GifError);
+  Internal_EGifCloseFile(GifFile);
   return true;
 }