[Fwd: Put image to nondefault visuial: help needed]
Andrei Zaparii
zappa at yandex-team.ru
Mon Nov 27 23:18:28 PST 2006
Hi!
I'm now trying to fix X application that puts some informational icons
on all windows (xxkb). When window is created with default visual
everything is going right. Sim, instant messenger using qt3.3, creates
window vis visual different from default. In my case default is 24bit
DirectColor and qt makes window with 32bit TrueColor.
I tried to create XImage from XpmImage with XpmAttributes set for
visual, colormap and depth from attributes for the window and valuemask
= XpmVisual | XpmColormap | XpmDepth. Image is successfuly created but
XPutImage still failing with BadMatch.
Can anyone recomend me some way to fix the problem or help me to
understand what i'm doing wrong?
May be following code snippet will be of help:
===8<===
Display *dpy;
Window win;
GC gc;
XImage * picture;
XpmImage * pixmap;
...
somwhere later in the code
...
XWindowAttributes attrs;
XGetWindowAttributes(dpy, win, &attrs);
VisualID wvid = XVisualIDFromVisual(attrs.visual);
Visual * dvis = XDefaultVisual(dpy, 0);
VisualID dvid = XVisualIDFromVisual(dvis);
if(wvid == dvid) {
XPutImage(dpy, win, gc, conf.pictures[group + 4],
0, 0, 0, 0, conf.but_geom.width, conf.but_geom.height);
}
else {
XImage * xim;
XpmAttributes ndattrs;
ndattrs.visual = attrs.visual;
ndattrs.colormap = attrs.colormap;
ndattrs.depth = attrs.depth;
ndattrs.valuemask = XpmVisual | XpmColormap | XpmDepth;
int res = XpmCreateImageFromXpmImage(dpy, pixmap, &xim, NULL,
&ndattrs);
if(XpmSuccess == res) {
XPutImage(dpy, win, gc, xim,
0, 0, 0, 0, conf.but_geom.width, conf.but_geom.height);
XDestroyImage(xim);
XSync(dpy, False);
}
===8<===
XSync is added for debugging purposes and isn't a part of application
--
Regards,
Andrei Zaparii
--
Regards,
Andrei Zaparii
More information about the xorg
mailing list