summaryrefslogtreecommitdiff
path: root/graphics/bit2spr
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /graphics/bit2spr
Initial commit
Diffstat (limited to 'graphics/bit2spr')
-rw-r--r--graphics/bit2spr/Makefile14
-rw-r--r--graphics/bit2spr/README21
-rw-r--r--graphics/bit2spr/bit2spr.161
-rw-r--r--graphics/bit2spr/bit2spr.c165
l---------graphics/bit2spr/sprite.sty1
5 files changed, 262 insertions, 0 deletions
diff --git a/graphics/bit2spr/Makefile b/graphics/bit2spr/Makefile
new file mode 100644
index 0000000000..5b4dbcb6b6
--- /dev/null
+++ b/graphics/bit2spr/Makefile
@@ -0,0 +1,14 @@
+#
+# Makefile for bit2spr.c
+# Created by Marc David Rovner (mrovner@ic.sunysb.edu)
+# June 7th, 1992
+#
+
+CC = cc
+CFLAGS = -g
+
+bit2spr: bit2spr.c
+ ${CC} ${CFLAGS} bit2spr.c -o bit2spr
+
+clean:
+ rm -rf bit2spr
diff --git a/graphics/bit2spr/README b/graphics/bit2spr/README
new file mode 100644
index 0000000000..424a2a55ad
--- /dev/null
+++ b/graphics/bit2spr/README
@@ -0,0 +1,21 @@
+This distribution should contain:
+ Makefile
+ README
+ bit2spr.c
+ bit2spr.1
+ sprite.sty
+ test.xbm
+
+Bit2spr converts standard X11 bitmap files to be used by LaTeX in conjunction
+with the sprite style file created by Martin Costabel. Look in it for
+details on using sprites in LaTeX.
+
+The file bit2spr.1 is a standard nroff manual page. Put it in your man
+directory, or just view the file with "nroff -man bit2spr.1"
+
+If you have any problems with it, feel free to contact the author of this
+program, Marc David Rovner (mrovner@ic.sunysb.edu). There's nothing strange
+in it, so it should compile anywhere, but I've only been able to test it on
+HP 300/400 series machines.
+
+Enjoy!
diff --git a/graphics/bit2spr/bit2spr.1 b/graphics/bit2spr/bit2spr.1
new file mode 100644
index 0000000000..b4b5886eae
--- /dev/null
+++ b/graphics/bit2spr/bit2spr.1
@@ -0,0 +1,61 @@
+.na
+.TH BIT2SPR 1 "June 9, 1992"
+.AT3
+.de sh
+.br
+.ne 5
+.PP
+\fB\\$1\fR
+.PP
+..
+.SH NAME
+bit2spr \- convert xmb type bitmap files into sprites for LaTeX's sprite
+style.
+.SH SYNOPSIS
+.B bit2spr
+[-width widthratio]\ [-height heightratio]
+[-output filename]\ [file] ...
+.SH DESCRIPTION
+.I bit2spr
+will read in a bitmaps from the names files or from standard input and
+procede to convert them into the sprite files for use in LaTeX documents.
+See the
+.I sprite.sty
+file for information on using sprites.
+
+The sprite information will be written to standard output unless a output
+file is named in the options.
+
+Since LaTeX needs to know the dimensions of the sprite, bit2spr takes the
+height and width information supplied by the bitmap and uses the default or
+given ratios to calculate the height and width of the sprite in inches. The
+default ratios are both 1.5. Given ratios can be any rational number, but
+just because bit2spr allows it doesn't mean the TeX processor will like the
+result.
+
+Bit2spr gives the sprites the same name as the filename, which means that
+directory slashes will be included. If no files are named to be read (ie:
+input taken from stanard input), bit2spr will only read the first sprite and
+name it Dummy.
+.SH EXAMPLES
+.I bit2spr < test > test.tex
+would instruct bit2spr to take standard input (
+.B test
+in this case) and write
+to stadard output (
+.B test.tex
+in this case).
+
+.I bit2spr -width 2.0 -height 2.5 -output test.tex test
+would instruct bit2spr to change the width ratio to 2.0, the height ratio to
+2.5, write to the file test.tex, and read from the file test.
+
+.I bit2spr -output test.tex < test
+would instruct bitspr to write to test.tex, and read from standard input (
+.B test
+in this case).
+.SH ACKNOWLEDGEMENTS
+Martin Costabel for writing the sprite.sty for LaTeX
+.SH AUTHOR
+Marc David Rovner (mrovner@ic.sunysb.edu)
+
diff --git a/graphics/bit2spr/bit2spr.c b/graphics/bit2spr/bit2spr.c
new file mode 100644
index 0000000000..af3a47f45d
--- /dev/null
+++ b/graphics/bit2spr/bit2spr.c
@@ -0,0 +1,165 @@
+/*
+ * Bitmap to LaTeX Sprite
+ * by Marc David Rovner (mrovner@ic.sunysb.edu)
+ * June 7th, 1992
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define MAXFILENAME 1024
+#define INITWIDTH 1.5
+#define INITHEIGHT 1.5
+
+typedef struct {
+ char OutFileName[MAXFILENAME];
+ float WidthRatio, HeightRatio;
+} ConvInfo;
+
+void conv_bitmap(Stuff,bitmapfile,spritefile,spritename)
+ConvInfo Stuff;
+FILE *bitmapfile, *spritefile;
+char *spritename;
+{ char buffer0[80], buffer1[80], temp;
+ int width, height, Row, Column, byte, i;
+
+ if ( (fscanf(bitmapfile, "%s %s %i", buffer0, buffer1, &width) == EOF)
+ || (fscanf(bitmapfile, "%s %s %i", buffer0, buffer1, &height) == EOF) )
+ {
+ fprintf(stderr, "File not correct bitmap file.\n");
+ fclose(bitmapfile);
+ exit(-1);
+ }
+ do
+ {
+ fscanf(bitmapfile, "%s", buffer0);
+ }
+ while (buffer0[0] != '{');
+
+ fprintf(spritefile,"\\sprite{\\%s}(%i,%i)[%.3fin,%.3fin]\n",
+ spritename, width, height,
+ ((width * Stuff.WidthRatio)/160.0),
+ ((height * Stuff.HeightRatio)/160.0) );
+
+ for (Row = 0; Row < height; ++Row)
+ {
+ fprintf(spritefile,":");
+ for (Column = 0; Column < width; Column = Column + 8)
+ {
+ if (fscanf(bitmapfile, "%i%c ", &byte, &temp) == EOF)
+ {
+ fprintf(stderr, "File not correct bitmap file.\n");
+ fclose(bitmapfile);
+ exit(-1);
+ }
+ for(i = 0; i<= 7; i++)
+ {
+ if ( (byte >> i) & 1)
+ {
+ fprintf(spritefile,"B");
+ }
+ else
+ {
+ fprintf(spritefile,".");
+ }
+ }
+ }
+ fprintf(spritefile," |\n");
+
+ }
+ fprintf(spritefile,"\\endsprite\n");
+
+ fclose(bitmapfile);
+}
+
+void main(argc,argv)
+int argc; char *argv[];
+{ ConvInfo Stuff;
+ FILE *bitmapfile, *spritefile;
+ int filestatus;
+ char *c;
+
+
+ /* Assign initial values to conversion information record */
+ Stuff.WidthRatio=INITWIDTH;
+ Stuff.HeightRatio=INITHEIGHT;
+ sprintf(Stuff.OutFileName,"\0");
+
+ /* While there are still command line options...*/
+ while (--argc>0 && (*++argv)[0] == '-')
+ {
+ c = ++(*argv);
+
+ /* User is redefining the width ratio */
+ if (strcmp("width",c) == 0)
+ {
+ --argc; (*++argv);
+ Stuff.WidthRatio= atof(*argv);
+ }
+
+ /* User is redefining the height ratio */
+ else if (strcmp("height",c) == 0)
+ {
+ --argc; (*++argv);
+ Stuff.HeightRatio= atof(*argv);
+ }
+
+ /* User is naming a file to put the output in */
+ else if (strcmp("output", c) == 0)
+ {
+ --argc; (*++argv);
+ strcpy(Stuff.OutFileName, *argv);
+ }
+
+ /* User has given an invalid option */
+ else
+ {
+ fprintf(stderr,"usage:\n bit2spr [-width width] [-height height] [-output outputfile] [bitmapfiles]\n");
+ exit(-1);
+ }
+ }
+
+ /* Test to see if the user gave an output file */
+ if (strcmp("\0", Stuff.OutFileName) != 0)
+ {
+ /* User did, so try to open it for writing */
+ if ( (spritefile = fopen(Stuff.OutFileName, "wt")) == NULL)
+ {
+ /* Open failed, tell user and quit */
+ fprintf(stderr,"Cannot open output file %s\n",Stuff.OutFileName);
+ exit(-1);
+ }
+ /* Open sucess */
+ else fprintf(stderr,"Writing to %s\n",Stuff.OutFileName);
+ }
+
+ /* User didn't supply an output file, so send output to
+ * standard output (usually the screen)
+ */
+ else spritefile = stdout;
+
+
+ /* Test to see if user supplied files to be read... */
+ if (argc == 0)
+ /* User didn't, so get files from stardard input */
+ conv_bitmap(Stuff,stdin,spritefile,"Dummy\0");
+
+ /* User did supply files to be read, so while there are still name */
+ else while (--argc>=0)
+ {
+ /* ...try opening current file for reading */
+ if ( (bitmapfile=fopen(*argv,"r")) == NULL)
+ /* Error opening file for read, so tell user & continue */
+ fprintf(stderr,"%s doesn't exists.\n",*argv);
+ /* Success opening file, so convert it */
+ else
+ {
+ fprintf(stderr,"Converting %s...\n", *argv);
+ conv_bitmap(Stuff,bitmapfile,spritefile,*argv);
+ }
+
+ /* move to next name */
+ (*++argv);
+ }
+}
+
diff --git a/graphics/bit2spr/sprite.sty b/graphics/bit2spr/sprite.sty
new file mode 120000
index 0000000000..7f14fb25b0
--- /dev/null
+++ b/graphics/bit2spr/sprite.sty
@@ -0,0 +1 @@
+../../macros/latex/contrib/sprite/sprite.sty \ No newline at end of file