Submitted by Anonymous on Tue, 06/12/2001 - 08:48. Developers
Hi everybody
I need to create an Ximage from a bitmap buffer.
The problem is
I receive in input a buffer that can be a RGB buffer or
a buffer of indexes associated with a colortable.
The question is
Is it necessary to create a new buffer with the indexes of the colormap of the window in which the image is displayed (so with the correct depth)
or there is an easier solution?
Now I use a BGRH buffer and in RedHat Linux 6.0 with Enlightenment Window Manager and Motif 2.1.10
it works but in RedHat Linux 7.0 with Sawfish Window Manager, Motif 2.1.10 it does?t work it only shows a very small empty square.
I also try to change the colormap of a window with the function
XstoreColor but I obtain an error.
Thanks
Because the bitmap you receive is not an X bitmap but a buffer, and because an XImage is basically a data structure with extra display information, you are probably best doing the conversion as a data-to-data transfer on the client side. That is, you likely will iterate over the pixels in the source and convert them to pixels in the target, using XPutPixel().
The alternative is to render the bitmap into an X Pixmap and then to retrieve it as an Image using XGetImage(). This route uses the X server as part of the conversion, while still demanding that you get the original data displayed.
XStoreColor() changes the color associated with a colormap entry; I don`t believe that the colormap associated with a window can be changed after that window is created.
Worked fine!
Thanks a lot a lot a lot -)