Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!sgi!shinobu!odin!marktwain.rad.sgi.com!linton From: linton@marktwain.rad.sgi.com (Mark Linton) Newsgroups: comp.windows.interviews Subject: Re: xwd files and rasters Message-ID: <1991Apr19.232821.8157@odin.corp.sgi.com> Date: 19 Apr 91 23:28:21 GMT References: <9104160922.AA05229@ryoma03.sk.teijin.co.jp> Sender: news@odin.corp.sgi.com (Net News) Reply-To: linton@marktwain.rad.sgi.com (Mark Linton) Organization: sgi Lines: 28 In article <9104160922.AA05229@ryoma03.sk.teijin.co.jp>, kddlab!ryoma03.sk.teijin.co.jp!jane@UUNET.UU.NET (Jane Silber) writes: |> |> I am adding a method which looks like |> |> Raster::Raster(const char *filename) |> |> where filename is a file in xwd format (X window dump, |> described in XWDFile.h). It's pretty straightforward, |> consisting of |> - reading the XWDFileHeader |> - reading the colormap |> - reading the image data itself |> - creating an XImage by calling XCreateImage. |> |> When I call XCreateImage, I use parameters (e.g, format and |> depth) that I found in the XWDFileHeader. I am having |> trouble getting it to work though, especially when the |> image is depth = 1 (i.e., black/white). In that case |> the thing crashes later on, namely when IV tries to display |> it with a XPutImage call (bad parameter match). Don't think of rasters as having a "depth", just think of them as a 2d array of colors. I would suggest you map the data to rgb values and use them to call Raster::poke. Also, you should make it a static member function Raster::open_xwd that returns a Raster* or nil if the file can't be found. If you get it working and can send it to me, I'll merge it into our tree.