Xref: utzoo comp.windows.x:29939 comp.windows.misc:1676 comp.windows.news:2469 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!apple!julius.cs.uiuc.edu!rpi!sarah!cs.albany.edu!ccl From: ccl@cs.albany.edu (Chia-Chih Li) Newsgroups: comp.windows.x,comp.windows.misc,comp.windows.news Subject: X window Keywords: OpenLook X window Message-ID: <499@lovelace.albany.edu> Date: 28 Nov 90 19:28:47 GMT Followup-To: poster Organization: SUNY Albany, Comp Sci Dept, Albany, NY Lines: 118 Hi World, I've been trying to display an image which is a tiff file created by scanner on an OpenLook X window. The displaying will be taken place in the expose procedure of stub widget under the parent widget, scrolledwindow widget. I used two Xlib routines, XReadBitmapFile and XPutImage, for the displaying inside the expose procedure. Core dump occurred in the earlier testing and now I'm getting errors for XReadBitmapFile. I'm not really sured the two Xlib routines that I used is appropreiated for image displaying. If anyone does have the experiences of dealing image displaying on OpenLook X window using different Xlib routines or some methods other than what I'm doing here, I'll appreiate if you could drop a line. I have a brief code of what I did of image displaying listed below. ******************************************************************************* #define LONG 4 Display *display; Screen *screen; char *filename = "/usr/accts/ccli/ski.tif"; /* creating the Pixmap image using XReadBitmapFile to fill in the pixmap */ create_read_imagepix(imagep, filename, width, height) Pixmap *imagep; /* returned created imagep */ char *filename; unsigned int *width, *height; { int depth=1; int value; int x_hot, y_hot; value = XReadBitmapFile(display, RootWindow(display, screen), filename, width, height, imagep, &x_hot, &y_hot); return(value); } /* CreateDrawableCanvas */ Widget CreateDrawableCanvas(name, parent, width, height) char *name; Widget parent; int width, height; { Widget canvas; Arg arg[4]; int n = 0; XtSetArg(arg[n], XtNwidth, (Dimension) width); n++; XtSetArg(arg[n], XtNheight, (Dimension) height); n++; canvas = XtCreateManagedWidget(name, stubWidgetClass, parent, arg, n); return(canvas); } /* exposeHandler */ void exposeHandler(w, xevent, region) Widget w; XEvent *xevent; Region region; { GC gc; XGCValues gc_values; Window paint_win; XImage *image; unsigned int width, height; Pixmap *imagep; display = XtDisplay(w); paint_win = XtWindow(w); image->width=LONG; image->height=LONG; image->xoffset=512; image->format=XYPixmap; image->data=imagep; image->byte_order=LSBFirst; image->bitmap_unit=8; image->bitmap_bit_order=LSBFirst; image->bitmap_pad=8; image->depth=1; image->bytes_per_line=512; image->bits_per_pixel=8; XPutImage(display,paint_win,gc,image,0,0,0,0,width,height); } main(argc, argv) int argc; char **argv; { Widget canvas; Pixmap imagepix; unsigned int imagep_width, imagep_height; if(create_read_imagepix(&imagepix, filename, &imagep_width, &imagep_height) != BitmapSuccess) fprintf(stderr,"Can't read bitmap\n); /* Stub widget: this will be used as a drawing board */ canvas = CreateDrawableCanvas("canvas", scrolledwindow, 350, 500); i = 0; XtSetArg(args[i], XtNexpose, (XtArgVal) exposeHandler); i++; XtSetArg(canvas, args, i); XtRealizeWidget(toplevel); XtMainLoop(); } ******************************************************************************* Jason Li Strategic System Lab State of New York 11/28/90