ecere/gfx/bitmaps/GIFFormat: Fixes to build with Giflib 5.0.x
[sdk] / ecere / src / gfx / bitmaps / GIFFormat.ec
index 69042ae..681692d 100644 (file)
@@ -1,22 +1,24 @@
 namespace gfx::bitmaps;
 
-#include "gif_lib.h"
-
 import "Display"
 
+#if !defined(__EMSCRIPTEN__)
+
+#include "gif_lib.h"
+
 static int ReadData(GifFileType * gifFile, GifByteType * bytes, int size)
 {
    File f = gifFile->UserData;
    return f.Read(bytes, 1, size);
 }
 
-static int WriteData(GifFileType * gifFile, GifByteType * bytes, int size)
+/*static int WriteData(GifFileType * gifFile, GifByteType * bytes, int size)
 {
-   // File f = gifFile->UserData;
-   // f.Write(bytes, 1, size);
+   File f = gifFile->UserData;
+   return f.Write(bytes, 1, size);
 }
-
-static char * extensions[] = { "gif", null };
+*/
+static const char * extensions[] = { "gif", null };
 
 class GIFFormat : BitmapFormat
 {
@@ -26,7 +28,7 @@ class GIFFormat : BitmapFormat
    {
       bool result = false;
 
-#if GIFLIB_MAJOR > 5
+#if (GIFLIB_MAJOR > 5 || (GIFLIB_MAJOR == 5 && GIFLIB_MINOR >= 1))
       GifFileType * gifFile = DGifOpen(f, ReadData, null);
 #else
       GifFileType * gifFile = DGifOpen(f, ReadData);
@@ -105,7 +107,11 @@ class GIFFormat : BitmapFormat
                result = true;
             }
          }
+#if (GIFLIB_MAJOR > 5 || (GIFLIB_MAJOR == 5 && GIFLIB_MINOR >= 1))
+         DGifCloseFile(gifFile, null);
+#else
          DGifCloseFile(gifFile);
+#endif
       }
 
       if(!result)
@@ -113,15 +119,17 @@ class GIFFormat : BitmapFormat
       return result;
    }
 
-   bool Save(Bitmap bitmap, char * filename, void * options)
+   bool Save(Bitmap bitmap, const char * filename, void * options)
    {
       bool result = false;
       return result;
    }
 
-   ColorAlpha * LoadPalette(char * fileName, char * type)
+   ColorAlpha * LoadPalette(const char * fileName, const char * type)
    {
       ColorAlpha * result = null;
       return result;
    }
 }
+
+#endif // !defined(__EMSCRIPTEN__)