[comp.sources.x] v02i077: XReadBitmapFile

mikew@wyse.wyse.com (Mike Wexler) (01/05/89)

Submitted-by: mic@emx.utexas.edu (Mic Kaczmarczik)
Posting-number: Volume 2, Issue 77
Archive-name: newrbf/part02

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 2 (of 2)."
# Contents:  AUTHOR Imakefile patchlevel.h revtable.h x11toras.c
#   xshow.c xshow.icon xshow.man
# Wrapped by mikew@wyse on Wed Jan  4 11:16:21 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'AUTHOR' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'AUTHOR'\"
else
echo shar: Extracting \"'AUTHOR'\" \(1507 characters\)
sed "s/^X//" >'AUTHOR' <<'END_OF_FILE'
X(Message inbox:707)
XReturn-Path: mic@emx.utexas.edu
XReceived:  by wyse.wyse.com (5.58/Wyse master/5-13-88)
X	id AA10630; Wed, 4 Jan 89 00:34:51 PST
XReceived: from emx.utexas.edu by uunet.UU.NET (5.59/1.14) 
X	id AA19548; Wed, 4 Jan 89 01:28:03 EST
XDate: Wed, 4 Jan 89 00:29:13 CST
XFrom: mic@emx.utexas.edu (Mic Kaczmarczik)
XPosted-Date: Wed, 4 Jan 89 00:29:13 CST
XMessage-Id: <8901040629.AA11117@emx.utexas.edu>
XReceived: by emx.utexas.edu (5.54/5.51)
X	id AA11117; Wed, 4 Jan 89 00:29:13 CST
XTo: x-sources%wyse.com@uunet.UU.NET
XSubject: XReadBitmapFile() that reads Suntools icons, Sun rasterfiles
X
XHere are some replacements for XReadBitmapFile() that read Sun format
Ximage files (Suntools icons and Sun rasterfiles) as well X 11 format
Ximages. The code does not require any Sun-specific libraries, however;
XI've been using it daily on a MicroVAX.  There's also a program that
Xuses the routines to show an image on an X display, and one to convert
Xfrom X 11 format images to Sun rasterfiles.
X
XInstalling the routines in our X library has allowed us to use
Xcompressed Sun rasterfiles for big root window background images, with
Xa substantial savings in disk space. It also lets me maintain just one
Xset of icon files and images for both X and Suntools.  I figured this
Xmight be useful to others, so here it is... 
X
XCheers,
X
XMic Kaczmarczik
XUser Services Unix Support Group
XUT Austin Computation Center
X
XInternet:	mic@emx.utexas.edu	UUCP:	...!cs.utexas.edu!ut-emx!mic
XBITNET:		mic@utaivc		THENET:	utaivc::mic
X
END_OF_FILE
if test 1507 -ne `wc -c <'AUTHOR'`; then
    echo shar: \"'AUTHOR'\" unpacked with wrong size!
fi
# end of 'AUTHOR'
fi
if test -f 'Imakefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Imakefile'\"
else
echo shar: Extracting \"'Imakefile'\" \(455 characters\)
sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
X#
X# Imakefile for xshow and x11toras, using enhanced XReadBitmapFile()
X#
X
X#ifdef BandAidCompiler
X#include BandAidCompiler
X#endif
X
X          SRCS1 = xshow.c xshow.icon xshow.cursor
X          OBJS1 = xshow.o XRdBitF.o
X          SRCS2 = x11toras.c
X          OBJS2 = x11toras.o
X       PROGRAMS = xshow x11toras
XLOCAL_LIBRARIES = $(XLIB)
X        DEFINES = -I/src/x/x11.3/lib/X
X
XComplexProgramTarget_1(xshow,$(XLIB),)
X
XSingleProgramTarget(x11toras,$(OBJS2),,)
X
END_OF_FILE
if test 455 -ne `wc -c <'Imakefile'`; then
    echo shar: \"'Imakefile'\" unpacked with wrong size!
fi
# end of 'Imakefile'
fi
if test -f 'patchlevel.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'patchlevel.h'\"
else
echo shar: Extracting \"'patchlevel.h'\" \(22 characters\)
sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
X#define PATCHLEVEL 0
X
END_OF_FILE
if test 22 -ne `wc -c <'patchlevel.h'`; then
    echo shar: \"'patchlevel.h'\" unpacked with wrong size!
fi
# end of 'patchlevel.h'
fi
if test -f 'revtable.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'revtable.h'\"
else
echo shar: Extracting \"'revtable.h'\" \(3379 characters\)
sed "s/^X//" >'revtable.h' <<'END_OF_FILE'
X/*
X * revtable.h
X * revtable[i] is the reverse 8-bit image of i
X * c_revtable[i] is the 1's complement of revtable[i]
X */
Xchar revtable[256] = { 
X	    0, -128,   64,  -64,   32,  -96,   96,  -32,
X	   16, -112,   80,  -48,   48,  -80,  112,  -16,
X	    8, -120,   72,  -56,   40,  -88,  104,  -24,
X	   24, -104,   88,  -40,   56,  -72,  120,   -8,
X	    4, -124,   68,  -60,   36,  -92,  100,  -28,
X	   20, -108,   84,  -44,   52,  -76,  116,  -12,
X	   12, -116,   76,  -52,   44,  -84,  108,  -20,
X	   28, -100,   92,  -36,   60,  -68,  124,   -4,
X	    2, -126,   66,  -62,   34,  -94,   98,  -30,
X	   18, -110,   82,  -46,   50,  -78,  114,  -14,
X	   10, -118,   74,  -54,   42,  -86,  106,  -22,
X	   26, -102,   90,  -38,   58,  -70,  122,   -6,
X	    6, -122,   70,  -58,   38,  -90,  102,  -26,
X	   22, -106,   86,  -42,   54,  -74,  118,  -10,
X	   14, -114,   78,  -50,   46,  -82,  110,  -18,
X	   30,  -98,   94,  -34,   62,  -66,  126,   -2,
X	    1, -127,   65,  -63,   33,  -95,   97,  -31,
X	   17, -111,   81,  -47,   49,  -79,  113,  -15,
X	    9, -119,   73,  -55,   41,  -87,  105,  -23,
X	   25, -103,   89,  -39,   57,  -71,  121,   -7,
X	    5, -123,   69,  -59,   37,  -91,  101,  -27,
X	   21, -107,   85,  -43,   53,  -75,  117,  -11,
X	   13, -115,   77,  -51,   45,  -83,  109,  -19,
X	   29,  -99,   93,  -35,   61,  -67,  125,   -3,
X	    3, -125,   67,  -61,   35,  -93,   99,  -29,
X	   19, -109,   83,  -45,   51,  -77,  115,  -13,
X	   11, -117,   75,  -53,   43,  -85,  107,  -21,
X	   27, -101,   91,  -37,   59,  -69,  123,   -5,
X	    7, -121,   71,  -57,   39,  -89,  103,  -25,
X	   23, -105,   87,  -41,   55,  -73,  119,   -9,
X	   15, -113,   79,  -49,   47,  -81,  111,  -17,
X	   31,  -97,   95,  -33,   63,  -65,  127,   -1,
X};
X
Xchar c_revtable[256] = { 
X	   -1,  127,  -65,   63,  -33,   95,  -97,   31,
X	  -17,  111,  -81,   47,  -49,   79, -113,   15,
X	   -9,  119,  -73,   55,  -41,   87, -105,   23,
X	  -25,  103,  -89,   39,  -57,   71, -121,    7,
X	   -5,  123,  -69,   59,  -37,   91, -101,   27,
X	  -21,  107,  -85,   43,  -53,   75, -117,   11,
X	  -13,  115,  -77,   51,  -45,   83, -109,   19,
X	  -29,   99,  -93,   35,  -61,   67, -125,    3,
X	   -3,  125,  -67,   61,  -35,   93,  -99,   29,
X	  -19,  109,  -83,   45,  -51,   77, -115,   13,
X	  -11,  117,  -75,   53,  -43,   85, -107,   21,
X	  -27,  101,  -91,   37,  -59,   69, -123,    5,
X	   -7,  121,  -71,   57,  -39,   89, -103,   25,
X	  -23,  105,  -87,   41,  -55,   73, -119,    9,
X	  -15,  113,  -79,   49,  -47,   81, -111,   17,
X	  -31,   97,  -95,   33,  -63,   65, -127,    1,
X	   -2,  126,  -66,   62,  -34,   94,  -98,   30,
X	  -18,  110,  -82,   46,  -50,   78, -114,   14,
X	  -10,  118,  -74,   54,  -42,   86, -106,   22,
X	  -26,  102,  -90,   38,  -58,   70, -122,    6,
X	   -6,  122,  -70,   58,  -38,   90, -102,   26,
X	  -22,  106,  -86,   42,  -54,   74, -118,   10,
X	  -14,  114,  -78,   50,  -46,   82, -110,   18,
X	  -30,   98,  -94,   34,  -62,   66, -126,    2,
X	   -4,  124,  -68,   60,  -36,   92, -100,   28,
X	  -20,  108,  -84,   44,  -52,   76, -116,   12,
X	  -12,  116,  -76,   52,  -44,   84, -108,   20,
X	  -28,  100,  -92,   36,  -60,   68, -124,    4,
X	   -8,  120,  -72,   56,  -40,   88, -104,   24,
X	  -24,  104,  -88,   40,  -56,   72, -120,    8,
X	  -16,  112,  -80,   48,  -48,   80, -112,   16,
X	  -32,   96,  -96,   32,  -64,   64, -128,    0,
X};
END_OF_FILE
if test 3379 -ne `wc -c <'revtable.h'`; then
    echo shar: \"'revtable.h'\" unpacked with wrong size!
fi
# end of 'revtable.h'
fi
if test -f 'x11toras.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'x11toras.c'\"
else
echo shar: Extracting \"'x11toras.c'\" \(3452 characters\)
sed "s/^X//" >'x11toras.c' <<'END_OF_FILE'
X/*
X * x11toras -- quick-and-dirty program to convert X 11 bitmap files into
X * uncompressed Sun rasterfiles.
X *
X * Usage:
X *	x11toras [X11-bitmap-file] >rasterfile
X *
X * Reads standard input, write standard output, and that's about it.
X * Should run on most 32-bit Berkeley systems (uses htonl() to figure
X * out byte order for the rasterfile header).
X *
X * Mic Kaczmarczik
X * User Services Unix Support Group
X * UT Austin Computation Center
X * mic@emx.utexas.edu
X */
X
X
X#include <sys/types.h>
X#include <netinet/in.h>
X#include <stdio.h>
X#include "revtable.h"
X
X#define	RASTERFILE_MAGIC	0x59a66a95
X#define STANDARD		1
X
Xstruct rasterfile_header {
X	int	magic;
X	int	width;
X	int	height;
X	int	depth;
X	int	length;
X	int	type;
X	int	maptype;
X	int	maplength;
X};
X
Xmain(argc,argv)
Xint argc;
Xchar *argv[];
X{
X	FILE	*bmfile, *fopen();
X
X	int width = -1, height = -1, value;
X	int nrow, ncol;
X	int rowbytes, pad;
X	int nbytes, bitmap_size, c;
X	unsigned char *bitmap;
X	char *malloc();
X	char buf[81];
X	struct rasterfile_header ras;
X
X	/*
X	 * argument checking
X	 */
X	if (argc == 1)
X		bmfile = stdin;
X	else if (argc == 2) {
X		if ((bmfile = fopen(argv[1], "r")) == NULL) {
X			fprintf(stderr,"%s: can't open %s for reading\n",
X				argv[0], argv[1]);
X			exit(1);
X		}
X	} else {
X		fprintf(stderr,"usage: %s [X11-bitmap-file]\n", argv[0]);
X		exit(1);
X	} 
X
X	/*
X	 * a small amount of fire wall code
X	 */
X
X	while ((fscanf(bmfile, "#define %80s %d\n",buf,&value)) == 2) {
X		if (atend("width",buf))
X			width = value;
X		else if (atend("height",buf))
X			height = value;
X	}
X
X	if (width == -1 || height == -1) {
X		fprintf(stderr,"%s: error parsing bitmap size\n", argv[0]);
X		exit(1);
X	}
X
X	if (fscanf(bmfile, "static char %80s = {\n",buf) != 1) {
X		fprintf(stderr,"%s: error parsing bitmap file declaration\n",
X			argv[0]);
X		exit(1);
X	}
X
X	if (!atend("bits[]",buf)) {
X		fprintf(stderr,"%s: error parsing bitmap file bits\n", argv[0]);
X		exit(1);
X	}
X
X	/*
X	 * Parse the rest of the bitmap file in a pretty inefficient manner.
X	 * Reverse bits while we're at it.
X	 */
X
X	rowbytes = (width + 7) / 8;	/* # of bytes per line in image */
X	pad = rowbytes % 2;		/* pad each line to 16 bits */
X	bitmap_size = (rowbytes + pad) * height;
X	if ((bitmap = ((unsigned char *) malloc(bitmap_size))) == NULL) {
X		fprintf(stderr,"%s: can't get %d bytes for bitmap\n",
X			argv[0], bitmap_size);
X		exit(1);
X	}
X
X	for (nbytes = 0, nrow = 0; nrow < height ; nrow++) {
X		for (ncol = 0 ; ncol < rowbytes ; ncol++) {
X			if (fscanf(bmfile, " 0x%2x",&c) != 1) {
X				fprintf(stderr,
X				"%s: error parsing bitmap file at byte %d\n",
X					argv[0], nbytes);
X				exit(1);
X			}
X			bitmap[nbytes++] = revtable[c];
X			fscanf(bmfile, ",");	/* ok to fail here */
X		}
X		if (pad)
X			bitmap[nbytes++] = revtable[0];
X	}
X
X	/*
X 	 * Fill in the header for an uncompressed Sun raster file.
X	 * Take advantage of the fact that the byte order in rasterfiles
X	 * is also network byte order, so we let htonl() decide what to do
X	 */
X	ras.magic = htonl(RASTERFILE_MAGIC);
X	ras.width = htonl(width);
X	ras.height = htonl(height);
X	ras.depth = htonl(1);
X	ras.length = htonl(nbytes);
X	ras.type = htonl(STANDARD);
X	ras.maptype = htonl(0);
X	ras.maplength = htonl(0);
X
X
X	/*
X	 * Write out the header and the uncompressed bitmap data.
X	 */
X	fwrite(&ras, sizeof(ras), 1, stdout);
X	fwrite(bitmap, nbytes, 1, stdout);
X}
X
X/*
X * Returns true if s is the final substring of t
X */
X
Xatend(s,t)
Xchar *s,*t;
X{
X	return (0 == strcmp(&t[strlen(t) - strlen(s)],s));
X}
X
END_OF_FILE
if test 3452 -ne `wc -c <'x11toras.c'`; then
    echo shar: \"'x11toras.c'\" unpacked with wrong size!
fi
# end of 'x11toras.c'
fi
if test -f 'xshow.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xshow.c'\"
else
echo shar: Extracting \"'xshow.c'\" \(8113 characters\)
sed "s/^X//" >'xshow.c' <<'END_OF_FILE'
X/*
X *                             XSHOW 1.0
X *
X *		      An X Bitmap Image Viewer for X 11
X *
X *		Converted from XMAC, a MacPaint image viewer, by
X *
X *			     Mic Kaczmarczik
X *
X *			Original copyright notice:
X *
X *				XMAC V1.2
X *
X *		      A MacPaint Image Viewer For X.11
X *
X *                Copyright 1987 by Patrick J. Naughton
X *
X *                         All Rights Reserved
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation.
X *
X * Comments and additions (or any MacPaint files) may be sent the author at:
X *
X * naughton@sun.soe.clarkson.edu
X *
X * or by Snail Mail:
X * Patrick J. Naughton
X * 23 Pleasant Street, #3
X * Potsdam, NY  13676
X *         or
X * (315) 265-2853 (voice)
X *
X * Thanks to the following bug-fixers/enhancers:
X *   Jim Fulton     (jim@dandelion.ci.com)
X *   Jon Greenblatt (jonnyg@rover.umd.edu)
X *   Terry Weissman (weissman@decwrl.dec.com)
X *
X * Revision History:
X * (xshow)
X * 27-Mar-88: Use X bitmap files instead of MacPaint images, reverse
X *	      engineer the Gumby cursor
X * (xmac)
X * 5-Dec-87: Added apple mouse cursor.
X * 4-Dec-87: Added Jim Fulton's fixes.
X *           Key trapping and better error messages.
X * 3-Dec-87: Added Jon Greenblatt and Terry Weissman's fixes.
X *           fixed "scanLine <= MAX_SCAN_LINE" and "PS-Adobe 1.0"
X * 1-Dec-87: Initial Release.
X *
X */
X
X#include <stdio.h>
X#include <X11/Xlib.h>
X#include <X11/Xatom.h>
X#include <X11/Xutil.h>
X#include <X11/cursorfont.h>
X#include "xshow.icon"
X#include "xshow.cursor"
X
X#define	XBITMAPPATH	"XBITMAPS"
X#define	BORDER_WIDTH	3
X#define	MAX_NAME	64
X
X#define	TRUE		1
X#define	FALSE		0
Xtypedef	int	boolean;
X
Xstatic Pixmap theBitmap, thePixmap;
Xstatic int theBitmap_x, theBitmap_y;
X
Xchar		*ProgramName;
XDisplay		*displayPtr = NULL;	/* important that this be inited */
XGContext	gc;
XWindow		theWindow;
Xint		screen, geomStat;
XXSizeHints	size_hints;
X
Xchar		name[MAX_NAME];	
X
Xvoid	processEvents()
X{
XXEvent	pe;
X#define BUFFERSIZE 10
Xchar	buffer[BUFFERSIZE];
X
X    while(1) {
X        XNextEvent(displayPtr, &pe);
X	switch(pe.type) {
X	    case Expose:
X		break;
X	    case NoExpose:
X	    case MapNotify:
X	    case UnmapNotify:
X		continue;
X	    case KeyPress:
X		if (XLookupString(&pe, buffer, BUFFERSIZE, NULL, NULL) == 1) {
X		    switch (buffer[0]) {
X			case 'q':
X			case 'Q':
X			case ' ':
X			case '\033':		/* ESC */
X			case '\003':		/* ^C */
X			case '\004':		/* ^D */
X			return;
X		    }
X		}
X		continue;
X	    default:
X		fprintf(stderr, "%s:  unknown event type: %d\n",
X			ProgramName, pe.type);
X		break; /* shouldn't ever happen... */
X	}
X
X	XCopyArea(displayPtr, thePixmap, theWindow, gc,
X		  0, 0, theBitmap_x, theBitmap_y, 0, 0);
X		   
X
X	/* flush event queue of all exposure events... */
X	while (XCheckTypedEvent(displayPtr, Expose, &pe));
X
X    }
X}
X
X
Xstatic init(argc, argv)
Xint	argc;
Xchar	*argv[];
X{
Xint			i;
XXGCValues		xgcv;
XXSetWindowAttributes	xswa;
XWindow			root;
XVisual			visual;
XPixmap			bitmapPixmap, bitmapMask;
XCursor			bitmapCursor;
XXColor			FGcolor, BGcolor;
Xchar			*geom = NULL;
Xchar			*displayName = NULL;
Xchar			*fname, *thePath;
Xchar			fullPath[1024];
Xint			failure;
X
Xextern	char		*getenv();
X
X    for (i = 1; i < argc; i++) {
X	if (0 == strcmp("-geometry",argv[i]))
X		geom = argv[++i];
X	else if (0 == strcmp("-display",argv[i]))
X		displayName = argv[++i];
X	else fname = argv[i];
X    }
X
X    if (!fname) {
X	printf("usage: xshow [-geometry geometry] [-display host:display] fname\n");
X	printf("-geometry is the standard X client geometry specification\n");
X	printf("-display is the standard X client display specification\n");
X	printf("\nIf you keep your X 11 bitmaps in /usr/local/lib/images");
X	printf(" then do this:\n\t%% setenv XBITMAPS /usr/local/lib/images\n");
X	printf("Xshow will look in the current dir first, then in $XBITMAPS.\n");
X	exit(-1);
X    }
X
X    strncpy(name, fname, sizeof(name));
X    if ((thePath = getenv(XBITMAPPATH)) != NULL) {
X	strcpy (fullPath, thePath);
X	strcat (fullPath, "/");
X	strcat (fullPath, fname);
X    } else {
X	fullPath[0] = '\0';
X    }
X
X
X    if (!(displayPtr = XOpenDisplay(displayName))) {
X	fprintf (stderr, "%s:  unable to open display \"%s\".\n",
X		 ProgramName, XDisplayName (displayName));
X	exit(1);
X    }
X
X    screen = DefaultScreen(displayPtr);
X    failure = XReadBitmapFile(displayPtr, RootWindow(displayPtr, screen),
X			      fname, &theBitmap_x, &theBitmap_y, &theBitmap,
X			      (int *)NULL, (int *)NULL);
X
X    if (failure != BitmapSuccess) { /* try $XBITMAPS/filename */
X	    failure = XReadBitmapFile(displayPtr,
X				      RootWindow(displayPtr, screen), fullPath,
X				      &theBitmap_x, &theBitmap_y, &theBitmap,
X				      (int *)NULL, (int *)NULL);
X	    if (failure != BitmapSuccess) {
X		    fprintf(stderr, "%s: unable to read bitmap file %s\n",
X			    ProgramName, fname);
X		    exit (1);
X	    }
X    }
X     
X    size_hints.x = 0;
X    size_hints.y = 0;
X    size_hints.width = theBitmap_x;
X    size_hints.height = theBitmap_y;
X    size_hints.min_width = size_hints.max_width = theBitmap_x;
X    size_hints.min_height = size_hints.max_width = theBitmap_y;
X
X    size_hints.flags = 0;
X    if (!geom) {
X	size_hints.flags |= PSize;
X    } else {
X	geomStat = XParseGeometry(geom, &(size_hints.x),  
X                                        &(size_hints.y),
X                                        &(size_hints.width),
X                                        &(size_hints.height));
X	if (geomStat & (XValue | YValue)) {
X	    size_hints.flags |= USPosition;
X	}
X	if (geomStat & (WidthValue | HeightValue)) {
X	    if (size_hints.width < theBitmap_x)
X	    	size_hints.width = theBitmap_x;
X	    if (size_hints.height < theBitmap_y)
X	    	size_hints.height = theBitmap_y;
X	    size_hints.flags |= USSize;
X	}    
X    }
X
X   /* make the cursor */
X
X    FGcolor.red = 0;        FGcolor.green = 0;      FGcolor.blue = 0;
X    BGcolor.red = 0xffff;   BGcolor.green = 0xffff; BGcolor.blue = 0xffff;
X
X    bitmapPixmap = XCreateBitmapFromData(displayPtr,
X				RootWindow(displayPtr,screen),
X				bitmap_bits, bitmap_width, bitmap_height);
X    bitmapMask = XCreateBitmapFromData(displayPtr,
X				RootWindow(displayPtr,screen),
X				bitmap_mask_bits, bitmap_width, bitmap_height);
X
X    xswa.event_mask = ExposureMask | KeyPressMask;
X    xswa.backing_store = Always;
X    xswa.border_pixel = BlackPixel(displayPtr, screen);
X    xswa.background_pixel = WhitePixel(displayPtr, screen);
X    xswa.cursor = XCreatePixmapCursor(displayPtr,bitmapPixmap,bitmapMask,
X				&FGcolor, &BGcolor, bitmap_x_hot, bitmap_y_hot);
X
X    theWindow = XCreateWindow(displayPtr,
X		RootWindow(displayPtr, screen),
X		size_hints.x,
X		size_hints.y,
X		size_hints.width,
X		size_hints.height,
X		BORDER_WIDTH,
X		CopyFromParent, InputOutput, CopyFromParent, 
X	        CWEventMask | CWBackingStore | CWBorderPixel |
X		CWBackPixel | CWCursor, 
X		&xswa);
X
X    XSetStandardProperties(displayPtr, theWindow, name, "xshow 1.0",
X                    XCreateBitmapFromData(displayPtr,
X				RootWindow(displayPtr, screen),
X				Xbitmap_bits, Xbitmap_width, Xbitmap_height),
X                            argv, argc, &size_hints);
X
X    XMapWindow(displayPtr, theWindow);
X
X    xgcv.foreground = BlackPixel(displayPtr, screen);
X    xgcv.background = WhitePixel(displayPtr, screen); 
X    gc = (GContext) XCreateGC(displayPtr, theWindow,
X	GCForeground | GCBackground, &xgcv);
X
X    /*
X     * Extend the pixmap to have as many planes as the window
X     */
X    thePixmap = XCreatePixmap(displayPtr, RootWindow(displayPtr, screen),
X    		theBitmap_x, theBitmap_y,
X		(unsigned int)DefaultDepth(displayPtr, screen));
X
X    XCopyPlane(displayPtr, theBitmap, thePixmap, gc, 0, 0,
X		theBitmap_x, theBitmap_y, 0, 0, (unsigned long) 1);
X}
X
X
Xstatic finish ()
X{
X    if (displayPtr) {
X	XCloseDisplay (displayPtr);
X	displayPtr = NULL;
X    }
X    return;
X}
X
X
Xmain(argc, argv)
Xint	argc;
Xchar	*argv[];
X{
X    ProgramName = argv[0];
X    init(argc, argv);
X    processEvents();
X    finish();
X    exit(0);
X}
END_OF_FILE
if test 8113 -ne `wc -c <'xshow.c'`; then
    echo shar: \"'xshow.c'\" unpacked with wrong size!
fi
# end of 'xshow.c'
fi
if test -f 'xshow.icon' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xshow.icon'\"
else
echo shar: Extracting \"'xshow.icon'\" \(884 characters\)
sed "s/^X//" >'xshow.icon' <<'END_OF_FILE'
X#define Xbitmap_width 32
X#define Xbitmap_height 32
Xstatic char Xbitmap_bits[] = {
X   0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0x0f, 0x08, 0x00, 0x00, 0x08,
X   0xe8, 0xff, 0xff, 0x0b, 0x28, 0x1c, 0x10, 0x0a, 0x28, 0x38, 0x08, 0x0a,
X   0x28, 0x38, 0x04, 0x0a, 0x28, 0x70, 0x04, 0x0a, 0x28, 0xe0, 0x02, 0x0a,
X   0x28, 0xe0, 0x01, 0x0a, 0x28, 0xc0, 0x01, 0x0a, 0x28, 0xc0, 0x03, 0x0a,
X   0x28, 0xe0, 0x03, 0x0a, 0x28, 0x20, 0x07, 0x0a, 0x28, 0x10, 0x0e, 0x0a,
X   0x28, 0x08, 0x0e, 0x0a, 0x28, 0x04, 0x1c, 0x0a, 0xe8, 0xff, 0xff, 0x0b,
X   0x08, 0x00, 0x00, 0x08, 0xf8, 0xff, 0xff, 0x0f, 0x04, 0x00, 0x00, 0x10,
X   0xfe, 0xff, 0xff, 0x7f, 0x02, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x00, 0xa0,
X   0xfe, 0xff, 0xff, 0xbf, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xe0, 0x3f,
X   0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x78, 0x00,
X   0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00};
END_OF_FILE
if test 884 -ne `wc -c <'xshow.icon'`; then
    echo shar: \"'xshow.icon'\" unpacked with wrong size!
fi
# end of 'xshow.icon'
fi
if test -f 'xshow.man' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xshow.man'\"
else
echo shar: Extracting \"'xshow.man'\" \(1893 characters\)
sed "s/^X//" >'xshow.man' <<'END_OF_FILE'
X.TH XSHOW 6 "17 Jun 1988" "X Version 11"
X.SH NAME
Xxshow \- display X bitmap files under X 11
X
X.SH SYNOPSIS
X.B xshow
Xfilename [-display \fIhost\fP:\fIdisplaynum\fP] [-geometry \fIgeometry\fP]
X
X.SH DESCRIPTION
X.I xshow
Xdisplays an X bitmap file in a window, allows resize/move, and has an icon.
X.I xshow
Xaccepts two other optional command line arguments.  You may specify a
Xdisplay name in the form \fIhost\fP:\fIdisplay\fP (see \fIX(1)\fP).
XAnd you may provide
Xa geometry specification.  If you don't give a geometry specification, 
X.I xshow
Xwill ask you where you want to put the window when it starts up.  See
X.I X(1)
Xfor a full explanation.  To exit
X.I xshow ,
Xpress 'q', 'Q', SPACE, ESC, ^D, or ^C while the mouse is in the
X.I xshow
Xwindow.
X
X.SH BUGS
XThere are no known bugs.  There are lots of lacking features.
XEnhancement possibilities include: a title bar, editing, bitmap file
Xgeneration, cut/paste,  as well as replacing the desktop pattern with
Xan image.
X
XFrom the standpoint of a Unix user, it is somewhat disappointing
Xthat xshow (really the Xlib routine XReadBitmapFile) cannot read an
Ximage from standard input, but that is the way the routine is
Ximplemented in the MIT distribution of the X library.
X
X.SH ENVIRONMENT
XXBITMAPS - the default directory for searching for image files, (after ".").
X
X.SH SEE ALSO
XX(1), Xlib Documentation.
X
X.SH AUTHOR
XXMAC, on which this program is based, is Copyright (c) 1987 by
XPatrick J. Naughton, (naughton@sun.soe.clarkson.edu).
X
XXMAC was hacked into XSHOW by Mic Kaczmarczik (mic@emx.utexas.edu).
XThe original copyright notice for XMAC is below:
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted,
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in
Xsupporting documentation.
END_OF_FILE
if test 1893 -ne `wc -c <'xshow.man'`; then
    echo shar: \"'xshow.man'\" unpacked with wrong size!
fi
# end of 'xshow.man'
fi
echo shar: End of archive 2 \(of 2\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked both archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Mike Wexler(wyse!mikew)    Phone: (408)433-1000 x1330
Moderator of comp.sources.x