Pixmap color depth problem - Xwindows

This is a discussion on Pixmap color depth problem - Xwindows ; Hi, Is it possible to render to off-screen bitmaps in a specified color depth without opening a window in X? I would like to use the output of some xscreensaver applications in a program which needs only pixel data, but ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Pixmap color depth problem

  1. Pixmap color depth problem

    Hi,

    Is it possible to render to off-screen bitmaps in a specified color depth
    without opening a window in X?

    I would like to use the output of some xscreensaver applications in a
    program which needs only pixel data, but doesn't know anything about
    windows, screens and displays. Thus, I would like to render the output
    to an off-screen buffer without opening a window, but still using Xlib
    function calls.

    Xscreensaver operates on windows. I thought I would use Pixmaps instead
    and obtain pixel data with XGetImage. XCreatePixmap requires a window
    specified in the funcion call, so I used the one returned by DefaultRootWindow.
    The problem is that I cannot set the color depth of the Pixmap freely, probably
    because they don't match the depth of the default screen. Unfortunately I have
    to support 16, 24 and 32bit color depths as well and it should not be related
    to the currently set screen depth.

    Is there a solution to this? Or should I do it in a completely different
    way?

    thanks in advance,
    Gabor

  2. Re: Pixmap color depth problem

    In comp.windows.x, gabor papp

    wrote
    on 29 Oct 2004 02:16:18 -0700
    <22886011.0410290116.5b930724@posting.google.com>:
    > Hi,
    >
    > Is it possible to render to off-screen bitmaps in a specified color depth
    > without opening a window in X?


    Yes, but one has to open a connection to the display. This is different
    from opening a window.

    >
    > I would like to use the output of some xscreensaver applications in a
    > program which needs only pixel data, but doesn't know anything about
    > windows, screens and displays. Thus, I would like to render the output
    > to an off-screen buffer without opening a window, but still using Xlib
    > function calls.
    >
    > Xscreensaver operates on windows. I thought I would use Pixmaps
    > instead and obtain pixel data with XGetImage. XCreatePixmap
    > requires a window specified in the funcion call, so I used
    > the one returned by DefaultRootWindow.


    That would work, to some extent. However, XGetImage renders to an
    Image structure on the client side, as opposed to Pixmaps which are
    managed on the *server* side, so your question is slightly confused.

    One can copy to a pixmap using XCopyArea(), if the depths are compatible.

    > The problem is that I cannot set the color depth of the Pixmap freely,
    > probably because they don't match the depth of the default screen.
    > Unfortunately I have to support 16, 24 and 32bit color depths as well
    > and it should not be related to the currently set screen depth.
    >
    > Is there a solution to this? Or should I do it in a completely different
    > way?


    A Pixmap is managed by the server and can only have certain depths.

    >
    > thanks in advance,
    > Gabor



    --
    #191, ewill3@earthlink.net
    It's still legal to go .sigless.

  3. Re: Pixmap color depth problem

    > That would work, to some extent. However, XGetImage renders to an
    > Image structure on the client side, as opposed to Pixmaps which are
    > managed on the *server* side, so your question is slightly confused.


    Sorry, I'm quite new to X programming. I thought that I
    get the image data from the pixmap using XGetImage like this:

    ximage = XGetImage(display, pixmap, 0, 0, width, height, ~0L, ZPixmap);

    then i can obtain the pixel data from ximage->data like

    memcpy(framebuffer, ximage->data, width*height*bpp);

    Anyway, thanks for your help.

+ Reply to Thread