Sign in to follow this  

Color Palette - Clueless!

Recommended Posts

Hey guys. I'm trying to save an image from raw pixels (specifically, those taken from a GdkPixbuf) as a GIF, using GIFLIB. All is well... the image is fine, except for one thing: the colors are _totally_ off. Black is white, white is black, gray is purple, etc. I know my problem lies in my ColorMapObject -- which is basically a colorpalette, something like:
struct ColorMapObject {
   int size;
   int bits_per_pixel;
   colorPalette *palette;
Where colorPalette is a structure array, which has Red, Green, and Blue set as a byte value, one for each color (so there'd be 256 RGB values for 256 colors). I'm sure you guys know how to do this: how can I create a color palette that will just "look right", for any image? I'm totally clueless. I'm going to be saving screenshots, so I guess it needs to match the system color palette? I'd like also to be able to specify the number of colors (256, 2 for monochrome, etc). Any help would be much appreciated. Thanks. :)

Share this post

Link to post
Share on other sites
Yes it does use an 8-bit screen format. The problem is, I don't know how to get my screen's palette, and convert it to a certain color depth when I want (like 256 colors, 16 colors, etc). I don't think GTK/GDK offers this option, because I've asked on the mailing list and IRC channel and no-one seems to be able to answer.

Funny thing is, I was able to do:

int x = 0;
for (x = 0; x < 256; ++x) {
color_map[x].red = (unsigned char)x;
color_map[x].green = (unsigned char)x;
color_map[x].blue = (unsigned char)x;

When I give that to giflib, the screenshot is in grayscale. :D

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this