show an image on RootWindow

KAMALNEET SINGH kamalneet.s at samsung.com
Wed Jul 9 20:33:31 PDT 2008


Lucas wrote:
> Daniel Stone wrote:
>> On Mon, Jul 07, 2008 at 02:25:45PM -0300, Lucas wrote:
>>   
>>> I'm programming with Xlib and cairo libs but I couldn't show an image on
>>> RootWindow. how can I do this?
>>>     
>> Use XPutImage once you have the raw, decoded image.
>>
>> Cheers,
>> Daniel
>>   
> I couldn't load an image with xlib, I tried to use XCreateImage to do it 
> and XPutImage to show the image on screen, but it didn't work. Can you 
> send me an example how to load an image and put it on screen?

Are you able to draw anything at all on the root window? And do you get 
any X error?

I don't know what you are trying to do. If you are trying to do this on 
gnome, kde, etc.., what you see is actually the desktop window, not the 
root window. The attached code tries to guess the desktop window,
create an override-redirect child window of it, and draw some lines, rectangles
on it.. Works at least on KDE4 and GNOME on my system. I think there 
should be a better (more standard/portable) way, but I don't know..

If it's only a matter of image, it should be as simple as:
img = XCreateImage(display, NULL, defaultDepth, ZPixmap, 0, 
(char*)imgdata, imgwidth, imgheight, 32, 0);
XPutImage(display, drawable, gc, img, 0, 0, 50, 100, imgwidth, 
imgheight);

~kammal

> 
> thank you,
> 
> Lucas
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: desktop.c
Type: application/octet-stream
Size: 2826 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg/attachments/20080710/0e9c5ade/attachment.obj>


More information about the xorg mailing list