[comp.windows.x] Display image in X Window

lee@pandora.cs.wayne.edu (Harrison Y. Lee) (03/23/91)

Hi  XWindow experts:

	I am new to X programming and I need to display an image on screen,
	I have to read from a file which contains a long string of gray
	values.  I declare "char pixel" to hold the value.  I then need
	to read those values from the file one pixel at a time and use
	(I think) XPutPixel to put them in my image.  So far, it just
	gives me bus error (core dumped) error, I use dbx to run the program
	and it terminated at the XPutPixel line, I am wondering if anybody
	can give me some instructions or procedures on the correct
	procedures to define the image, open the window on the screen and
	display those pixels inside the window.

	Thanks alot for any suggestion!!!

	

boyter@bimbo.uucp (Maj Brian Boyter) (03/24/91)

lee@pandora.cs.wayne.edu (Harrison Y. Lee) writes:


>Hi  XWindow experts:

>	I am new to X programming and I need to display an image on screen,
>	I have to read from a file which contains a long string of gray
>	values.  I declare "char pixel" to hold the value.  I then need
>	to read those values from the file one pixel at a time and use
>	(I think) XPutPixel to put them in my image.  So far, it just
>	gives me bus error (core dumped) error, I use dbx to run the program
>	and it terminated at the XPutPixel line, I am wondering if anybody
>	can give me some instructions or procedures on the correct
>	procedures to define the image, open the window on the screen and
>	display those pixels inside the window.

>	Thanks alot for any suggestion!!!

Lee,

Try this:

1) read the data into an array.
2) create the appropriate windows (XCreateWindow)
3) use XCreateImage to get the data into an image on the server
4) use XPutImage to put the image into the window

Reading the data and using XPutPixel could work,
but it would be relatively inefficient...

Brian

-- 
---------------------------------------------------------------
   Maj. Brian A Boyter
   US Army Foreign Science & Technology Center
   Charlottesville, Va 22901                         __
   off: (804)980-7362                              (    )
   home:     973-9440                             {      }
                                                   (    )
   boyter@fstc-chville.army.mil                      ||
                                                     ||
   Just say glow......                       _______<  >_______