Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 571610 | Differences between
and this patch

Collapse All | Expand All

(-)libgdiplus-3.12/src/gifcodec.c.orig (-23 / +32 lines)
Lines 39-49 GUID gdip_gif_image_format_guid = {0xb96 Link Here
39
39
40
#include "gifcodec.h"
40
#include "gifcodec.h"
41
41
42
#ifdef EgifOpen
43
/* giflib declares this incorrectly as EgifOpen */
44
extern GifFileType *EGifOpen(void *userData, OutputFunc writeFunc);
45
#endif
46
47
/* Data structure used for callback */
42
/* Data structure used for callback */
48
typedef struct
43
typedef struct
49
{
44
{
Lines 107-113 gdip_gif_inputfunc (GifFileType *gif, Gi Link Here
107
*/
102
*/
108
103
109
static int
104
static int
110
AddExtensionBlockMono(SavedImage *New, int Len, BYTE ExtData[])
105
AddExtensionBlockMono(SavedImage *New, int Function, int Len, BYTE ExtData[])
111
{
106
{
112
	ExtensionBlock	*ep;
107
	ExtensionBlock	*ep;
113
108
Lines 123-137 AddExtensionBlockMono(SavedImage *New, i Link Here
123
118
124
	ep = &New->ExtensionBlocks[New->ExtensionBlockCount++];
119
	ep = &New->ExtensionBlocks[New->ExtensionBlockCount++];
125
120
121
	ep->Function = Function;
126
	ep->ByteCount=Len;
122
	ep->ByteCount=Len;
127
	ep->Bytes = (char *)GdipAlloc(ep->ByteCount);
123
	ep->Bytes = (GifByteType *)GdipAlloc(ep->ByteCount);
128
	if (ep->Bytes == NULL) {
124
	if (ep->Bytes == NULL) {
129
		return (GIF_ERROR);
125
		return (GIF_ERROR);
130
	}
126
	}
131
127
132
	if (ExtData) {
128
	if (ExtData) {
133
		memcpy(ep->Bytes, ExtData, Len);
129
		memcpy(ep->Bytes, ExtData, Len);
134
		ep->Function = New->Function;
135
	}
130
	}
136
131
137
	return (GIF_OK);
132
	return (GIF_OK);
Lines 168-173 static int Link Here
168
DGifSlurpMono(GifFileType * GifFile, SavedImage *TrailingExtensions)
163
DGifSlurpMono(GifFileType * GifFile, SavedImage *TrailingExtensions)
169
{
164
{
170
	int		ImageSize;
165
	int		ImageSize;
166
	int		Function;
171
	GifRecordType	RecordType;
167
	GifRecordType	RecordType;
172
	SavedImage	*sp;
168
	SavedImage	*sp;
173
	GifByteType	*ExtData;
169
	GifByteType	*ExtData;
Lines 234-253 DGifSlurpMono(GifFileType * GifFile, Sav Link Here
234
			}
230
			}
235
231
236
			case EXTENSION_RECORD_TYPE: {
232
			case EXTENSION_RECORD_TYPE: {
237
				if (DGifGetExtension(GifFile, &temp_save.Function, &ExtData) == GIF_ERROR) {
233
				if (DGifGetExtension(GifFile, &Function, &ExtData) == GIF_ERROR) {
238
					return (GIF_ERROR);
234
					return (GIF_ERROR);
239
				}
235
				}
240
236
241
				while (ExtData != NULL) {
237
				while (ExtData != NULL) {
242
					/* Create an extension block with our data */
238
					/* Create an extension block with our data */
243
					if (AddExtensionBlockMono(&temp_save, ExtData[0], &ExtData[1]) == GIF_ERROR) {
239
					if (AddExtensionBlockMono(&temp_save, Function, ExtData[0], &ExtData[1]) == GIF_ERROR) {
244
						return (GIF_ERROR);
240
						return (GIF_ERROR);
245
					}
241
					}
246
242
247
					if (DGifGetExtensionNext(GifFile, &ExtData) == GIF_ERROR) {
243
					if (DGifGetExtensionNext(GifFile, &ExtData) == GIF_ERROR) {
248
						return (GIF_ERROR);
244
						return (GIF_ERROR);
249
					}
245
					}
250
					temp_save.Function = 0;
251
				}
246
				}
252
				break;
247
				break;
253
			}
248
			}
Lines 306-314 gdip_load_gif_image (void *stream, GpIma Link Here
306
	loop_counter = FALSE;
301
	loop_counter = FALSE;
307
302
308
	if (from_file) {
303
	if (from_file) {
309
		gif = DGifOpen(stream, &gdip_gif_fileinputfunc);
304
		gif = DGifOpen(stream, &gdip_gif_fileinputfunc, NULL);
310
	} else {
305
	} else {
311
		gif = DGifOpen (stream, &gdip_gif_inputfunc);
306
		gif = DGifOpen (stream, &gdip_gif_inputfunc, NULL);
312
	}
307
	}
313
	
308
	
314
	if (gif == NULL) {
309
	if (gif == NULL) {
Lines 583-589 gdip_load_gif_image (void *stream, GpIma Link Here
583
	}
578
	}
584
579
585
	FreeExtensionMono(&global_extensions);
580
	FreeExtensionMono(&global_extensions);
581
#if (GIFLIB_MAJOR > 5) || ((GIFLIB_MAJOR == 5) && (GIFLIB_MINOR >= 1))
582
	DGifCloseFile (gif, NULL);
583
#else
586
	DGifCloseFile (gif);
584
	DGifCloseFile (gif);
585
#endif
587
586
588
	*image = result;
587
	*image = result;
589
	return Ok;
588
	return Ok;
Lines 599-605 error: Link Here
599
598
600
	if (gif != NULL) {
599
	if (gif != NULL) {
601
		FreeExtensionMono (&global_extensions);
600
		FreeExtensionMono (&global_extensions);
601
#if (GIFLIB_MAJOR > 5) || ((GIFLIB_MAJOR == 5) && (GIFLIB_MINOR >= 1))
602
		DGifCloseFile (gif, NULL);
603
#else
602
		DGifCloseFile (gif);
604
		DGifCloseFile (gif);
605
#endif
603
	}
606
	}
604
607
605
	*image = NULL;
608
	*image = NULL;
Lines 663-671 gdip_save_gif_image (void *stream, GpIma Link Here
663
	}
666
	}
664
667
665
	if (from_file) {
668
	if (from_file) {
666
		fp = EGifOpenFileName (stream, 0);
669
		fp = EGifOpenFileName (stream, 0, NULL);
667
	} else {
670
	} else {
668
		fp = EGifOpen (stream, gdip_gif_outputfunc);
671
		fp = EGifOpen (stream, gdip_gif_outputfunc, NULL);
669
	}
672
	}
670
		
673
		
671
	if (!fp) {
674
	if (!fp) {
Lines 704-710 gdip_save_gif_image (void *stream, GpIma Link Here
704
					goto error; 
707
					goto error; 
705
				}
708
				}
706
709
707
				cmap = MakeMapObject(cmap_size, 0);
710
				cmap = GifMakeMapObject(cmap_size, 0);
708
711
709
				pixbuf = GdipAlloc(pixbuf_size);
712
				pixbuf = GdipAlloc(pixbuf_size);
710
				if (pixbuf == NULL) {
713
				if (pixbuf == NULL) {
Lines 795-801 gdip_save_gif_image (void *stream, GpIma Link Here
795
				pixbuf = pixbuf_org;
798
				pixbuf = pixbuf_org;
796
			} else {
799
			} else {
797
				cmap_size = 256;
800
				cmap_size = 256;
798
				cmap  = MakeMapObject (cmap_size, 0);
801
				cmap  = GifMakeMapObject (cmap_size, 0);
799
802
800
				red = GdipAlloc(pixbuf_size);
803
				red = GdipAlloc(pixbuf_size);
801
				green = GdipAlloc(pixbuf_size);
804
				green = GdipAlloc(pixbuf_size);
Lines 826-838 gdip_save_gif_image (void *stream, GpIma Link Here
826
						v += 4;
829
						v += 4;
827
					}
830
					}
828
				}
831
				}
829
				if (QuantizeBuffer(bitmap_data->width, bitmap_data->height, &cmap_size, 
832
				if (GifQuantizeBuffer(bitmap_data->width, bitmap_data->height, &cmap_size, 
830
						red,  green, blue, pixbuf, cmap->Colors) == GIF_ERROR) {
833
						red,  green, blue, pixbuf, cmap->Colors) == GIF_ERROR) {
831
					goto error;
834
					goto error;
832
				}
835
				}
833
			}
836
			}
834
837
835
			cmap->BitsPerPixel = BitSize (cmap_size);
838
			cmap->BitsPerPixel = GifBitSize (cmap_size);
836
			cmap->ColorCount = 1 << cmap->BitsPerPixel;
839
			cmap->ColorCount = 1 << cmap->BitsPerPixel;
837
840
838
			if ((frame == 0) && (k == 0)) {
841
			if ((frame == 0) && (k == 0)) {
Lines 850-857 gdip_save_gif_image (void *stream, GpIma Link Here
850
						Buffer[0] = 1;
853
						Buffer[0] = 1;
851
						Buffer[1] = ptr[0];
854
						Buffer[1] = ptr[0];
852
						Buffer[2] = ptr[1];
855
						Buffer[2] = ptr[1];
853
						EGifPutExtensionFirst(fp, APPLICATION_EXT_FUNC_CODE, 11, "NETSCAPE2.0");
856
						EGifPutExtensionLeader(fp, APPLICATION_EXT_FUNC_CODE);
854
						EGifPutExtensionLast(fp, APPLICATION_EXT_FUNC_CODE, 3, Buffer);
857
						EGifPutExtensionBlock(fp, 11, "NETSCAPE2.0");
858
						EGifPutExtensionBlock(fp, 3, Buffer);
859
						EGifPutExtensionTrailer(fp);
855
					}
860
					}
856
				}
861
				}
857
862
Lines 903-909 gdip_save_gif_image (void *stream, GpIma Link Here
903
				pixbuf += bitmap_data->width;
908
				pixbuf += bitmap_data->width;
904
			}
909
			}
905
910
906
			FreeMapObject (cmap);
911
			GifFreeMapObject (cmap);
907
			if (red != NULL) {
912
			if (red != NULL) {
908
				GdipFree (red);
913
				GdipFree (red);
909
			}
914
			}
Lines 925-937 gdip_save_gif_image (void *stream, GpIma Link Here
925
		}
930
		}
926
	}
931
	}
927
932
933
#if (GIFLIB_MAJOR > 5) || ((GIFLIB_MAJOR == 5) && (GIFLIB_MINOR >= 1))
934
	EGifCloseFile (fp, NULL);
935
#else
928
	EGifCloseFile (fp);	
936
	EGifCloseFile (fp);	
937
#endif
929
	
938
	
930
	return Ok;
939
	return Ok;
931
940
932
error:
941
error:
933
	if (cmap != NULL) {
942
	if (cmap != NULL) {
934
		FreeMapObject (cmap);
943
		GifFreeMapObject (cmap);
935
	}
944
	}
936
945
937
	if (red != NULL) {
946
	if (red != NULL) {

Return to bug 571610