[comp.windows.x] Help on Image package

(Sam) (10/21/90)

Hi,
  I am just started working on X windows. I tried to do some stuff on Images but
got some problems. Can some one please send me examples on Image creation, etc.
I was able to create an image but, irrespective of what I have in data, it
displays a white screen. I tried using XPutPixel and initializing the data 
argument before creating the image both the times I get a white screen. I was 
trying to put gray scale in the image.
	I think the problem is the visual(second) argument I am passing. I dint 
really understand it. The way  I was using XCreateImage was 
	xi=XCreateImage(display,use_dynamic,8,XYPixmap,0,data,256,256,8,0);

I am working on a Sparc 1+ (Sun) and using Open Windows 2.0
Can someone tell me what I am doing wrong.
		Thank you.
				Sam
				Email : sam@ee.fit.edu

mouse@LARRY.MCRCIM.MCGILL.EDU (10/22/90)

> I was able to create an image but, irrespective of what I have in
> data, it displays a white screen.

Are you sure your pixel values are correct?  Where did you get the
pixel values, in particular?

> I was trying to put gray scale in the image.

This leads me to suspect you are simply storing a ramp into the data.
This will not work unless there is also a ramp present in the colormap
to match it.  You need to make sure that the pixel values in the image
map to something useful in the colormap.  (You may be doing this
correctly; without looking at the code I can't tell.)

> I think the problem is the visual(second) argument I am passing.  I
> dint really understand it.

(That's often a recipe for problems :-)

> The way  I was using XCreateImage was

>	xi=XCreateImage(display,use_dynamic,8,XYPixmap,0,data,256,256,8,0);

What is use_dynamic supposed to be (ie, what do you think it is), how
is it declared, and where does it get its value from?  (Since you say
that is probably the problem, how about a little more detail on it?)

Also, are you sure you mean XYPixmap?  You very probably mean ZPixmap
instead.  XYPixmap amounts to saying you have 8 one-bit images present
in consecutive memory, and each pixel's 8-bit value is to be formed by
gathering together the corresponding bits from each.  (Unless I've
misunderstood it, which is possible (and would only emphasize my next
paragraph :-).)  ZPixmap is closer to what you're used to with 8-bit
pixrects: each pixel's bits are all collected together in one place.

Support for client-side images is not very good.  XImages are poorly
documented and difficult to use in any way except a strictly opaque
way, which is grossly inefficient.  Someone should pull the appropriate
code out of the server and make it available as a client library.  If I
find the time I may do that - or something similar - myself....

Also, since you say you're using (so-called) OpenWindows, the default
Visual is probably a StaticColor visual.  The name "use_dynamic"
implies to me that it is supposed to tell it to use a dynamic visual,
probably a PseudoColor one.  In this case, your window needs to have
been created with the same visual, and you also need to create a
colormap for it to use (because if its visual isn't the same as its
parent's visual, the default colormap value of CopyFromParent results
in an invalid colormap; the window's colormap's visual must have the
same type as the window's visual).

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu