From: MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX" 14-NOV-1992 12:35 14-NOV-1992 12:35:00.00 To: mlevin@husc8.harvard.edu, info-vax@sri.com CC: Subj: Re: How do I throw a pixmap up on a DecWindows screen at once? In article <1992Nov10.202825.17325@husc3.harvard.edu> you write: # I am a complete novice to X-windows programming (although I know #C and unix and VMS systems programming at an intermediate level). I #need to take a 2-dimensional array of colormap indeces, corresponding #to a rectangular patch of the screen with pixels of different colors, #and throw it up as a window on a Ultrix VAX or a VMS Vax with #DecWindows (no MIT X stuff - just regular out-of-the-box DecWindows) #from a C program. Something like this: #display_in_window(array) # #short array[X][Y]; #{ # /* here's the part I'm having trouble with */ #} # #where each element of array[][] will be 0 for black, 1 for white, 2 #for green, etc. # Is there any code anywhere that will show me how to do this? At #least a hint as to which routines I should be looking at (I don't have #a DecWindows manual, but I'll get one if there's no PD code already #around to do this - what's the proper manual called?). If anyone has #any helpful suggestions, please email me at mlevin@husc8.harvard.edu. # Mike, What you need to do is two fold 1) Allocate the colors using the XColor structure like so XColor colors[256]; for (i = 0; i < 256; i++) { colors[i].pixel = i; /* value to reference this color by */ colors[i].red = red; /* RGB value for red */ colors[i].green = green;/* RGB value for green */ colors[i].blue = blue; /* RGB value for blue */ colors[i].flags = DoRed | DoGreen | DoBlue; } XSetColors(dpy, DefaultColormapOfScreen(scr), colors, 256); 2) Create an XImage structure containing the imagedata where the image data is a array[] of pixel values matching those you setup in the colormap; XImage *image; unsigned char image_array[90000]; /* 300x300 image */ /* * Load image (any way you want) */ /* * Create XImage */ image = XCreateImage(dpy, DefaultVisualOfScreen(scr), /* what is the visual */ DefaultDepthOfScreen(scr), /* how deep is the display */ ZPixmap, /* needed for images made up of pixels */ 0, /* offset to start of image */ image_array, 300, 300, /* image is 300x300 */ 8, /* image is in 8 bit units */ 300); /* number of bytes per line */ 3) Put the image to the window you want using XPutImage. XPutImage(dpy, window, /* window to display image in */ gc, /* graphics context */ image, /* XImage to use */ 0, 0, /* start at the start of the Image */ 0, 0, /* place in window starting at (0,0) */ 300, 300); /* image is 300x300 */ This is a simplified example, but should get you started. -- Patrick L. Mahan --- TGV Window Washer ------------------------------- Mahan@TGV.COM --------- Waking a person unnecessarily should not be considered - Lazarus Long a capital crime. For a first offense, that is From the Notebooks of Lazarus Long