I posted this on GIFLIB's sourceforge page, but it doesn't look like it's visited very often, so I thought I'd post it here as well.
I'm trying to save raw pixels from a GdkPixbuf as a GIF with giflib. Everything works... except the colors are really screwey in the final image. I used the default, 16-color colormap from one of the utilities in giflib (EGAPalette, I think the structure was called). Everything has a magenta shade, and every color is completely off (some blues look pure red/green/blue, etc).
I am totally new to this. What do I need to do to create a ColorMap to send to giflib? I don't want to mess with colors... it just needs to look right. I'd like also to be able to save the GIF as monochrome, and certain bit-depths (up to 8-bit, of course) if possible.
Any help would be appreciated. Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Heh... I just discovered QuantizeBuffer(). I'm finally getting colors in my image. However, it's still not quite right. The grays/whites are slightly off, with a slight blue tint, but look more white than anything. I don't know why this is. I would think QuantizeBuffer() would pick the correct colors for use? Also, I see banding in certain areas of my screen (example, near gradients). I can see pretty much all colors, though.
Since I'm using GdkPixbufs, I simply grab the pixels:
unsigned char *p = pixels + y * rowstride + x * n_channels;
Then, I grab the RGB values: p[0], p[1], p[2], respectively. I build up a Red, Green, and Blue array, then I pass this to QuantizeBuffer(). Then, I write to EGifPutLine the buffer set by QuantizeBuffer(). I'm using 256 colors, 8BPP.
Any tips?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I should also note that I attempted to use a colormap from an existing GIF using the gifclrmp utility (gifclrmp -s image.gif) to create my GIF image, but the colors are still off, even though the image uses mostly the same colors.
Also, if I create a colormap with .Red, .Green, and .Blue values incrementing as the index increments (example colormap->colors[0].red = 0, colormap->colors[5].red = 55) 256 times, the image turns out to be grayscale.
I think I'm getting close...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I posted this on GIFLIB's sourceforge page, but it doesn't look like it's visited very often, so I thought I'd post it here as well.
I'm trying to save raw pixels from a GdkPixbuf as a GIF with giflib. Everything works... except the colors are really screwey in the final image. I used the default, 16-color colormap from one of the utilities in giflib (EGAPalette, I think the structure was called). Everything has a magenta shade, and every color is completely off (some blues look pure red/green/blue, etc).
I am totally new to this. What do I need to do to create a ColorMap to send to giflib? I don't want to mess with colors... it just needs to look right. I'd like also to be able to save the GIF as monochrome, and certain bit-depths (up to 8-bit, of course) if possible.
Any help would be appreciated. Thanks.
Heh... I just discovered QuantizeBuffer(). I'm finally getting colors in my image. However, it's still not quite right. The grays/whites are slightly off, with a slight blue tint, but look more white than anything. I don't know why this is. I would think QuantizeBuffer() would pick the correct colors for use? Also, I see banding in certain areas of my screen (example, near gradients). I can see pretty much all colors, though.
Since I'm using GdkPixbufs, I simply grab the pixels:
unsigned char *p = pixels + y * rowstride + x * n_channels;
Then, I grab the RGB values: p[0], p[1], p[2], respectively. I build up a Red, Green, and Blue array, then I pass this to QuantizeBuffer(). Then, I write to EGifPutLine the buffer set by QuantizeBuffer(). I'm using 256 colors, 8BPP.
Any tips?
I should also note that I attempted to use a colormap from an existing GIF using the gifclrmp utility (gifclrmp -s image.gif) to create my GIF image, but the colors are still off, even though the image uses mostly the same colors.
Also, if I create a colormap with .Red, .Green, and .Blue values incrementing as the index increments (example colormap->colors[0].red = 0, colormap->colors[5].red = 55) 256 times, the image turns out to be grayscale.
I think I'm getting close...