ImageGear for Java User Guide > ImageGear Imaging Formats Reference > ImageGear Supported File Formats Reference > PGM |
Full Name | PGM (Portable Graymap File Format) |
Format ID | ImGearFormats.PBM (see the Note below) |
File Extension(s) | *.pgm |
Data Type | Raster Image |
Data Encoding | Binary |
IG Multipage Support | No |
IG Alpha Channel Support | No |
IG Platforms Support | WIN32, WIN64, Linux32, Linux64, MAC32, MAC64 |
ImageGear supports PGM file format via its PBM format filter. Use ImGearFormats.PBM to save images to PGM format. |
October 1991 - last release
None
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.
Kay, David C. and John R. Levine. Graphics File Formats, 2nd ed. Windcrest /McGraw-Hill, 1995.
PGM Specification by Jef Poskanzer, copyright A 1989, 1991.