wok-next view xplanet/stuff/patches/giflib5.diff @ rev 21727

created recipe for vbindiff
author Hans-G?nter Theisgen
date Sat Nov 21 14:32:44 2020 +0100 (2020-11-21)
parents
children
line source
1 Index: b/src/libimage/gif.c
2 ===================================================================
3 --- a/src/libimage/gif.c
4 +++ b/src/libimage/gif.c
5 @@ -38,32 +38,34 @@ read_gif(const char *filename, int *widt
6 GifRecordType record_type;
7 GifRowType *buffer = NULL;
9 - int i, j;
10 + int i, j, err;
11 int color_index;
12 unsigned char *ptr = NULL;
14 - infile = DGifOpenFileName(filename);
15 + infile = DGifOpenFileName(filename, &err);
17 if (infile == NULL)
18 {
19 - PrintGifError();
20 + fprintf(stderr, "\nGIF-LIB error: %s.\n", GifErrorString(err));
21 return(0);
22 }
24 do
25 {
26 - if (DGifGetRecordType(infile, &record_type) == GIF_ERROR)
27 + err = DGifGetRecordType(infile, &record_type);
28 + if (err != GIF_OK)
29 {
30 - PrintGifError();
31 + fprintf(stderr, "\nGIF-LIB error: %s.\n", GifErrorString(err));
32 return(0);
33 }
35 switch (record_type)
36 {
37 case IMAGE_DESC_RECORD_TYPE:
38 - if (DGifGetImageDesc(infile) == GIF_ERROR)
39 + err = DGifGetImageDesc(infile);
40 + if (err != GIF_OK)
41 {
42 - PrintGifError();
43 + fprintf(stderr, "\nGIF-LIB error: %s.\n", GifErrorString(err));
44 return(0);
45 }
47 @@ -105,16 +107,18 @@ read_gif(const char *filename, int *widt
48 /* Skip extension blocks */
49 int ext_code;
50 GifByteType *ext;
51 - if (DGifGetExtension(infile, &ext_code, &ext) == GIF_ERROR)
52 + err = DGifGetExtension(infile, &ext_code, &ext);
53 + if (err != GIF_OK)
54 {
55 - PrintGifError();
56 + fprintf(stderr, "\nGIF-LIB error: %s.\n", GifErrorString(err));
57 return(0);
58 }
59 while (ext != NULL)
60 {
61 - if (DGifGetExtensionNext(infile, &ext) == GIF_ERROR)
62 + err = DGifGetExtensionNext(infile, &ext);
63 + if (err != GIF_OK)
64 {
65 - PrintGifError();
66 + fprintf(stderr, "\nGIF-LIB error: %s.\n", GifErrorString(err));
67 return(0);
68 }
69 }
70 @@ -154,14 +158,14 @@ read_gif(const char *filename, int *widt
72 free(buffer);
74 - DGifCloseFile(infile);
75 + DGifCloseFile(infile, NULL);
76 return(1);
77 }
79 int
80 write_gif(const char *filename, int width, int height, char *rgb)
81 {
82 - int i;
83 + int i, err;
84 int colormap_size = 256;
85 GifByteType *red, *green, *blue, *buffer, *ptr;
86 GifFileType *outfile;
87 @@ -178,7 +182,7 @@ write_gif(const char *filename, int widt
88 return(0);
89 }
91 - colormap = MakeMapObject(colormap_size, NULL);
92 + colormap = GifMakeMapObject(colormap_size, NULL);
94 for (i = 0; i < width * height; i++)
95 {
96 @@ -187,10 +191,11 @@ write_gif(const char *filename, int widt
97 blue[i] = (GifByteType) rgb[3*i+2];
98 }
100 - if (QuantizeBuffer(width, height, &colormap_size, red, green, blue,
101 - buffer, colormap->Colors) == GIF_ERROR)
102 + err = GifQuantizeBuffer(width, height, &colormap_size, red, green, blue,
103 + buffer, colormap->Colors);
104 + if (err != GIF_OK)
105 {
106 - PrintGifError();
107 + fprintf(stderr, "\nGIF-LIB error: %s.\n", GifErrorString(err));
108 return(0);
109 }
111 @@ -198,24 +203,24 @@ write_gif(const char *filename, int widt
112 free(green);
113 free(blue);
115 - outfile = EGifOpenFileName((char *) filename, FALSE);
116 + outfile = EGifOpenFileName((char *) filename, 0, &err);
117 if (outfile == NULL)
118 {
119 - PrintGifError();
120 + fprintf(stderr, "\nGIF-LIB error: %s.\n", GifErrorString(err));
121 return(0);
122 }
124 - if (EGifPutScreenDesc(outfile, width, height, colormap_size, 0, colormap)
125 - == GIF_ERROR)
126 + err = EGifPutScreenDesc(outfile, width, height, colormap_size, 0, colormap);
127 + if (err != GIF_OK)
128 {
129 - PrintGifError();
130 + fprintf(stderr, "\nGIF-LIB error: %s.\n", GifErrorString(err));
131 return(0);
132 }
134 - if (EGifPutImageDesc(outfile, 0, 0, width, height, FALSE, NULL)
135 + if (EGifPutImageDesc(outfile, 0, 0, width, height, 0, NULL)
136 == GIF_ERROR)
137 {
138 - PrintGifError();
139 + fprintf(stderr, "\nGIF-LIB error: %s.\n", GifErrorString(err));
140 return(0);
141 }
143 @@ -224,7 +229,7 @@ write_gif(const char *filename, int widt
144 {
145 if (EGifPutLine(outfile, ptr, width) == GIF_ERROR)
146 {
147 - PrintGifError();
148 + fprintf(stderr, "\nGIF-LIB error: %s.\n", GifErrorString(err));
149 return(0);
150 }
151 ptr += width;
152 @@ -232,8 +237,8 @@ write_gif(const char *filename, int widt
154 EGifSpew(outfile);
156 - if (EGifCloseFile(outfile) == GIF_ERROR)
157 - PrintGifError();
158 + if (EGifCloseFile(outfile, NULL) == GIF_ERROR)
159 + fprintf(stderr, "\nGIF-LIB error: %s.\n", GifErrorString(err));
161 free(buffer);