Xref: utzoo comp.windows.x:30007 comp.windows.misc:1680 comp.windows.news:2473 Path: utzoo!utgpu!watserv1!watmath!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!wuarchive!uunet!nysnet!ccli From: ccli@nysnet.nysnet (Chia-Chih Li) Newsgroups: comp.windows.x,comp.windows.misc,comp.windows.news Subject: X window Keywords: OpenLook X window Message-ID: <169@nys138.nysnet.nysnet> Date: 28 Nov 90 15:06:31 GMT Followup-To: poster Organization: New York State Office of General Services, Albany, NY. Lines: 131 Hi, I've been tring to display an image which is a tiff file created by scanner on the OpenLook X window. The image displaying will be placed in the expose procedure of stub widget under the parent widget, scrolledwindow widget. I used Xlib functions, XReadBitmapFile and XPutImage, for image displaying inside the expose procedure, but they are not really working. Core dump occurred in the earlier testing and I'm getting errors for XReadBitmapFile now. The brief code for displaying is listed below. If anyone does have the experience of dealing image displaying on OpenLook X window using Xlib functions other than what I'm using now, I'll appreiate if you could drop a line. ******************************************************************************* #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(vaule); /* returns BitmapSuccess if everything worked */ } /* 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], XtNwidht, (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); unsigned int width, height; Pixmap *imagep; display = XtDisplay(w); paint_win = XtWindow(w); 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,widht,height); } main(argc,argv) int argc; char **argv; { Arg args[10]; 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(); } *******************************************************************************