who@portia.Stanford.EDU (Doiknow Liu) (09/01/89)
Newsgroups: comp.graphics
Subject: Fwd:How to get RGB values from XImage data?
Expires:
References:
Sender:
Reply-To: luj@delta.ecn.purdue.edu
Followup-To:
Distribution: world
Organization: Stanford University
Keywords: XImage, RGB values, color map
I'm helping a friend to post the following article. Please reply to
his account:
ARPAnet: luj@delta.ecn.purdue.edu
UUCP: pur-ee!luj
------------------------------------------------------------------
Hello, netters,
I'm a X-novice and I'm also new to graphics. I need to know how
to get RGB values from the XImage data created by "xwd". This
might be an old question having been discussed before. Sorry if
this is a repetition.
To let you understand better where the problem lies, I'll briefly
describe what I'm doing.
Recently we got a Titan from Ardent Computer Co. Titan is a
supermini graphics computer running under AT&T System V. It
supports X11(R2) window system and a 24-plane DirectColor visual
display , and has a graphics library Dore' built on the top
of X. We have built , using Dore', a dynamic renderer to
simulate a simple battlefield scene consisting of a tank, a
tree, a house and flat "terrain". What we need to do next is to
pass the image to an image processor to extract the
information about the target and track the target.
Ideally I'd like to have the image processor to directly access
the image data stored in the frame buffer(or some other device?
-- I don't quite understand the tigr( Titan graphics hardware )
yet) in order to avoid the overhead incurred in sending
requests(XGetImage)to X server or writing/reading data to/from a
disk file. But accessing frame buffer directly requires quite
lot of understanding of the graphics hardware and I'm hoping
that someday in the near future Ardent will come up with some
solutions.( Can someone on the net shed some light on this
problem ?)
As a first step to pass the pixel data to the image processor, I
used the command level utility -- xclient "xwd" -- to dump an
image to a disk file. Now the problem is how to get pixel RGB
values from the XImage data in the file. Could someone please
tell me how the "((XImage)image)-> data " is REPRESENTED ? Are
there any routines in the public domain that enable me to do the
conversion from the XImage data to RGB values ?
Any suggestions and help would be appreciated.
Stanley J. Lu
School of Aeronautics and Astronautics
Purdue University
West Lafayette, IN 47907
Phone:(317)494-7864
ARPAnet: luj@ecn.purdue.edu
UUCP: pur-ee!luj
#include <stddisclaimer.h>rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (09/01/89)
The file format used by xwd is "documented" in the header file <X11/XWDFile.h> plus the xwd/xwud code. The contents, in order: header name color data image data The pixel values in the image data index the colormap (described by the color data) to yield RGB values. The exact method of indexing depends on the visual class described in the header, and potentially on the RGB masks in the header. However, for a 24-bit DirectColor image, assuming you have a vanilla MIT R2 or R3 xwd (Ardent may have fixed this), the color data will not be present in the file. In that case, you can just use the RGB masks in the header to directly decompose each pixel value into RGB subfields. Other entries in the header (byte_order, bitmap_unit, bitmap_pad) give the details of how the pixels are stored in the image data. Formats are described in the X protocol document (page 357 in the Digital Press book).
luj@DELTA.ECN.PURDUE.EDU (Jun Lu) (09/02/89)
Thanks for your explanations. > >The file format used by xwd is "documented" in the header file ><X11/XWDFile.h> plus the xwd/xwud code. The contents, in order: > header > name > color data > image data >The pixel values in the image data index the colormap (described >by the color data) to yield RGB values. The exact method of indexing >depends on the visual class described in the header, and potentially >on the RGB masks in the header. However, for a 24-bit DirectColor >image, assuming you have a vanilla MIT R2 or R3 xwd (Ardent may have >fixed this), the color data will not be present in the file. In >that case, you can just use the RGB masks in the header to directly >decompose each pixel value into RGB subfields. Other entries in the >header (byte_order, bitmap_unit, bitmap_pad) give the details of how >the pixels are stored in the image data. Formats are described in >the X protocol document (page 357 in the Digital Press book). > Conceptually, I know how to get the RGB values: Convert the (XImage*)->data, via color map stored, to the RGB values. However my C experince is no more than 3 months and my X experince is no more than 1 month; as a result the details are quite opaqe to me: the XPutImage.c code is quite complicated for me understand it and xwd/xwud souce codes , simple though, don't give much hints as to how to solve my problem at hand. Now suppose that I have a disk file data.img created by xwd. How do I go about the problem? /* open the disk file */ /* read the header, color map */ /* read the XImage data */ /* ? !!!!!!!!!!!!!!!!!!!!!!! How to get the RGB values ? i.e. How to make use of the XImage data and the color map ? Any examplenary fragments of code about how actually doing this coversion( on any system ) would be very helpful !!! ? */ Another question: how to specify the plane masks in the XImage so that I can port the XImage data created from one machine to another machine ?? Are Xperts at MIT going to develop utilites for above-mentioned converstion and include them in the future X11R3+ release ? Thank you. Jun S. Lu