Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!columbia!lamont!rbd From: rbd@lamont.ldgo.columbia.edu (roger davis) Newsgroups: comp.windows.x Subject: XImage problems Keywords: X be slow and I be stupid Message-ID: <1628@lamont.ldgo.columbia.edu> Date: 21 Aug 89 21:51:11 GMT Organization: Lamont-Doherty Geological Observatory N.Y. Lines: 40 I am writing an image processing application under X11 Release 3 and am having difficulty converting raw raster data into an XImage. My current method is: 1) XCreateImage( ... ); (using ZPixmap format) 2) loop over entire raster, converting raw raster data into pixel values and then doing XPutPixel(); 3) XPutImage( ... ); This works, but is **painfully** slow. On a Sun 4/280 w/32 Mb of memory running SunOS 4.0.1, MIT X11/R3, a 512x512 image requires between 5 and 10 minutes to load. Is there any faster way to get raster data into a Pixmap? I thought of keeping an array of 256 GC's (one for each pixel value) and then doing XDrawPoint()s with the appropriate GC, but this seems kind of ugly. I've also thought of bypassing XPutPixel() by directly writing pixel data into the XImage->data memory, but, besides this being incredibly unportable, I've been able to ascertain just about zilch from the XLib manual regarding the layout of pixels within the data array. Could someone explain the difference between XYPixmap and ZPixmap format, and how I can address individual pixels or bits thereof in an 8-bit image? I'd also like to know just how much data space I need to allocate for a width*height 8-bit XImage. The documentation seems to indicate that I need (width*height*sizeof(char)) bytes, but this causes core dumps in XPutPixel() with large images. I jacked it up to (width*height*sizeof(unsigned long)) which works OK, but this is a lot of memory for an image which may be as large as 1024x1024, and I'd rather not waste it if I don't need to. -- Roger Davis Lamont-Doherty Geological Observatory rbd@lamont.ldgo.columbia.edu