|
The portable pixmap file format (PPM) is a file format for exchanging pixmap files (more commonly known as color bitmap files). It is very basic and serves as a least common denominator for converting bitmap files between different platforms. It is used in the netpbm (http://netpbm.sourceforge.net/) file conversion package as the central file format for different conversion utilities.
Let's take the example of the letter J from the bitmap article
....X.
....X.
....X.
....X.
....X.
....X.
X...X.
.XXX..
......
......
It is represented in an similar, but even simpler file format version PBM (monochrome) as follows
P1
# This is an example bit map file j.pbm
6 10
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 0
0 0 0 0 1 0
1 0 0 0 1 0
0 1 1 1 0 0
0 0 0 0 0 0
0 0 0 0 0 0
The P1 is the identificaton of the file format. The hash sign marks a commentary. And the next two numbers give the width and the height. Then follows the matrix with the pixel values (in the monochrome case here only zeros and ones).
This file can be converted by two conversion programs from the netpbm package for example to a bmp file:
pgmtoppm "#FFFFFF" j.pbm > j.ppm
ppmtobmp j.ppm > j.bmp
Depending on the identification of the file format three similar file formats are distinguished, each with two versions:
- pbm - portable bitmap file format (P1/P4) - 1 bit per pixel
- pgm - portable graymap file format (P2/P5) - 8 bits per pixel
- ppm - portable pixmap file format (P3/P6) - 24 bits per pixel, 8 for red, 8 for green, 8 for blue
In each case, the lower-numbered version refers to a human-readable, ASCII-based format similar to the one in the example above and the higher-numbered version refers to a binary format which is not human-readable but saves some space in the file, as well as being easier to parse due to the lack of whitespace.
External link
- File format details for all 3 formats:
|