ImageGear for C and C++ on Windows v19.10 - Updated
PGM
User Guide > File Formats and Compressions > File Formats > File Formats Reference > PGM

Full Name PGM (Portable Graymap File Format)
Format ID IG_FORMAT_PBM = 28 (see the Note below)
File Extension(s) *.pgm
Data Type Raster Image
Data Encoding Binary
Color Profile Support No
Multi-Page Support No
Alpha Channel Support No
ImageGear Platforms Support WIN32, WIN64, Unix, Unix64, .NET, .NET64, MAC
ImageGear supports PGM file format via its IG_FORMAT_PBM format filter. Use IG_FORMAT_PBM to save grayscale images to PGM format.

ImageGear Supported Versions:

October 1991 - last release

ImageGear Supported Features:

ImageGear Read Support:

ImageGear Write Support:

ImageGear Filter Control Parameters:

None

Comments:

This format quickly and easily transfers grayscale bitmap images. This format, as well as PBM, PNM, and PPM, are at the core of a set of utility programs also written by Jef Poskanzer. These formats serve as an intermediary storage methods for the conversion of other file formats.

The Portable Graymap File Format structure is very simple. It begins with a short ASCII header that contains the file type identifier (magic number), the width and height of the image, a "maximum gray value", and perhaps a comment line identifying the filename. The bitmap data follows white space (usually a carriage return). The number of pixels is equal to width * height. A pixel value of 0 indicates black, and a "maximum gray value" is equivalent to white.

The magic number of the header can have one of two values: either P2 or P5. P2 indicates that the bitmap data is read as ASCII decimal values. P5 indicates that the bitmap data is stored as plain bytes. This makes for a smaller and faster-to-read file.

If the maximum gray value does not exceed 255 (28 = 256 gray values from 0 to 255), each pixel is represented by a 8-bit sample. ImageGear loads such images as 8-bit grayscale. Otherwise, each pixel is represented by a 16-bit sample. ImageGear loads these images as 16-bit grayscale.

See Also:

PPM, PBM, PNM

References Used

Kay, David C. and John R. Levine. Graphics File Formats, 2nd ed. Windcrest /McGraw-Hill, 1995.

PGM Specification by Jef Poskanzer, copyright © 1989, 1991.