Anonymous avatar Anonymous committed d5f9de6

fixed FS#227
ported from gd-libgd-pierre

Comments (0)

Files changed (4)

         /*
          * OR in the resolution
          */
-        B |= (Resolution - 1) << 5;
+        B |= (Resolution - 1) << 4;
 
         /*
          * OR in the Bits per Pixel
         /*
          * OR in the resolution
          */
-        B |= (Resolution - 1) << 5;
+        B |= (Resolution - 1) << 4;
 
         /*
          * OR in the Bits per Pixel

src/tests/gif/CMakeLists.txt

 	bug00060
 	bug00066
 	bug00181
+	bug00227
 )
 
 FOREACH(test_name ${TESTS_FILES})

src/tests/gif/Makefile.am

 ## Process this file with automake to produce Makefile.in -*-Makefile-*-
 
-EXTRA_DIST = CMakeLists.txt gif_im2im.c gif_null.c bug00005_0.gif bug00005_2.c bug00005_2.gif bug00005.c bug00060.c bug00066.c bug00066.gif bug00005_1.gif  bug00005_2_exp.png  bug00005_3.gif  bug00006.c  bug00060.gif  bug00066_exp.png bug00181.c
+EXTRA_DIST = CMakeLists.txt gif_im2im.c gif_null.c bug00005_0.gif bug00005_2.c bug00005_2.gif bug00005.c bug00060.c bug00066.c bug00066.gif bug00005_1.gif  bug00005_2_exp.png  bug00005_3.gif  bug00006.c  bug00060.gif  bug00066_exp.png bug00181.c bug00227.c

src/tests/gif/bug00227.c

+#include <stdio.h>
+#include <stdlib.h>
+#include <gd.h>
+#include <gdtest.h>
+
+#define WIDTH 150
+#define HEIGHT 1
+#define DELAY 100
+#define PROBE_SIZE 11
+
+int main()
+{
+	FILE *fp;
+	gdImagePtr im0, im1, im2;
+	int file, i;
+	char *buf;
+
+	/* generate a GIF animation */
+	im0 = gdImageCreate(WIDTH, HEIGHT);
+	if (!im0) return 1;
+	for (i = 0; i < WIDTH; i++) {
+		int c = gdImageColorAllocate(im0, i, 0xff, 0xff);
+		gdImageSetPixel(im0, i, 0, c);
+	}
+
+	fp = fopen("bug00227.gif", "wb");
+	if (!fp) return 1;
+
+	gdImageGifAnimBegin(im0, fp, 0, 0);
+
+	gdImageGifAnimAdd(im0, fp, 1, 0, 0, DELAY, 1, NULL);
+
+	im1 = gdImageCreate(WIDTH, HEIGHT);
+	if (!im1) return 1;
+	for (i = 0; i < WIDTH; i++) {
+		int c = gdImageColorAllocate(im1, i, 0x00, 0xff);
+		gdImageSetPixel(im1, i, 0, c);
+	}
+	gdImageGifAnimAdd(im1, fp, 1, 0, 0, DELAY, 1, im0);
+
+	im2 = gdImageCreate(WIDTH, HEIGHT);
+	if (!im2) return 1;
+	for (i = 0; i < WIDTH; i++) {
+		int c = gdImageColorAllocate(im2, i, 0xff, 0x00);
+		gdImageSetPixel(im2, i, 0, c);
+	}
+	gdImageGifAnimAdd(im2, fp, 1, 0, 0, DELAY, 1, im1);
+
+	gdImageGifAnimEnd(fp);
+
+	fclose(fp);
+
+	gdImageDestroy(im0);
+	gdImageDestroy(im1);
+	gdImageDestroy(im2);
+
+	/* check the Global Color Table flag */
+	fp = fopen("bug00227.gif", "rb");
+	if (!fp) return 1;
+	buf = malloc(PROBE_SIZE);
+	if (!buf) return 1;
+	if (PROBE_SIZE != fread(buf, 1, PROBE_SIZE, fp)) return 1;
+	if (buf[PROBE_SIZE-1] & 0x80) return 1;
+	free(buf);
+	fclose(fp);
+	return 0;
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.