[comp.windows.x] creating n-bit Pixmaps on other-than-n-bit screens

arne@rrzbu.hanse.de (Arne Ludwig) (07/24/90)

R3 server. R4 Xlib. (although this doesn't matter)

xdpyinfo output:
...
supported pixmap formats:
...
    depth 8, bits_per_pixel 8, scanline_pad 32
...
number of screens:    1

screen #0:
  depths (1):    4


So it won't create Pixmaps with depths other than 4 (and 1), i.e.
	pix8 = XCreatePixmap(dpy, drawable_on_screen_0, 64, 64, 8);
fails with BadValue. Fine.

Does this mean, the server supports 8 bit Pixmaps but there is no
screen that does?? Why should anybody do that?
Is this a problem with my particular server or with my understanding
of the protocol? Can I get around that restriction?

PS.
I won't need to CopyArea that Pixmap, I just need to GetImage from it.
What I really need is a way to convert a depth 8 XImage portably.
-- 
Arne Ludwig		arne@rrzbu.hanse.de	...uunet!??????!rrzbu!arne

john@acorn.co.uk (John Bowler) (07/30/90)

In article <1597@rrzbu.UUCP> arne@rrzbu.hanse.de (Arne Ludwig) writes:
>xdpyinfo output:
>...
>supported pixmap formats:
>...
>    depth 8, bits_per_pixel 8, scanline_pad 32
>...
>number of screens:    1
>
>screen #0:
>  depths (1):    4
>
>
>So it won't create Pixmaps with depths other than 4 (and 1), i.e.
>	pix8 = XCreatePixmap(dpy, drawable_on_screen_0, 64, 64, 8);
>fails with BadValue. Fine.
>
>Does this mean, the server supports 8 bit Pixmaps but there is no
>screen that does?? Why should anybody do that?

Probably because some ways of running the server (eg some particular
screen drivers) handle depth 8 pixmaps; so the support is in there,
but the way your system is configured no screens have this capability.

>Is this a problem with my particular server or with my understanding
>of the protocol? Can I get around that restriction?

I would say that it is a bug in the server, but this is clearly a
matter of opinion.  The relevant section of the protocol says:-

	``An entry for a depth is included if any screen supports
	that depth...''

It *doesn't* say ``if and only if'' - so maybe this server is legal.
You cannot get round the restriction.  It may be difficult to change
the server to avoid this problem (ie not to advertise the depth 8
format) - there is a featureette in the MIT sample server which
(effectively) requires that all the depths are set up before the
individual screens are handled.  What I do is to support every
supported depth pixmap (1,4,8,16,24,32) on every screen, regardless
of whether any screen has a visual which will display that depth -
the protocol says (of a screen's allowed depths):-

	``Pixmaps are supported for each depth listed, and windows
	of that depth are supported if at least one visual type
	is listed for the depth.''

So, by implication, it is legal to have a depth without any visuals
to support it.

>I won't need to CopyArea that Pixmap, I just need to GetImage from it.
>What I really need is a way to convert a depth 8 XImage portably.

Um.  Are you sure you want to do it this way?  All the XImage conversion
is done in the client program (each server only understands one (server
specific) format for a depth 8 image).  Creating a pixmap and doing a
GetImage will give you an image format which varies from server to server.
The XImage interface will handle any X format which you specify - just
fill in an XImage structure with the information specifying the format
you want.

John Bowler (jbowler@acorn.co.uk)