Portable Maps or AnyMaps (PNM) is collective name refering to family of very similar raster file formats. Their format is very simple and most of them contain just two-byte Id, Width, Height, and raster data. Data can be stored in binary format or in text format (whick produces very large files). Most formats can store images with 8 or 16 bit channels but not all viewer and editor programs support 16 bit PNMs (or binary ones). Imaging supports five PNM formats where PBM, PGM, and PPM are quite common but PAM and PFM are somewhat rare.
PBM - Portable Bit Map
stores monochrome 1bit images. Raster data
can be saved as text or binary data. Either way value of 0 represents white
and 1 is black. As Imaging does not have support for 1bit data formats
PBM images can be loaded but not saved. Loaded images are returned in
ifGray8 format (witch pixel values scaled from 1bit to 8bit).
PBM - Portable Gray Map
stores grayscale 8bit or 16bit images. Raster data can be
saved as text or binary data.
PPM - Portable Pixel Map
stores RGB images with 8bit or 16bit channels.
Raster data can be saved as text or binary data.
PAM - Portable Arbitrary Map
is more complex format that can store image data formats
of PBM, PGM, and PPM formats with optional alpha channel. Raster data
can be stored only in binary format.
PFM - Portable Float Map
is unofficial extension of PNM format family which
can store images with floating point pixels. Raster data is saved in
binary format as array of IEEE 32 bit floating point numbers. One channel
or RGB images are supported by PFM format (so no alpha).
There is a complete list of data formats supported by PNM file formats, their Imaging equivalents, and load/cave capability.
Portable Maps File Format SupportFormat | TImageFormat equivalent | Loading | Saving | Supported By Map Format |
---|---|---|---|---|
1 bit mono |
ifGray8
| Yes | No | PBM, PAM |
1bit mono + alpha |
ifA8Gray8
| Yes | No | PAM |
8 bit grayscale |
ifGray8
| Yes | Yes | PGM, PAM |
16 bit grayscale |
ifGray16
| Yes | Yes | PGM, PAM |
8 bit grayscale + alpha |
ifA8Gray8
| Yes | Yes | PAM |
16 bit grayscale + alpha |
ifA16Gray16
| Yes | Yes | PAM |
24 bit RGB |
ifR8G8B8
| Yes | Yes | PPM, PAM |
48 bit RGB |
ifR16G16B16
| Yes | Yes | PPM, PAM |
32 bit ARGB |
ifA8R8G8B8
| Yes | Yes | PAM |
64 bit ARGB |
ifA16R16G16B16
| Yes | Yes | PAM |
32 bit R FP32 |
ifR32F
| Yes | Yes | PFM |
96 bit RGB FP32 |
ifA32R32G32B32F
| Yes | Yes | PFM |
When working with PNM files you can find useful some options which can be set by SetOption function and their current values can be get by GetOption function. Or you can set them by modifying properties of TPGMFileFormat and TPPMFileFormat classes.
Options Related to PNM FilesOptionId | Allowed Values | Usage |
---|---|---|
ImagingPGMSaveBinary | 0 (false) or 1 (true) | If set to True PGM images will be saved in binary format, otherwise they will be saved in text format (which could result in 5-10x bigger file). Default value is 1 (true). |
ImagingPPMSaveBinary | 0 (false) or 1 (true) | If set to True PPM images will be saved in binary format, otherwise they will be saved in text format (which could result in 5-10x bigger file). Default value is 1 (true). |