Path: utzoo!attcan!uunet!wuarchive!csd4.csd.uwm.edu!bionet!agate!ucbvax!bloom-beacon!DELTA.ECN.PURDUE.EDU!luj From: luj@DELTA.ECN.PURDUE.EDU (Jun Lu) Newsgroups: comp.windows.x Subject: Re: Fwd: How to get RGB values from XImage data Message-ID: <8909020431.AA13449@delta.ecn.purdue.edu> Date: 2 Sep 89 04:31:54 GMT Sender: daemon@bloom-beacon.MIT.EDU Organization: The Internet Lines: 46 Thanks for your explanations. > >The file format used by xwd is "documented" in the header file > 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