[comp.windows.interviews] xwd files and rasters

linton@marktwain.rad.sgi.com (Mark Linton) (04/20/91)

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.