Re: XForms: Display 24 bit images?

Steve Lamont (spl@szechuan.ucsd.edu)
Mon, 25 May 98 13:39:10 PDT

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

> I use
> XImage *ximage = XCreateImage(display, visual,
> fl_get_canvas_depth(canvas),
> ZPixmap, 0,
> cdata, width, height,
> 8, 0);
>
> where cdata is a char pointer to a buffer of size width * height * 4
> and the pixel values are ordered
>
> cdata[0] = A, cdata[1] = R, cdata[2] = G, cdata[3] = B,
> cdata[4] = A, cdata[5] = R, cdata[6] = G, cdata[7] = B,
> and so on.
>
> A is an alpha plane that I believe is ignored by the display.
> R is a red pixel value and so on.

For portability sake you really should use XPutPixel() to write the
data in the buffer, since there is no guarantee that the ordering is
the same on all machines.

You should query the Visual with XGetVisualInfo(). This will give
you, among other things, the color masks. You can then use this
information to construct a valid pixel argument to XPutPixel().

Not doing this invites anomalous behavior on different systems.

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/