170 lines
5.4 KiB
HTML
170 lines
5.4 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of pbm</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>pbm</H1>
|
|
Section: File Formats (5)<BR>Updated: 05 March 2000<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
pbm - portable bitmap file format
|
|
<A NAME="lbAC"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
The portable bitmap format is a lowest common denominator monochrome
|
|
file format.
|
|
<A NAME="ixAAB"></A>
|
|
It serves as the common language of a large family of bitmap
|
|
conversion filters. Because the format pays no heed to efficiency,
|
|
it is simple and general enough that one can easily develop programs
|
|
to convert to and from just about any other graphics format, or to
|
|
manipulate the image.
|
|
<P>
|
|
|
|
This is not a format that one would normally use to store a file or to
|
|
transmit it to someone -- it's too expensive and not expressive enough
|
|
for that. It's just an intermediary format. In it's purest use, it
|
|
lives only in a pipe between two other programs.
|
|
<P>
|
|
|
|
The format definition is as follows.
|
|
<P>
|
|
|
|
A PBM file consists of a sequence of one or more PBM images. There are
|
|
no data, delimiters, or padding before, after, or between images.
|
|
<P>
|
|
|
|
Each PBM image consists of the following:
|
|
<DL COMPACT>
|
|
<DT id="1">-<DD>
|
|
A "magic number" for identifying the file type.
|
|
A pbm image's magic number is the two characters "P4".
|
|
<A NAME="ixAAC"></A>
|
|
<DT id="2">-<DD>
|
|
Whitespace (blanks, TABs, CRs, LFs).
|
|
<DT id="3">-<DD>
|
|
The width in pixels of the image, formatted as ASCII characters in decimal.
|
|
<DT id="4">-<DD>
|
|
Whitespace.
|
|
<DT id="5">-<DD>
|
|
The height in pixels of the image, again in ASCII decimal.
|
|
<DT id="6">-<DD>
|
|
Newline or other single whitespace character.
|
|
<DT id="7">-<DD>
|
|
A raster of Height rows, in order from top to bottom. Each row is
|
|
Width bits, packed 8 to a byte, with don't care bits to fill out the
|
|
last byte in the row. Each bit represents a pixel: 1 is black, 0 is
|
|
white. The order of the pixels is left to right. The order of their
|
|
storage within each file byte is most significant bit to least
|
|
significant bit. The order of the file bytes is from the beginning of
|
|
the file toward the end of the file.
|
|
<DT id="8">-<DD>
|
|
Characters from a "#" to the next end-of-line, before the width/height line,
|
|
are comments and are ignored.
|
|
</DL>
|
|
<P>
|
|
|
|
There is actually another version of the PBM format, even more more
|
|
simplistic, more lavishly wasteful of space than PBM, called Plain
|
|
PBM. Plain PBM actually came first, but even its inventor couldn't
|
|
stand its recklessly squanderous use of resources after a while and
|
|
switched to what we now know as the regular PBM format. But Plain PBM
|
|
is so redundant -- so overstated -- that it's virtually impossible to
|
|
break. You can send it through the most liberal mail system (which
|
|
was the original purpose of the PBM format) and it will arrive still
|
|
readable. You can flip a dozen random bits and easily piece back
|
|
together the original image. And we hardly need to define the format
|
|
here, because you can decode it by inspection.
|
|
<P>
|
|
|
|
The difference is:
|
|
<DL COMPACT>
|
|
<DT id="9">-<DD>
|
|
There is exactly one image in a file.
|
|
<DT id="10">-<DD>
|
|
The "magic number" is "P1" instead of "P4".
|
|
<DT id="11">-<DD>
|
|
Each pixel in the raster is represented by a byte containing ASCII '1' or '0',
|
|
representing black and white respectively. There are no fill bits at the
|
|
end of a row.
|
|
<DT id="12">-<DD>
|
|
White space in the raster section is ignored.
|
|
<DT id="13">-<DD>
|
|
You can put any junk you want after the raster, if it starts with a
|
|
white space character.
|
|
<DT id="14">-<DD>
|
|
No line should be longer than 70 characters.
|
|
</DL>
|
|
<P>
|
|
|
|
Here is an example of a small bitmap in the plain PBM format:
|
|
<PRE>
|
|
P1
|
|
# feep.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
|
|
</PRE>
|
|
|
|
<P>
|
|
|
|
You can generate the Plain PBM format from the regular PBM format
|
|
(first image in the file only) with the
|
|
<B>pnmtoplainpnm</B>
|
|
|
|
program.
|
|
<P>
|
|
<P>
|
|
|
|
Programs that read this format should be as lenient as possible,
|
|
accepting anything that looks remotely like a bitmap.
|
|
<P>
|
|
<A NAME="lbAD"> </A>
|
|
<H2>COMPATIBILITY</H2>
|
|
|
|
<P>
|
|
Before July 2000, there could be at most one image in a PBM file. As
|
|
a result, most tools to process PBM files ignore (and don't read) any
|
|
data after the first image.
|
|
<P>
|
|
<A NAME="lbAE"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+libpbm">libpbm</A></B>(3),<B><A HREF="/cgi-bin/man/man2html?5+pnm">pnm</A></B>(5),<B><A HREF="/cgi-bin/man/man2html?5+pgm">pgm</A></B>(5),<B><A HREF="/cgi-bin/man/man2html?5+ppm">ppm</A></B>(5)
|
|
|
|
<A NAME="lbAF"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
Copyright (C) 1989, 1991 by Jef Poskanzer.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="15"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="16"><A HREF="#lbAC">DESCRIPTION</A><DD>
|
|
<DT id="17"><A HREF="#lbAD">COMPATIBILITY</A><DD>
|
|
<DT id="18"><A HREF="#lbAE">SEE ALSO</A><DD>
|
|
<DT id="19"><A HREF="#lbAF">AUTHOR</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:06:04 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|