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
|
This file is part of MXE.
See index.html for further information.
Taken from http://trac.osgeo.org/gdal/changeset/24491?format=diff&new=24491
Index: gdal/frmts/gif/gifdataset.cpp
===================================================================
--- gdal/frmts/gif/gifdataset.cpp (revision 23621)
+++ gdal/frmts/gif/gifdataset.cpp (revision 24491)
@@ -471,4 +471,26 @@
/************************************************************************/
+/* GDALPrintGifError() */
+/************************************************************************/
+
+static void GDALPrintGifError(const char* pszMsg)
+{
+/* GIFLIB_MAJOR is only defined in libgif >= 4.2.0 */
+/* libgif 4.2.0 has retired PrintGifError() and added GifErrorString() */
+#if defined(GIFLIB_MAJOR) && defined(GIFLIB_MINOR) && \
+ ((GIFLIB_MAJOR == 4 && GIFLIB_MINOR >= 2) || GIFLIB_MAJOR > 4)
+ /* Static string actually, hence the const char* cast */
+ const char* pszGIFLIBError = (const char*) GifErrorString();
+ if (pszGIFLIBError == NULL)
+ pszGIFLIBError = "Unknown error";
+ CPLError( CE_Failure, CPLE_AppDefined,
+ "%s. GIFLib Error : %s", pszMsg, pszGIFLIBError );
+#else
+ PrintGifError();
+ CPLError( CE_Failure, CPLE_AppDefined, "%s", pszMsg );
+#endif
+}
+
+/************************************************************************/
/* CreateCopy() */
/************************************************************************/
@@ -597,7 +619,5 @@
{
FreeMapObject(psGifCT);
- PrintGifError();
- CPLError( CE_Failure, CPLE_AppDefined,
- "Error writing gif file." );
+ GDALPrintGifError("Error writing gif file.");
EGifCloseFile(hGifFile);
VSIFCloseL( fp );
@@ -623,7 +643,5 @@
if (EGifPutImageDesc(hGifFile, 0, 0, nXSize, nYSize, bInterlace, NULL) == GIF_ERROR )
{
- PrintGifError();
- CPLError( CE_Failure, CPLE_AppDefined,
- "Error writing gif file." );
+ GDALPrintGifError("Error writing gif file.");
EGifCloseFile(hGifFile);
VSIFCloseL( fp );
|