chapman@lll-lcc.UUCP (Carol Chapman) (09/01/89)
I am *still* having trouble doing what is essentially a screen dump to a Tektronix (non-postscript) color printer. I get the window corresponding to an Athena vpaned widget and then create a pixmap of that window. I store the image data for that pixmap into a SUN rasterfile. (Header and colormap information are also in the rasterfile, before the image data.) Then I use system("cat rasterfile | lpr -v -Ptcpr"). My program compiles and runs without complaint, but the printer aborts the job. I used another program called xviewsun to try and look at my rasterfile. There appears to be a problem with the image data in the rasterfile. Below is the short routine that puts the image data into the rasterfile. Does anyone see anything wrong with this? Do I need to call XCreateImage? I didn't think so, but threw it in just in case! Do I need to associate a GC with the pixmap (here called a_drawable)? Thanks in advance, carol chapman /*****************************************************************************/ static unsigned char write_raster_image(fd, width, height, a_drawable, raster_cmap) int fd; unsigned width, height; Drawable a_drawable; unsigned char *raster_cmap; { unsigned bytes_returned = 0; /* number of bytes written by write() */ unsigned num_bytes = 0; /* total size in bytes of outer_vpaned */ unsigned char success = FALSE; /* TRUE if raster file image is written correctly */ XImage *screen_image; /* an image of outer_vpaned */ num_bytes = width * height; /* determine total size of window in bytes */ /* save the contents of the pixmap that is to be printed into an image */ screen_image = XCreateImage(disp, vis, depth, ZPixmap, 0, raster_cmap, width, height, BitmapPad(disp), 0); screen_image = XGetImage(disp, a_drawable, 0, 0, width, height, AllPlanes, ZPixmap); /* write the image data into the raster file after the colormap info */ bytes_returned = write(fd, screen_image->data, num_bytes); if (bytes_returned != num_bytes) xprintf(wp, "Problem writing raster file to printer.\n"); else success = TRUE; /* the raster file image was written correctly */ XDestroyImage(screen_image); /* the image is no longer needed - remove it */ return(success); } /* of write_raster_image */ /*****************************************************************************/ -- ------------------------------------------------------------------------------- Livermore Lab (chapman@lll-crg.llnl.gov or chapman@lll-lcc.llnl.gov) P.O. Box 808, L-153 Tel. (415) 423-7876 Livermore, CA 94550 "Never own anything that you have to FEED or PAINT."