summaryrefslogtreecommitdiff
path: root/graphics/gd/files/patch-gdtest.c
blob: 85c855d4db028989b48dcfab7193991792fe95e3 (plain) (blame)
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
--- gdtest.c.orig	Thu Apr 25 14:16:47 2002
+++ gdtest.c	Tue Nov  6 15:53:38 2001
@@ -84,6 +84,35 @@
   gdImageDestroy (im2);
   ctx->gd_free (ctx);
 
+        /* */
+        /* Send to GIF File then Ptr */
+        /* */
+        sprintf(of, "%s.gif", argv[1]);
+        out = fopen(of, "wb");
+        gdImageGif(im, out);
+        fclose(out);
+
+        in = fopen(of, "rb");
+        if (!in) {
+                fprintf(stderr, "GIF Output file does not exist!\n");
+                exit(1);
+        }
+        im2 = gdImageCreateFromGif(in);
+        fclose(in);
+
+        CompareImages("GD->GIF File->GD", ref, im2);
+
+        unlink(of);
+        gdImageDestroy(im2);
+
+	iptr = gdImageGifPtr(im,&sz);
+	ctx = gdNewDynamicCtx(sz,iptr);
+	im2 = gdImageCreateFromGifCtx(ctx);
+
+        CompareImages("GD->GIF ptr->GD", ref, im2);
+
+	gdImageDestroy(im2);
+	ctx->gd_free(ctx);
 
   /* */
   /* Send to GD2 File then Ptr */
@@ -200,7 +229,30 @@
       gdImageDestroy (im2);
     };
 
-  unlink (of);
+	/*
+	** Test gdImageCreateFromGifSource
+	**/
+
+	in = fopen(of, "rb");
+
+	if (!in)
+	  {
+		fprintf (stderr, "GD Source: ERROR - GD Source input file does not exist - Sink may have failed!\n");
+	  };
+
+	imgsrc.source = freadWrapper;
+	imgsrc.context = in;
+	im2 = gdImageCreateFromGifSource(&imgsrc);
+	fclose(in);
+
+	if (im2 == NULL) {
+		printf("GD Source (GIF): ERROR Null returned by gdImageCreateFromGifSource\n");
+	} else {
+		CompareImages("GD Source (GIF)", ref, im2);
+		gdImageDestroy(im2);
+	};
+
+	unlink(of);
 
   /* */
   /*  Test Extraction */
@@ -266,6 +318,10 @@
 
   printf ("[Merged Image has %d colours]\n", im2->colorsTotal);
   CompareImages ("Merged (gdtest.png, gdtest_merge.png)", im2, im3);
+
+  out = fopen ("test/gdtest_merge_out.png", "wb");
+  gdImagePng(im2, out);
+  close(out);
 
   gdImageDestroy (im2);
   gdImageDestroy (im3);