version 1, including all changes.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
pbm |
|
|
2 |
!!!pbm |
|
|
3 |
NAME |
|
|
4 |
DESCRIPTION |
|
|
5 |
COMPATIBILITY |
|
|
6 |
SEE ALSO |
|
|
7 |
AUTHOR |
|
|
8 |
---- |
|
|
9 |
!!NAME |
|
|
10 |
|
|
|
11 |
|
|
|
12 |
pbm - portable bitmap file format |
|
|
13 |
!!DESCRIPTION |
|
|
14 |
|
|
|
15 |
|
|
|
16 |
The portable bitmap format is a lowest common denominator |
|
|
17 |
monochrome file format. It serves as the common language of |
|
|
18 |
a large family of bitmap conversion filters. Because the |
|
|
19 |
format pays no heed to efficiency, it is simple and general |
|
|
20 |
enough that one can easily develop programs to convert to |
|
|
21 |
and from just about any other graphics format, or to |
|
|
22 |
manipulate the image. |
|
|
23 |
|
|
|
24 |
|
|
|
25 |
This is not a format that one would normally use to store a |
|
|
26 |
file or to transmit it to someone -- it's too expensive and |
|
|
27 |
not expressive enough for that. It's just an intermediary |
|
|
28 |
format. In it's purest use, it lives only in a pipe between |
|
|
29 |
two other programs. |
|
|
30 |
|
|
|
31 |
|
|
|
32 |
The format definition is as follows. |
|
|
33 |
|
|
|
34 |
|
|
|
35 |
A PBM file consists of a sequence of one or more PBM images. |
|
|
36 |
There are no data, delimiters, or padding before, after, or |
|
|
37 |
between images. |
|
|
38 |
|
|
|
39 |
|
|
|
40 |
Each PBM image consists of the following: |
|
|
41 |
|
|
|
42 |
|
|
|
43 |
- |
|
|
44 |
|
|
|
45 |
|
|
|
46 |
A |
|
|
47 |
|
|
|
48 |
|
|
|
49 |
- |
|
|
50 |
|
|
|
51 |
|
|
|
52 |
Whitespace (blanks, TABs, CRs, LFs). |
|
|
53 |
|
|
|
54 |
|
|
|
55 |
- |
|
|
56 |
|
|
|
57 |
|
|
|
58 |
The width in pixels of the image, formatted as ASCII |
|
|
59 |
characters in decimal. |
|
|
60 |
|
|
|
61 |
|
|
|
62 |
- |
|
|
63 |
|
|
|
64 |
|
|
|
65 |
Whitespace. |
|
|
66 |
|
|
|
67 |
|
|
|
68 |
- |
|
|
69 |
|
|
|
70 |
|
|
|
71 |
The height in pixels of the image, again in ASCII |
|
|
72 |
decimal. |
|
|
73 |
|
|
|
74 |
|
|
|
75 |
- |
|
|
76 |
|
|
|
77 |
|
|
|
78 |
Newline or other single whitespace character. |
|
|
79 |
|
|
|
80 |
|
|
|
81 |
- |
|
|
82 |
|
|
|
83 |
|
|
|
84 |
A raster of Height rows, in order from top to bottom. Each |
|
|
85 |
row is Width bits, packed 8 to a byte, with don't care bits |
|
|
86 |
to fill out the last byte in the row. Each bit represents a |
|
|
87 |
pixel: 1 is black, 0 is white. The order of the pixels is |
|
|
88 |
left to right. The order of their storage within each file |
|
|
89 |
byte is most significant bit to least significant bit. The |
|
|
90 |
order of the file bytes is from the beginning of the file |
|
|
91 |
toward the end of the file. |
|
|
92 |
|
|
|
93 |
|
|
|
94 |
- |
|
|
95 |
|
|
|
96 |
|
|
|
97 |
Characters from a |
|
|
98 |
|
|
|
99 |
|
|
|
100 |
There is actually another version of the PBM format, even |
|
|
101 |
more more simplistic, more lavishly wasteful of space than |
|
|
102 |
PBM, called Plain PBM. Plain PBM actually came first, but |
|
|
103 |
even its inventor couldn't stand its recklessly squanderous |
|
|
104 |
use of resources after a while and switched to what we now |
|
|
105 |
know as the regular PBM format. But Plain PBM is so |
|
|
106 |
redundant -- so overstated -- that it's virtually impossible |
|
|
107 |
to break. You can send it through the most liberal mail |
|
|
108 |
system (which was the original purpose of the PBM format) |
|
|
109 |
and it will arrive still readable. You can flip a dozen |
|
|
110 |
random bits and easily piece back together the original |
|
|
111 |
image. And we hardly need to define the format here, because |
|
|
112 |
you can decode it by inspection. |
|
|
113 |
|
|
|
114 |
|
|
|
115 |
The difference is: |
|
|
116 |
|
|
|
117 |
|
|
|
118 |
- |
|
|
119 |
|
|
|
120 |
|
|
|
121 |
There is exactly one image in a file. |
|
|
122 |
|
|
|
123 |
|
|
|
124 |
- |
|
|
125 |
|
|
|
126 |
|
|
|
127 |
The |
|
|
128 |
|
|
|
129 |
|
|
|
130 |
- |
|
|
131 |
|
|
|
132 |
|
|
|
133 |
Each pixel in the raster is represented by a byte containing |
|
|
134 |
ASCII '1' or '0', representing black and white respectively. |
|
|
135 |
There are no fill bits at the end of a row. |
|
|
136 |
|
|
|
137 |
|
|
|
138 |
- |
|
|
139 |
|
|
|
140 |
|
|
|
141 |
White space in the raster section is ignored. |
|
|
142 |
|
|
|
143 |
|
|
|
144 |
- |
|
|
145 |
|
|
|
146 |
|
|
|
147 |
You can put any junk you want after the raster, if it starts |
|
|
148 |
with a white space character. |
|
|
149 |
|
|
|
150 |
|
|
|
151 |
- |
|
|
152 |
|
|
|
153 |
|
|
|
154 |
No line should be longer than 70 characters. |
|
|
155 |
|
|
|
156 |
|
|
|
157 |
Here is an example of a small bitmap in the plain PBM |
|
|
158 |
format: |
|
|
159 |
|
|
|
160 |
|
|
|
161 |
P1 |
|
|
162 |
# feep.pbm |
|
|
163 |
24 7 |
|
|
164 |
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
|
|
165 |
0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 |
|
|
166 |
0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 |
|
|
167 |
0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 1 0 |
|
|
168 |
0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 |
|
|
169 |
0 1 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 0 0 0 0 |
|
|
170 |
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
|
|
171 |
You can generate the Plain PBM format from the regular PBM format (first image in the file only) with the __pnmtoplainpnm__ program. |
|
|
172 |
|
|
|
173 |
|
|
|
174 |
Programs that read this format should be as lenient as |
|
|
175 |
possible, accepting anything that looks remotely like a |
|
|
176 |
bitmap. |
|
|
177 |
!!COMPATIBILITY |
|
|
178 |
|
|
|
179 |
|
|
|
180 |
Before July 2000, there could be at most one image in a PBM |
|
|
181 |
file. As a result, most tools to process PBM files ignore |
|
|
182 |
(and don't read) any data after the first |
|
|
183 |
image. |
|
|
184 |
!!SEE ALSO |
|
|
185 |
|
|
|
186 |
|
|
|
187 |
libpbm(3),pnm(5),pgm(5),ppm(5) |
|
|
188 |
!!AUTHOR |
|
|
189 |
|
|
|
190 |
|
|
|
191 |
Copyright (C) 1989, 1991 by Jef Poskanzer. |
|
|
192 |
---- |