PBMA Files
ASCII Portable Bit Map Graphics Files
PBMA is the ASCII version of the portable bitmap (PBM) format,
a lowest common denominator monochrome (black and white) file format.
It was originally designed to make it reasonable to mail bitmaps between
different types of machines. Now it serves as the common language
of a large family of bitmap conversion filters.
The definition is as follows:
-
the typical file extension is ".pbm", but an extension of
".pnm" is also occasionally used.
-
A "magic number" for identifying the file type. An
ASCII PBM file's magic number is the two characters "P1".
-
Whitespace (blanks, TABs, CRs, LFs).
-
A width, formatted as ASCII characters in decimal.
-
Whitespace.
-
A height, again in ASCII decimal.
-
Whitespace.
-
Width * height bits, each either '1' or '0', starting at the top-left
corner of the bitmap, proceeding in normal English reading order.
The character '1' means black, '0' means white.
Whitespace in the bits section is ignored.
Characters from a "#" to the next end-of-line are ignored (comments).
No line should be longer than 70 characters.
Example ASCII PBM file:
P1
# feep.ascii.pbm
24 7
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0
0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0
0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 1 0
0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0
0 1 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ASCII PBM File Characteristics:
-
ASCII
-
black and white
-
2D
-
No compression
-
1 image
Licensing:
The computer code and data files described and made available on this web page
are distributed under
the GNU LGPL license.
Related Data and Programs:
PBMA_IO
is a C++ library which
handles the Portable Bit Map (ASCII) format.
PBMB,
a data directory which
contains examples of PBMB files,
binary Portable Bit Map 2D graphics, black and white;
PBMLIB,
a C library which
reads or writes
graphics files in the Portable Bit Map format;
PGMA,
a data directory which
contains examples of PGMA files,
ASCII Portable Gray Map, 2D graphics;
PPMA,
a data directory which
contains examples of PPMA files,
Portable Pixel Map (ASCII) 2D graphics, color;
Reference:
-
the NETPBM homepage.
Programs to create an ASCII PBM file:
Programs and routines to read an ASCII PBM file:
Programs and routines to write an ASCII PBM file:
Programs to view an ASCII PBM file:
-
AVS
includes a module read_any_image which can read
an ASCII PBM file;
-
GIMP,
the GNU Image Manipulation Program, can read and display
an ASCII PBM file.
-
The
ImageVision
program imgview can display an ASCII PBM file.
-
MATLAB can display
an ASCII PBM file, once it is read in, with a command
like image(A).
-
xv
can read and display an ASCII PBM file.
Programs to convert an ASCII PBM file to another format:
-
convert, a program supplied with
ImageMagick,
can convert an ASCII PBM file to
BMP, CGM, EPS, FIG, FITS, GIF, JPG, PBM, PDF, PGM, PNG, PNM,
PPM, PS, RGB, TIF, XBM or XPM format.
-
GIMP,
the GNU Image Manipulation Program, can read an ASCII PBM file
and write out a copy in a variety of formats.
-
PBMTOASCII, a program that is part of
NETPBM,
can read an ASCII PBM file and write out it out as ASCII graphics.
-
xv can read
an ASCII PBM file and write out a copy in BMP, FIT, GIF, JPG,
PGM, PPM, RGB or TIF format.
Programs to convert a file to ASCII PBM format:
-
convert, a program supplied with
ImageMagick,
can convert a
BMP, CGM, EPS, FIG, FITS, GIF, JPG, PBM, PDF, PGM, PNG, PNM,
PPM, PS, RGB, TIF, XBM or XPM file to ASCII PBM format.
However, to force the ASCII format, you must include the switch
"-compress none".
-
GIMP,
the GNU Image Manipulation Program, can read a file in a
variety of formats, and write it out as an ASCII PBM file.
-
xv can read a file in a
BMP, FIT, GIF, JPG, PGM, PPM, RGB or TIF format, and write it out
as an ASCII PBM file.
Sample ASCII PBM files:
All the filenames here include the extension "ascii.pbm". The "ascii" part
just helps me to distinguish these files from their binary versions, and is
not required by any program.
-
circle.ascii.pbm,
a circle, drawn on a 200 by 200 grid;
-
circle.png,
a PNG version.
-
feep.ascii.pbm,
the example described above, on a 24 by 7 grid;
-
feep.png,
a PNG version.
-
gerrymander.ascii.pbm,
an image of the "Gerry-mander", on a 303 by 325 grid;
-
gerrymander.png,
a PNG version.
-
letter_a.ascii.pbm, a capital A,
using a 25 by 25 grid.
-
letter_a.png,
a PNG version.
-
scs.ascii.pbm,
the letters "SCS", on a 136 by 82 grid;
-
scs.png,
a PNG version.
You can go up one level to
the DATA page.
Last revised on 22 September 2009.