[comp.windows.x] Need help with XPutImage

lanzo@mercutio.steinmetz (Mark Lanzo) (10/06/87)

Help!

I'm trying to display an image using the X system (X11), but don't seem to be
getting anywhere.  Let's see if someone out there can tell me what I'm
doing wrong ... or if it's the X system at fault here.

First off, a bit of background, since obviously I don't want to include
the entire program here:  I have opened an 8-plane PseudoColor window up
on the screen, mapped it, created and installed a colormap for it, etc. etc.
I can draw into the screen using various graphics commands, so I don't think
there's anything fundamentally wrong with my window.

I have an image of dimensions "width" by "height" (typically 300 x 300) of
which each pixel is an unsigned byte.  Image data is just consecutive
bytes in a calloc'ed block of memory, no padding between lines, etc. so
nothing extraordinary there.  The fragment of code which I am trying to
use to display the image looks like:

    ximage = XCreateImage(server,xvi.visual,8,image_fmt,0,
		      img->ifsptr,width,height,8,0);
    XPutImage(server,w1,gc,ximage,0,0,0,0,width,height);

where:
    image_fmt = ZPixmap;
    img   is a structure unrelated to X; img->ifsptr is an 
	  "unsigned char *" which points to the actual image data.
    gc    is a graphics context, basically your normal defaults
	  (function = GXcopy, etc.), created with XCreateGC.
    xvi   is an XVisualInfo structure filled in via XMatchVisualInfo()...
 
    and everything else should be obvious. 
    The window that I'm attempting to put the image is 512x512, images
    are 300x300 or smaller.


Now, when I run my program everything works fine up to the point of the
XPutImage call (XCreateImage seems to return with no problems).
Usually the program just freezes upon calling XPutImage, with a line or two
of garbage pixels appearing at the very top of my window.  Sometimes with
smaller images I get several lines of garbage.  The width of these lines
look like they probably correspond to the width of the image, i.e., they 
don't extend all the way across window.

So:  is it my calling sequence or X which is out of wack?


		Thanks for any help...
		    Mark

turner@daisy.UUCP (D'arc Angel) (10/09/87)

<problem with XPutImage description deleted to save space >

we are experiencing the same problem with the same results, so it ain't
your code (sigh of relief), if you (or anyone else) comes up with a 
solution please post it or pass it along to us

thanks

-- 
C'est la vie, C'est la guerre, C'est la pomme de terre
...{decwrl|ucbvax}!imagen!atari!daisy!turner (James M. Turner)
Daisy Systems, 700 E. Middlefield Rd, P.O. Box 7006, 
Mountain View CA 94039-7006.                          (415)960-0123