Re: XForms: Display 24 bit images?

Steve Lamont (spl@szechuan.ucsd.edu)
Mon, 25 May 98 17:53:56 PDT

# To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :

> I would rather use XPutImage for fast display, but
> after reading about the XVisualInfo struct, I need Alexander
> Keith's beer.

Actually, although there's a lot there, you only need to deal with a
few parameters. If you're using the same Visual as the form itself,
XVisualInfo is available in the FL_STATE vector for your current
visual. If you need some other Visual, for instance if your Canvas is
TrueColor and your form is PseudoColor, you'll need to look it up -- I
don't believe that the FL_STATE vector member for TrueColor will be
correct (TC, did I get that right?). Anyhow, being a belt and
suspenders kind of programmer, I tend to look it up just to be
certain.

Here's a little routine to fish up the XVisualInfo given a Window,
should you need it:

XVisualInfo *get_window_visual_info( Window window,
Colormap *colormap_ptr )

{

XWindowAttributes attributes;
XVisualInfo template_visual_info;
XVisualInfo *matching_visual_info;
int structures;

XGetWindowAttributes( fl_get_display(), window, &attributes );
template_visual_info.visualid = XVisualIDFromVisual( attributes.visual );

matching_visual_info = XGetVisualInfo( fl_get_display(),
VisualIDMask,
&template_visual_info,
&structures );

*colormap_ptr = attributes.colormap;
return matching_visual_info;

}

In this routine, I also return a pointer to the colormap, since it's
something I happen to generally need in this context.

I probably should be slightly more paranoid and test that the
XVisualInfo actually match but if they don't, something's pretty badly
broken elsewhere, anyhow.

spl
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/