On Fri, 30 Nov 2001, Scott Smedley wrote:

> Hi Xperts,
> 
> Just subscribed to this list to ask a question at the suggestion
> of someone on #xfree86 ...
> 
> I've got a program to display output of a black & white CCD camera.
> The program currently works well on 8bit display & code is written
> for 24bit display (I'm not able to test it at that resolution) ...
> I'm trying to modify it so the program will work for 16bit display ...
> 
> I've come across this snippet of code, which I think is causing my
> problems. The call to XMatchVisualInfo() fails. I don't really
> understand why - can anyone help me out here? What do I need to do
> to make it succeed?

   Static Gray is only available with 8 bpp framebuffers in XFree86.
In 16 bpp you will find only TrueColor, and sometimes DirectColor.
How many grays do you need?  I would recommend using TrueColor
visuals and using pixels through one level of indirection.
Eg, for 256 grays.

 XColor color;

 unsigned long graylevels[256];
 int i;

 for(i = 0; i < 256; i++) {
    color.red = color.green = color.blue = i | (i << 8);
    XAllocColor(display, colormap, &color);
    graylevels[i] = color.pixel;
 }
 
 graylevels[i] then holds the pixel values corresponding to
the gray levels.  This will work optimally in any TrueColor
visual.  For StaticGray visuals you can use the same 
graylevels array for your lookups and just initialize it to
a linear ramp (value == array index).

   Note that grayscale looks like crap on depth 16 displays.
Looks a little better in depth 15, if your hardware can do that.


                                        Mark.

_______________________________________________
Xpert mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/xpert

Reply via email to