[comp.windows.x] XReadBitmapFile

mic@ut-emx.UUCP (Mic (... K[a-z]+) Kaczmarczik) (01/04/89)

I have placed a shell archive with an extended version of
XReadBitmapFile() that can read Sun icon and raster image files (as
well as X 11 bitmap files) on expo, in contrib/xshow.shar.Z.  I've
also submitted the shell archive to comp.sources.x.

While Suns are the natural target, the code doesn't require any
Sun-specific libraries, and has been tested and used on a variety of
systems here.  Being able to maintain a single icon library for both
Suntools and X has proven to be very convenient. 

Included in the archive is a converted version of Patrick Naughton's
``xmac'' (that's where ``xshow'' comes from) that can be used to
display bitmap image files.  (I hated using xsetroot to look at
images. :-) There's also a program to convert X 11 bitmap format files
to Sun rasterfiles, which typically saves a *lot* of space. 

Happy viewing,

Mic Kaczmarczik

-- 
Mic Kaczmarczik			If you drink, don't drill.
UT Austin Computation Center			-- Matt Groening
mic@emx.utexas.edu	
MIC@UTAIVC.BITNET

rusty@GARNET.BERKELEY.EDU (08/02/89)

Is there any way to make XReadBitmapFile read standard input?  There
doesn't seem to be.  Is this an unreasonable request?

The reason I ask is that I'd like to be able to pipe the output of
zcat/compress -c to xsetroot, as in

zcat some_poskbitmap.xbm.Z | xsetroot -bitmap -

jim@EXPO.LCS.MIT.EDU (Jim Fulton) (08/02/89)

	Is there any way to make XReadBitmapFile read standard input?

It's fairly simple to hack lib/Xmu/RdBitF.c to have a routine like the
following and then make XmuReadBitmapDataFromFile call it:

    int XmuReadBitmapData (fstream, width, height, datap, x_hot, y_hot)
        FILE *fstream;                      /* handle on file  */
        unsigned int *width, *height;       /* RETURNED */
        unsigned char **datap;              /* RETURNED */
        int *x_hot, *y_hot;                 /* RETURNED */

jef@HELIOS.EE.LBL.GOV (Jef Poskanzer) (08/03/89)

In the referenced message, jim@EXPO.LCS.MIT.EDU (Jim Fulton) wrote:
}It's fairly simple to hack lib/Xmu/RdBitF.c to have a routine like the
}following and then make XmuReadBitmapDataFromFile call it:
}    int XmuReadBitmapData (fstream, width, height, datap, x_hot, y_hot)

What's wrong with the following (with the analogous change made to
lib/X/XRdBitF.c):

*** /tmp/,RCSt1a08334	Wed Aug  2 11:55:29 1989
--- RdBitF.c	Wed Aug  2 11:54:32 1989
***************
*** 135,146 ****
      /* first time initialization */
      if (initialized == False) initHexTable();
  
!     if ((fstream = fopen(filename, "r")) == NULL) {
! 	return BitmapOpenFailed;
!     }
  
      /* error cleanup and return macro	*/
! #define	RETURN(code) { if (data) free (data); fclose (fstream); return code; }
  
      while (fgets(line, MAX_SIZE, fstream)) {
  	if (strlen(line) == MAX_SIZE-1) {
--- 135,148 ----
      /* first time initialization */
      if (initialized == False) initHexTable();
  
!     if (!strcmp("-", filename))
! 	fstream = stdin;
!     else
! 	if ((fstream = fopen(filename, "r")) == NULL)
! 	    return BitmapOpenFailed;
  
      /* error cleanup and return macro	*/
! #define	RETURN(code) { if (data) free (data); if (fstream != stdin) fclose (fstream); return code; }
  
      while (fgets(line, MAX_SIZE, fstream)) {
  	if (strlen(line) == MAX_SIZE-1) {

jim@EXPO.LCS.MIT.EDU (Jim Fulton) (08/03/89)

> What's wrong with the following (with the analogous change made to
> lib/X/XRdBitF.c):
>
> [treat file named - as stdin]

Two things, which depend upon one's particular style:

    o  some folks don't like overloading "-" like that at that level of
       abstraction.

    o  it doesn't let you specify the stream to use.


But the main reason is that I had already written the other code.  :-)


							Jim