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
|
---
src/gifcodec.c | 50 +++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 41 insertions(+), 9 deletions(-)
Index: libgdiplus-2.10.9/src/gifcodec.c
===================================================================
--- libgdiplus-2.10.9.orig/src/gifcodec.c
+++ libgdiplus-2.10.9/src/gifcodec.c
@@ -39,8 +39,15 @@ GUID gdip_gif_image_format_guid = {0xb96
#include "gifcodec.h"
+#if !defined(GIFLIB_MAJOR) || GIFLIB_MAJOR < 5
/* giflib declares this incorrectly as EgifOpen */
extern GifFileType *EGifOpen(void *userData, OutputFunc writeFunc);
+#endif
+#if !defined(GIFLIB_MAJOR) || !(GIFLIB_MAJOR > 5 || \
+ (GIFLIB_MAJOR == 5 && GIFLIB_MINOR >= 1))
+# define DGifCloseFile(a, b) DGifCloseFile(a)
+# define EGifCloseFile(a, b) EGifCloseFile(a)
+#endif
/* Data structure used for callback */
typedef struct
@@ -105,7 +112,7 @@ gdip_gif_inputfunc (GifFileType *gif, Gi
*/
static int
-AddExtensionBlockMono(SavedImage *New, int Len, BYTE ExtData[])
+AddExtensionBlockMono(SavedImage *New, int Len, int func, BYTE ExtData[])
{
ExtensionBlock *ep;
@@ -129,7 +136,7 @@ AddExtensionBlockMono(SavedImage *New, i
if (ExtData) {
memcpy(ep->Bytes, ExtData, Len);
- ep->Function = New->Function;
+ ep->Function = func;
}
return (GIF_OK);
@@ -232,20 +239,20 @@ DGifSlurpMono(GifFileType * GifFile, Sav
}
case EXTENSION_RECORD_TYPE: {
- if (DGifGetExtension(GifFile, &temp_save.Function, &ExtData) == GIF_ERROR) {
+ int func;
+ if (DGifGetExtension(GifFile, &func, &ExtData) == GIF_ERROR) {
return (GIF_ERROR);
}
while (ExtData != NULL) {
/* Create an extension block with our data */
- if (AddExtensionBlockMono(&temp_save, ExtData[0], &ExtData[1]) == GIF_ERROR) {
+ if (AddExtensionBlockMono(&temp_save, func, ExtData[0], &ExtData[1]) == GIF_ERROR) {
return (GIF_ERROR);
}
if (DGifGetExtensionNext(GifFile, &ExtData) == GIF_ERROR) {
return (GIF_ERROR);
}
- temp_save.Function = 0;
}
break;
}
@@ -303,12 +310,19 @@ gdip_load_gif_image (void *stream, GpIma
result = NULL;
loop_counter = FALSE;
+#if GIFLIB_MAJOR < 5
if (from_file) {
gif = DGifOpen(stream, &gdip_gif_fileinputfunc);
} else {
gif = DGifOpen (stream, &gdip_gif_inputfunc);
}
-
+#else
+ if (from_file)
+ gif = DGifOpen(stream, &gdip_gif_fileinputfunc, NULL);
+ else
+ gif = DGifOpen(stream, &gdip_gif_inputfunc, NULL);
+#endif
+
if (gif == NULL) {
goto error;
}
@@ -581,7 +595,7 @@ gdip_load_gif_image (void *stream, GpIma
}
FreeExtensionMono(&global_extensions);
- DGifCloseFile (gif);
+ DGifCloseFile (gif, NULL);
*image = result;
return Ok;
@@ -597,7 +611,7 @@ error:
if (gif != NULL) {
FreeExtensionMono (&global_extensions);
- DGifCloseFile (gif);
+ DGifCloseFile (gif, NULL);
}
*image = NULL;
@@ -660,11 +674,22 @@ gdip_save_gif_image (void *stream, GpIma
return InvalidParameter;
}
+#if GIFLIB_MAJOR < 5
if (from_file) {
fp = EGifOpenFileName (stream, 0);
} else {
fp = EGifOpen (stream, gdip_gif_outputfunc);
}
+#else
+ if (from_file)
+ fp = EGifOpenFileName (stream, 0, NULL);
+ else
+ fp = EGifOpen (stream, gdip_gif_outputfunc, NULL);
+#define MakeMapObject GifMakeMapObject
+#define FreeMapObject GifFreeMapObject
+#define QuantizeBuffer GifQuantizeBuffer
+#define BitSize GifBitSize
+#endif
if (!fp) {
return FileNotFound;
@@ -848,8 +873,15 @@ gdip_save_gif_image (void *stream, GpIma
Buffer[0] = 1;
Buffer[1] = ptr[0];
Buffer[2] = ptr[1];
+#if GIFLIB_MAJOR < 5
EGifPutExtensionFirst(fp, APPLICATION_EXT_FUNC_CODE, 11, "NETSCAPE2.0");
EGifPutExtensionLast(fp, APPLICATION_EXT_FUNC_CODE, 3, Buffer);
+#else
+ EGifPutExtensionLeader(fp, APPLICATION_EXT_FUNC_CODE);
+ EGifPutExtensionBlock(fp, 11, "NETSCAPE2.0");
+ EGifPutExtensionBlock(fp, 3, Buffer);
+ EGifPutExtensionTrailer(fp);
+#endif
}
}
@@ -923,7 +955,7 @@ gdip_save_gif_image (void *stream, GpIma
}
}
- EGifCloseFile (fp);
+ EGifCloseFile (fp, NULL);
return Ok;
|