(ReadImage): lets get the offset right. This will let transparent gifs

1999-10-30    <jrb@redhat.com>

	(ReadImage): lets get the offset right.  This will let transparent
	gifs work.


Right now, gifs with transparency, both interlaced and non-interlaced,
seem to work perfectly fine.  I haven't tried grayscale gifs yet, and I
seem to be getting offset in my RGB buffer with non-alpha gifs. )-:
This leads to pretty, but incorrect, images.

-Jonathan
This commit is contained in:
0 1999-10-30 23:07:18 +00:00 committed by Jonathan Blandford
parent bcf6c51c4c
commit bcad6d8598
2 changed files with 20 additions and 14 deletions

View File

@ -3,6 +3,8 @@
* src/io-gif.c: Some more work. Now it generates a gdk_pixbuf of * src/io-gif.c: Some more work. Now it generates a gdk_pixbuf of
the right size, at a minimum, even if the image is squished and the right size, at a minimum, even if the image is squished and
the wrong color. the wrong color.
(ReadImage): lets get the offset right. This will let transparent
gifs work.
1999-10-28 Jonathan Blandford <jrb@redhat.com> 1999-10-28 Jonathan Blandford <jrb@redhat.com>

View File

@ -74,7 +74,6 @@ struct _GifContext
unsigned int aspect_ratio; unsigned int aspect_ratio;
int gray_scale; int gray_scale;
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
guchar used_cmap[3][256];
Gif89 gif89; Gif89 gif89;
}; };
@ -367,7 +366,6 @@ ReadImage (FILE *file,
guchar c; guchar c;
gint xpos = 0, ypos = 0, pass = 0; gint xpos = 0, ypos = 0, pass = 0;
gint v; gint v;
gint i, j;
/* /*
** Initialize the Compression routines ** Initialize the Compression routines
@ -377,6 +375,7 @@ ReadImage (FILE *file,
return; return;
} }
g_print ("c = %d\n", c);
if (LWZReadByte (file, TRUE, c) < 0) { if (LWZReadByte (file, TRUE, c) < 0) {
/*g_message (_("GIF: error while reading\n"));*/ /*g_message (_("GIF: error while reading\n"));*/
return; return;
@ -388,22 +387,20 @@ ReadImage (FILE *file,
context->width, context->width,
context->height); context->height);
for (i = 0, j = 0; i < ncols; i++) {
context->used_cmap[0][i] = cmap[0][i];
context->used_cmap[1][i] = cmap[1][i];
context->used_cmap[2][i] = cmap[2][i];
}
dest = gdk_pixbuf_get_pixels (context->pixbuf); dest = gdk_pixbuf_get_pixels (context->pixbuf);
while ((v = LWZReadByte (file, FALSE, c)) >= 0) { while ((v = LWZReadByte (file, FALSE, c)) >= 0) {
// g_print ("in inner loop: xpos = %d, ypos = %d\n", xpos, ypos);
if (context->gif89.transparent) { if (context->gif89.transparent) {
temp = dest + ( (ypos * len) + xpos ) * 2; temp = dest + (ypos * len + xpos) * 4;
*temp = (guchar) v; *temp = cmap [0][(guchar) v];
*(temp+1) = (guchar) ((v == context->gif89.transparent) ? 0 : 255); *(temp+1) = cmap [1][(guchar) v];
*(temp+2) = cmap [2][(guchar) v];
*(temp+3) = (guchar) ((v == context->gif89.transparent) ? 0 : 65535);
} else { } else {
temp = dest + (ypos * len + xpos) * 3;
temp = dest + (ypos * len) + xpos; *temp = cmap [0][(guchar) v];
*temp = (guchar) v; *(temp+1) = cmap [1][(guchar) v];
*(temp+2) = cmap [2][(guchar) v];
} }
xpos++; xpos++;
@ -448,8 +445,14 @@ ReadImage (FILE *file,
} }
fini: fini:
ypos = 0;
/* while (ReadOK (file, &c, 1) >= 0)
ypos++;
g_print ("ypos%d\n", ypos);*/
/*
if (LWZReadByte (file, FALSE, c) >= 0) if (LWZReadByte (file, FALSE, c) >= 0)
g_print ("GIF: too much input data, ignoring extra...\n"); g_print ("GIF: too much input data, ignoring extra...\n");
*/
} }
/* Shared library entry point */ /* Shared library entry point */
@ -516,6 +519,7 @@ image_load (FILE *file)
} }
for (;;) { for (;;) {
g_print ("in loop\n");
if (!ReadOK (file, &c, 1)) { if (!ReadOK (file, &c, 1)) {
/*g_message (_("GIF: EOF / read error on image data\n"));*/ /*g_message (_("GIF: EOF / read error on image data\n"));*/
return context->pixbuf; return context->pixbuf;