jef@helios.ee.lbl.gov (Jef Poskanzer) (11/09/88)
Posting-number: Volume 5, Issue 45 Submitted-by: "Jef Poskanzer" <jef@helios.ee.lbl.gov> Archive-name: pbm3/Part5 #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # pbm.h # libpbm.h # macp.h # x10wd.h # x11wd.h # pbm.5 # bmaliases # bitreverse.h # This archive created: Mon Oct 31 18:33:41 1988 # By: Jef Poskanzer (Paratheo-Anametamystikhood Of Eris Esoteric, Ada Lovelace Cabal) export PATH; PATH=/bin:$PATH echo shar: extracting "'pbm.h'" '(480 characters)' if test -f 'pbm.h' then echo shar: will not over-write existing file "'pbm.h'" else sed 's/^X//' << \SHAR_EOF > 'pbm.h' X/* pbm.h - header file for libpbm portable bitmap library X*/ X Xtypedef unsigned char bit; X X/* Declarations of routines. */ X Xbit **pbm_allocarray( ); X /* bits = pbm_allocarray( cols, rows ); bits[row][col]; */ X Xbit **pbm_readpbm( ); X /* bits = pbm_readpbm( file, &cols, &rows ); */ Xpbm_writepbm( ); X /* pbm_writepbm( file, bits, cols, rows ); */ X Xbit **pbm_readcbm( ); X /* bits = pbm_readcbm( file, &cols, &rows ); */ Xpbm_writecbm( ); X /* pbm_writecbm( file, bits, cols, rows ); */ SHAR_EOF if test 480 -ne "`wc -c < 'pbm.h'`" then echo shar: error transmitting "'pbm.h'" '(should have been 480 characters)' fi fi # end of overwriting check echo shar: extracting "'libpbm.h'" '(382 characters)' if test -f 'libpbm.h' then echo shar: will not over-write existing file "'libpbm.h'" else sed 's/^X//' << \SHAR_EOF > 'libpbm.h' X/* libpbm.h - internal header file for libpbm portable bitmap library X*/ X X#define PBM_MAGIC1 'P' X#define PBM_MAGIC2 '1' X X#define CBM_MAGIC1 42 X#define OCBM_MAGIC2 23 X#define NCBM_MAGIC2 24 X X#define VERSION_OLDCBM 1 X#define VERSION_RUNLEN 2 X X#define DEFAULT_BITSPERCOUNT 8 X#define MAX_BITSPERCOUNT 12 X#define MAX_MAXCOUNT 8191 X X#define DEFAULT_REPEATBITS 2 X#define MAX_REPEATBITS 32 SHAR_EOF if test 382 -ne "`wc -c < 'libpbm.h'`" then echo shar: error transmitting "'libpbm.h'" '(should have been 382 characters)' fi fi # end of overwriting check echo shar: extracting "'macp.h'" '(161 characters)' if test -f 'macp.h' then echo shar: will not over-write existing file "'macp.h'" else sed 's/^X//' << \SHAR_EOF > 'macp.h' X/* macp.h - header file for MacPaint files X*/ X X#define HEADER_LENGTH 512 X#define MAX_LINES 720 X#define BYTES_WIDE 72 X#define MAX_COLS 576 /* = BYTES_WIDE * 8 */ SHAR_EOF if test 161 -ne "`wc -c < 'macp.h'`" then echo shar: error transmitting "'macp.h'" '(should have been 161 characters)' fi fi # end of overwriting check echo shar: extracting "'x10wd.h'" '(952 characters)' if test -f 'x10wd.h' then echo shar: will not over-write existing file "'x10wd.h'" else sed 's/^X//' << \SHAR_EOF > 'x10wd.h' X/* x10wd.h - the following defs are taken from various X10 header files X*/ X X#define XYFormat 0 X#define ZFormat 1 X X#define X10WD_FILE_VERSION 6 Xtypedef struct { X int header_size; /* Size of the entire file header (bytes). */ X int file_version; /* X10WD_FILE_VERSION */ X int display_type; /* Display type. */ X int display_planes; /* Number of display planes. */ X int pixmap_format; /* Pixmap format. */ X int pixmap_width; /* Pixmap width. */ X int pixmap_height; /* Pixmap height. */ X short window_width; /* Window width. */ X short window_height; /* Window height. */ X short window_x; /* Window upper left X coordinate. */ X short window_y; /* Window upper left Y coordinate. */ X short window_bdrwidth; /* Window border width. */ X short window_ncolors; /* number of Color entries in this window */ X } X10WDFileHeader; X Xtypedef struct { X int pixel; X unsigned short red, green, blue; X } X10Color; SHAR_EOF if test 952 -ne "`wc -c < 'x10wd.h'`" then echo shar: error transmitting "'x10wd.h'" '(should have been 952 characters)' fi fi # end of overwriting check echo shar: extracting "'x11wd.h'" '(1692 characters)' if test -f 'x11wd.h' then echo shar: will not over-write existing file "'x11wd.h'" else sed 's/^X//' << \SHAR_EOF > 'x11wd.h' X/* x11wd.h - the following defs are taken from various X.V11R2 header files X*/ X X#define LSBFirst 0 X#define MSBFirst 1 X X#define XYBitmap 0 X#define XYPixmap 1 X#define ZPixmap 2 X Xtypedef unsigned long xwdval; X#define X11WD_FILE_VERSION 7 Xtypedef struct { X xwdval header_size; /* Size of the entire file header (bytes). */ X xwdval file_version; /* X11WD_FILE_VERSION */ X xwdval pixmap_format; /* Pixmap format */ X xwdval pixmap_depth; /* Pixmap depth */ X xwdval pixmap_width; /* Pixmap width */ X xwdval pixmap_height; /* Pixmap height */ X xwdval xoffset; /* Bitmap x offset */ X xwdval byte_order; /* MSBFirst, LSBFirst */ X xwdval bitmap_unit; /* Bitmap unit */ X xwdval bitmap_bit_order; /* MSBFirst, LSBFirst */ X xwdval bitmap_pad; /* Bitmap scanline pad */ X xwdval bits_per_pixel; /* Bits per pixel */ X xwdval bytes_per_line; /* Bytes per scanline */ X xwdval visual_class; /* Class of colormap */ X xwdval red_mask; /* Z red mask */ X xwdval green_mask; /* Z green mask */ X xwdval blue_mask; /* Z blue mask */ X xwdval bits_per_rgb; /* Log base 2 of distinct color values */ X xwdval colormap_entries; /* Number of entries in colormap */ X xwdval ncolors; /* Number of Color structures */ X xwdval window_width; /* Window width */ X xwdval window_height; /* Window height */ X long window_x; /* Window upper left X coordinate */ X long window_y; /* Window upper left Y coordinate */ X xwdval window_bdrwidth; /* Window border width */ X } X11WDFileHeader; X Xtypedef struct { X unsigned long pixel; X unsigned short red, green, blue; X char flags; /* do_red, do_green, do_blue */ X char pad; X } X11XColor; SHAR_EOF if test 1692 -ne "`wc -c < 'x11wd.h'`" then echo shar: error transmitting "'x11wd.h'" '(should have been 1692 characters)' fi fi # end of overwriting check echo shar: extracting "'pbm.5'" '(2500 characters)' if test -f 'pbm.5' then echo shar: will not over-write existing file "'pbm.5'" else sed 's/^X//' << \SHAR_EOF > 'pbm.5' X.TH pbm 5 "31 August 1988" X.SH NAME Xpbm - portable bitmap file format X.SH DESCRIPTION XThe portable bitmap format is a lowest common denominator. XIt was originally designed to make it reasonable to mail bitmaps Xbetween different types of machines using the typical stupid network Xmailers we have today. XNow it serves as the common language of a large family of bitmap Xconversion filters. XThe definition is as follows: X.IP - 2 XA "magic number" for identifying the file type. XA pbm file's magic number is the two characters "P1". X.IP - 2 XWhitespace (blanks, TABs, CRs, LFs). X.IP - 2 XA width, formatted as ASCII characters in decimal. X.IP - 2 XWhitespace. X.IP - 2 XA height, again in ASCII decimal. X.IP - 2 XWhitespace. X.IP - 2 XWidth * height bits, each either '1' or '0', starting at the top-left Xcorner of the bitmap, proceding in normal English reading order. X.IP - 2 XThe character '1' means black, '0' means white. X.IP - 2 XWhitespace in the bits section is ignored. X.IP - 2 XCharacters from a "#" to the next end-of-line are ignored (comments). X.IP - 2 XNo line may be longer than 70 characters. X.PP XHere is an example of a small bitmap in this format: X.PP X.nf XP1 X# feep.pbm X24 7 X0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 X0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 X0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 X0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 1 0 X0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 X0 1 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 0 0 0 0 X0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 X.fi X.PP XPrograms that read this format should be as lenient as possible, Xaccepting anything that looks remotely like a bitmap. X.SH "SEE ALSO" Xbrushtopbm(1), cbmtopbm(1), giftopbm(1), icontopbm(1), macptopbm(1), Xpbmcatlr(1), pbmcattb(1), pbmcrop(1), pbmcut(1), pbmenlarge(1), Xpbmfliplr(1), pbmfliptb(1), pbminvert(1), pbmmake(1), pbmpaste(1), Xpbmtoascii(1), pbmtocbm(1), pbmtoicon(1), pbmtolj(1), pbmtomacp(1), Xpbmtops(1), pbmtoptx(1), pbmtorast(1), pbmtox10bm(1), pbmtox10wd(1), Xpbmtoxbm(1), pbmtoxwd(1), pbmtrnspos(1), rasttopbm(1), Xxbmtopbm(1), xwdtopbm(1), xxxtopbm(1) X.SH AUTHOR XCopyright (C) 1988 by Jef Poskanzer. X XPermission to use, copy, modify, and distribute this software and its Xdocumentation for any purpose and without fee is hereby granted, provided Xthat the above copyright notice appear in all copies and that both that Xcopyright notice and this permission notice appear in supporting Xdocumentation. This software is provided "as is" without express or Ximplied warranty. SHAR_EOF if test 2500 -ne "`wc -c < 'pbm.5'`" then echo shar: error transmitting "'pbm.5'" '(should have been 2500 characters)' fi fi # end of overwriting check echo shar: extracting "'bmaliases'" '(386 characters)' if test -f 'bmaliases' then echo shar: will not over-write existing file "'bmaliases'" else sed 's/^X//' << \SHAR_EOF > 'bmaliases' X# This script must be sourced - it will not work if you run it in a sub-shell. X Xset _to_only="ascii lj ps ptx x10bm x10wd" Xset _from_only="brush gif xxx" Xset _both="cbm icon macp rast xbm xwd" X Xforeach i ( $_both $_from_only ) X foreach j ( $_both $_to_only ) X if ( $i != $j ) then X alias ${i}to${j} "( ${i}topbm | pbmto${j} )" X endif X end Xend X Xunset _to_only _from_only _both SHAR_EOF if test 386 -ne "`wc -c < 'bmaliases'`" then echo shar: error transmitting "'bmaliases'" '(should have been 386 characters)' fi fi # end of overwriting check echo shar: extracting "'bitreverse.h'" '(1992 characters)' if test -f 'bitreverse.h' then echo shar: will not over-write existing file "'bitreverse.h'" else sed 's/^X//' << \SHAR_EOF > 'bitreverse.h' X/* X** bitreverse.h X** X** This particular array seems to be useful in a lot of bitmap X** conversion programs. It's not used in pbm because bits are X** stored one per byte, for easier manipulation. But if you wanted X** to write, for example, a program to directly convert Sun raster X** format into X bitmaps, you could use this. X*/ X Xunsigned char bitreverse[256] = { X 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, X 0x30, 0xb0, 0x70, 0xf0, 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, X 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 0x04, 0x84, 0x44, 0xc4, X 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, X 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc, X 0x3c, 0xbc, 0x7c, 0xfc, 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, X 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, 0x0a, 0x8a, 0x4a, 0xca, X 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, X 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, X 0x36, 0xb6, 0x76, 0xf6, 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, X 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 0x01, 0x81, 0x41, 0xc1, X 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, X 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9, X 0x39, 0xb9, 0x79, 0xf9, 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, X 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, 0x0d, 0x8d, 0x4d, 0xcd, X 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, X 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, X 0x33, 0xb3, 0x73, 0xf3, 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, X 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, 0x07, 0x87, 0x47, 0xc7, X 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, X 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, X 0x3f, 0xbf, 0x7f, 0xff}; SHAR_EOF if test 1992 -ne "`wc -c < 'bitreverse.h'`" then echo shar: error transmitting "'bitreverse.h'" '(should have been 1992 characters)' fi fi # end of overwriting check # End of shell archive exit 0