Portable Pixmap file format

The portable pixmap / greymap / bitmap file formats (PPM, PGM, PBM) are file formats for exchanging graphics files. They are very basic and serve as a least common denominator for converting pixmap, greymap, or bitmap files between different platforms. They are used under the collective name PNM format in the Netpbm file conversion package.

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 the most basic (monochrome) PBM format 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.

16-bit extensions

The original definition of the PGM and the PPM binary formats (the P5 and P6 formats) did not support bit-depths greater than 8 bits. It is of course possible to use the ASCII format, but this format is both slow to read, and makes the files much larger. There have therefore been several efforts to extend the format to support higher bit depths. The problem with higher bit depths is that you have to decide on the endianess of the file. Unfortunately it appears that the various implementations could not agree on which bit depth to use! Netpbm, which is the de facto standard implementation of the pnm formats uses big-endian.

External link

Navigation

  • Art and Cultures
    • Art (https://academickids.com/encyclopedia/index.php/Art)
    • Architecture (https://academickids.com/encyclopedia/index.php/Architecture)
    • Cultures (https://www.academickids.com/encyclopedia/index.php/Cultures)
    • Music (https://www.academickids.com/encyclopedia/index.php/Music)
    • Musical Instruments (http://academickids.com/encyclopedia/index.php/List_of_musical_instruments)
  • Biographies (http://www.academickids.com/encyclopedia/index.php/Biographies)
  • Clipart (http://www.academickids.com/encyclopedia/index.php/Clipart)
  • Geography (http://www.academickids.com/encyclopedia/index.php/Geography)
    • Countries of the World (http://www.academickids.com/encyclopedia/index.php/Countries)
    • Maps (http://www.academickids.com/encyclopedia/index.php/Maps)
    • Flags (http://www.academickids.com/encyclopedia/index.php/Flags)
    • Continents (http://www.academickids.com/encyclopedia/index.php/Continents)
  • History (http://www.academickids.com/encyclopedia/index.php/History)
    • Ancient Civilizations (http://www.academickids.com/encyclopedia/index.php/Ancient_Civilizations)
    • Industrial Revolution (http://www.academickids.com/encyclopedia/index.php/Industrial_Revolution)
    • Middle Ages (http://www.academickids.com/encyclopedia/index.php/Middle_Ages)
    • Prehistory (http://www.academickids.com/encyclopedia/index.php/Prehistory)
    • Renaissance (http://www.academickids.com/encyclopedia/index.php/Renaissance)
    • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
    • United States (http://www.academickids.com/encyclopedia/index.php/United_States)
    • Wars (http://www.academickids.com/encyclopedia/index.php/Wars)
    • World History (http://www.academickids.com/encyclopedia/index.php/History_of_the_world)
  • Human Body (http://www.academickids.com/encyclopedia/index.php/Human_Body)
  • Mathematics (http://www.academickids.com/encyclopedia/index.php/Mathematics)
  • Reference (http://www.academickids.com/encyclopedia/index.php/Reference)
  • Science (http://www.academickids.com/encyclopedia/index.php/Science)
    • Animals (http://www.academickids.com/encyclopedia/index.php/Animals)
    • Aviation (http://www.academickids.com/encyclopedia/index.php/Aviation)
    • Dinosaurs (http://www.academickids.com/encyclopedia/index.php/Dinosaurs)
    • Earth (http://www.academickids.com/encyclopedia/index.php/Earth)
    • Inventions (http://www.academickids.com/encyclopedia/index.php/Inventions)
    • Physical Science (http://www.academickids.com/encyclopedia/index.php/Physical_Science)
    • Plants (http://www.academickids.com/encyclopedia/index.php/Plants)
    • Scientists (http://www.academickids.com/encyclopedia/index.php/Scientists)
  • Social Studies (http://www.academickids.com/encyclopedia/index.php/Social_Studies)
    • Anthropology (http://www.academickids.com/encyclopedia/index.php/Anthropology)
    • Economics (http://www.academickids.com/encyclopedia/index.php/Economics)
    • Government (http://www.academickids.com/encyclopedia/index.php/Government)
    • Religion (http://www.academickids.com/encyclopedia/index.php/Religion)
    • Holidays (http://www.academickids.com/encyclopedia/index.php/Holidays)
  • Space and Astronomy
    • Solar System (http://www.academickids.com/encyclopedia/index.php/Solar_System)
    • Planets (http://www.academickids.com/encyclopedia/index.php/Planets)
  • Sports (http://www.academickids.com/encyclopedia/index.php/Sports)
  • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
  • Weather (http://www.academickids.com/encyclopedia/index.php/Weather)
  • US States (http://www.academickids.com/encyclopedia/index.php/US_States)

Information

  • Home Page (http://academickids.com/encyclopedia/index.php)
  • Contact Us (http://www.academickids.com/encyclopedia/index.php/Contactus)

  • Clip Art (http://classroomclipart.com)
Toolbox
Personal tools