XForms: Display 24 bit images?

Alexander Keith (akeith@crc.ricoh.com)
Mon, 25 May 1998 10:16:13 -0700

# To subscribers of the xforms list from Alexander Keith <akeith@crc.ricoh.com> :

First the disclamer: This works, is it the best way I'm not sure.

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.

To paint the image to the canvas I use

XPutImage(display, window, gc,
ximage, 0, 0, hos, vos, width, height);

hos, vos is the horz and vert offset within the canvas window.

0, 0 is the horz and vert offset within the cdata buffer
and width and height is the extent of the cdata buffer to be
painted to the canvas.

Alex

Sundar Vedula writes:
> # To subscribers of the xforms list from Sundar Vedula <srv@cs.cmu.edu> :
>
> This is really an X question, but I guess some of you might know the
> answer:
>
> I am trying to display a 24 bit image in a TrueColor visual, in an Xforms
> canvas. After the initializations, I call XMatchVisualInfo, then
> XCreateImage , and then XCreatePixmap. My Xcreateimage call is
>
> image = XCreateImage (display, visual, 24, ZPixmap, 0, data, width,
> height, 32, 3*width);
>
> I am running on an SGI, and my visual is TrueColor(confirmed). However,
> the image returned is 32 bits per pixel, and therefore my image is getting
> compressed to 2/3 its width on the screen. The image itself looks
> greyscale, so only one band seems to be displayed.
>
> Does anyone have advice for me? (or even better, code that works for
> X display of truecolor images).
>
> Thanks,
> Sundar Vedula
> Carnegie Mellon University
>
>
> _________________________________________________
> 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/
>
>
_________________________________________________
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/