imp@crayview.msi.umn.edu (Chuck Lukaszewski) (08/05/88)
Since there has been a lot of interest in MacPaint format and transferring such files to Unix machines, I am taking the liberty of posting the source for paintraster.c, which takes a MacPaint file already on a UNIX machine and converts it to a Sun rasterfile. The format of the MacPaint file is very simple run-length encoding and is described in Apple Technote #96. We routinely use a Mac II to generate title/credit frames for a Gould Image Processor. Once the frame is made with MacPaint, we use NCSA Telnet's ftp mode. We have never had a problem, whether we go straight onto the ethernet with a EtherTalk card, or go via AppleTalk and a Kinetics gateway. Be sure to use binary mode. This solves any problems with carriage returns getting inserted into the transferred file. /* * paintraster -- read macpaint document and output Sun rasterfile * * cc -O -o paintraster -c paintraster.c -lpixrect * * Ron Hitchens, U. of Texas @ Austin, hitchens@sally.utexas.edu * */ #include <stdio.h> #include <pixrect/pixrect_hs.h> #define MACPAINT_HDRSIZE 512 #define MACPAINT_BITWIDTH 576 #define MACPAINT_BITHEIGHT 720 unsigned char paint_data [MACPAINT_BITWIDTH/8][MACPAINT_BITHEIGHT]; mpr_static(paint_mpr, MACPAINT_BITWIDTH, MACPAINT_BITHEIGHT, 1, paint_data); main(argc, argv) char **argv; { static FILE *fp[2] = {stdin, stdout}; static char *mode [2] = {"r", "w"}; int i = 0; argc--; argv++; if (argc > 2) { fprintf (stderr, "usage: paintraster [infile | -] [outfile]\n"); exit (1); } while (argc) { if (argv [0][0] == '-') /* nothing */ ; else fp[i] = fopen(argv [0], mode [i]); if (fp[i] == NULL) { perror(argv [0]); exit (1); } i++; argc--; argv++; } load_paint(fp[0]); dump_raster (fp[1]); exit (0); } load_paint (fp) FILE *fp; { int i, j; for (i = 0; i < MACPAINT_HDRSIZE; i++) /* eat the header */ if (getc (fp) == EOF) { fprintf (stderr, "unexpected EOF reading MP header\n"); exit (1); } for (i = 0; i < MACPAINT_BITWIDTH/8; i++) for (j = 0; j < MACPAINT_BITHEIGHT; j++) paint_data [i][j] = (unsigned char)getbits(fp); } dump_raster (fp) FILE *fp; { colormap_t cmt; cmt.type = RMT_NONE; cmt.length = 0; pr_dump (&paint_mpr, fp, &cmt, RT_STANDARD, 0); } /* macpaint input routines */ getbits(fp) FILE *fp; { /* This routine expands the packbits encoded MacPaint file, delivering one byte per call */ static int count, rep, chr; int c; if (rep) { rep--; return chr; } if (count) { count--; return getc(fp); } c = getc(fp); if (c & 0x80) { /* repeated character count */ rep = 0x100 - c; /* byte length 2's comp + 1 */ /* allow for this call */ chr = getc(fp); /* character to repeat */ return chr; } else { count = c; /* already counted this char */ return getc(fp); } } ---===---===---===---===---===---===---===---===---===---===---===---===--- ARPAnet: AppleLink: SnailMail: Ma Bell: imp@crayview.msi.umn.edu UG0138 Minneapolis MN 55418 612/789-0931
englandr@phoenix.Princeton.EDU (Scott Louis Englander) (08/06/88)
In article <6525@umn-cs.cs.umn.edu> imp@crayview.msi.umn.edu (Chuck Lukaszewski) writes: >Since there has been a lot of interest in MacPaint format and transferring >such files to Unix machines, I am taking the liberty of posting the source >for paintraster.c, which takes a MacPaint file already on a UNIX machine >and converts it to a Sun rasterfile. The format of the MacPaint file is >very simple run-length encoding and is described in Apple Technote #96. > Is there a way to go from Sun rasterfile --> MacPaint?
gandalf@csli.STANFORD.EDU (Juergen Wagner) (08/07/88)
In article <3422@phoenix.Princeton.EDU> Scott Louis Englander writes: >... >Is there a way to go from Sun rasterfile --> MacPaint? Yes, Virginia, there is a way to do this. I have written a package to convert between currently 16 bitmap formats, including MacPaint. You can convert any input format of this package to MacPaint documents. The package is currently being cleaned up and I am fixing some bugs/ugly things. I expect it to be ready some time next week. I'll submit the package ("bmx", bitmap conversion, by the name) to comp.sources.unix, and for those of you on the Internet it will be available from csli.stanford.edu (#36.9.0.46) via anonymous ftp from pub/Gandalf/bmx.* from some time next week on. Stay tuned, Juergen "Gandalf" Wagner, gandalf@csli.stanford.edu Center for the Study of Language and Information (CSLI), Stanford CA ---------------------------------------------------------------------------- *** Bitmap Conversion program: `bmx' (Version beta-2.2) *** [BitConv, Copyr 1988, Juergen Wagner (gandalf@csli.stanford.edu)] This program converts bitmaps between different formats. It supports a variety of bitmap formats both, for input and output, a few (printer languages) are only available as output formats. The package serves as an interface to a library of C functions which provide I/O and other operations for bitmaps in the formats listed below. The command line syntax is: bmx [ operators... ] where 'operations' is a list of operation names followed by some optional arguments. Operation names are: -in Read a bitmap file -out Write a bitmap file -info Print information about a bitmap -list List all bitmaps currently loaded -log Write an action log -inv Invert all bits -rev Reverse bits (word-wise) -rev2 Reverse bits (byte-wise) -swap Swap bytes (word-wise) -frame Frame the bitmap -help Print help information For a list of applicable arguments for these operators, please see the manual page for this program. Because of their frequent use, here a syntax description for the -in and -out operators: -in name format file options... -out name format file options... where 'name' is the bitmap name (a string), 'format' is one of the input/output formats listed below, 'file' is the name of the file, the bitmap shall be read from/written to, and 'options' are some additional arguments for the conversion operator (see man page). The available input/output formats are: gandalf (gandalf, g) Gandalf's favourite format ascii (asc, a) ASCII representation raster (ras, r) Sun Rasterfile iconedit (icon, i) Sun Iconedit file impress (imp, l) imPRESS format dlionbm (dlion, d) Xerox-1108 InterLISP bitmap laserjet (lj, h) HP LaserJet format macpaint (macp, m) MacPaint documents postscript (ps, p) (nano-)PostScript (images only) printronix (ptx, t) Printronix printer format sixel (six, s) Sixel format (LN03 printer) ucbvax (ucb, u) Weird format of ucbvax:pub/xbackground/* xbitmap (xicon, x) X bitmap (header file) xwindow (xwd, w) X Window Dump format g4fax (fax, f) G4 FAX Format (CCITT Rec. T.4/T.6, VII.3) cvl (cvl, c) CVL Format Please send bug reports, comments, enhancements, etc. to Juergen Wagner (gandalf@csli.stanford.edu). -- Juergen "Gandalf" Wagner, gandalf@csli.stanford.edu Center for the Study of Language and Information (CSLI), Stanford CA