Display of a gray Image on 8 bit screen



HI,

I am trying for 2 days now to display a gray level image
on an 8 bits screen with all its gray levels (ie 256)

I try several methods but none work and all get me at the
same point. A display with only 5 gray levels.
The only way to have something correct is to use dithering
but I don't want that. I need to see the pixel with it real value.

How can I do that ???

I had no answer about this one.
But I still searching.
I succes now installing a gray level color map.
I don't use anymore GdkRGB for that
I use to display the image "gdk_image_put_pixel()"
But I still have a problem:
When I allocate my gray level color map
// Set colors of the colormap
GdkColor *colors = (GdkColor*)malloc(256 * sizeof(GdkColor));
for (int i=0; i<256; i++) {
  colors[i].red = colors[i].green = colors[i].blue = i;
  if (!gdk_color_alloc(cm, &colors[i])) {
    cerr << "couleur " << i << " failed\n";
  }
  else {
    cerr << i << " -> " << colors[i].pixel << endl;
  }
}

The problem is that the pixel entry that is given in the 
pixel field is not right. For example, when I try to allocate
r =0, g = 0, b = 0, (ie black) the pixel entry given is 0.
And when I visualise my color table with xcolor, in fact,
the value 0 correspond to a white color. And that is the case
for all the pixel entry given to me.
Is this a known bug of gdk_color_alloc ?
Am I doing something wrong.

An other problem is that gdk_color_alloc seems to never
return FALSE. When it failed to allocate a color, it
seems to return TRUE with a 0 as pixel entry.

Please Help !!

Thanks

Christian




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]