ImageGear .NET v25.0 - Updated
PNG
User Guide > File Formats and Compressions > File Formats > File Formats Reference > PNG
Full Name PNG (Portable Network Graphics)
Format ID ImGearFormats.PNG
File Extension(s) *.png
Data Type Raster Image
Data Encoding Binary
Multi-Page Support No
Alpha Channel Support Supports single alpha channel for read/write.
Metadata Update Support Page
ImageGear Platforms Support WIN32, WIN64, Unix, Unix64, .NET, .NET64, MAC

ImageGear Supported Versions

ImageGear Supported Features

ImageGear Read Support

ImageGear Write Support

ImageGear Filter Control Parameters

ImageGear .NET provides two versions of PNG filters. One is 100% "managed", and the other relies on the native codecs and is optimized for best compression and decompression performance. "Managed" filter is created by default when initializing IG common formats. Use CreatePngFormat method to switch to optimized filter. Each filter has its own set of control parameters listed below:

ImageGear "Native" Filter Control Parameters

Filter Control Parameter Type Default Value Available Values Description
Filter ImGearPngImprovingFilter Enumeration None ImGearPngImprovingFilter Enumeration values

Each raster can be passed through a filter for improving the compression of raster. Possible values for this parameter are "None", "Sub", "Up", "Average", "Paeth", and "Optimal".

  • The value "None" means that the filter is not used.
  • The values "Sub”, "Up", "Average", and "Paeth" represent four different filters.
  • The value "Optimal" enables an algorithm that selects the best result. The algorithm passes the raster through each of the four filters, and the best result is used.
Interlaced bool true true, false Determines whether the image is saved in an interlaced or non-interlaced format.
KeepAlpha bool true true, false

When loading: if this parameter is true, then alpha channel is loaded into Alpha DIB. Otherwise, the image is transformed into RGB, by compositing over the background supplied in the bKGD chunk, if it is present, or over the default background.

When saving: if this parameter is true, and alpha DIB is present, it will be written to the file. Otherwise, alpha channel will be truncated.

ImageGear "Managed" Filter Control Parameters

Filter Control Parameter Type Default Value Available Values Description
StripConfig int 0 (fixed count) 0 (fixed count),
1 (fixed buffer)
Format of PNG strip, see ImGearPNGStrip constants.
BufferSize int 0 Any int value Size of the buffer for strip if StripConfig is 1 ( fixed buffer).
StripCount int 0 Any int value Number of lines in one strip if StripConfig is 0 ( fixed count).
CompLevel int 6 (default compression) Any integer in range 0..9 Compression level. It must be between 0 (No compression) and 9 (max compression). Better compression takes more time for compression. See ImGearPNGCompLevel.
KeepAlpha bool true true, false

When loading: if this parameter is true, then alpha channel is loaded into Alpha DIB. Otherwise, the image is transformed into RGB, by compositing over the background supplied in the bKGD chunk, if it is present, or over the default background.

When saving: if this parameter is true, and alpha DIB is present, it will be written to the file.

Comments

The PNG (pronounced "Ping") format was created out of reaction to Unisys's announcement that it would begin requiring royalty fees for use of its LZW compression scheme. This was the compression scheme for the widely-used GIF format (found in Web pages and online library images).

Thomas Boutell and a host of other programmers began working to devise a new file format to eliminate the need for payment of royalty fees. The result was a file format that offers better compression than GIF, and adds features GIF doesn't offer, including truecolor, and full alpha channel and gamma correction.

The basic organization of the PNG file format utilizes storage structures known as "chunks". A chunk is a block of data that contains its own header (identifying the chunk size and type). This makes it easy for a PNG viewer to identify chunks and to skip over the ones that are not necessary.

The first entry in a PNG file is the "PNG signature" that identifies the format as PNG. The file then proceeds with a series of chunks.

The IHDR Image Header, or IHDR Chunk, contains a number of fields including the height, width, depth, color type, and compression type of the image. The only valid compression value is 0, which indicates the PNG's custom compression scheme, a deflate/inflate compression with a 32k sliding window. This is a derivative of ZZ77, the precursor to LZW. ZZ77 is the compression scheme used by pkzip software.

The "PLTE Palette Chunk" contains 1 to 256 palette entries. This is present if the type field of the header chunk is set to 3. The number of colors cannot exceed the range provided by the bit depth.

The image data is stored in "IDAT Image Data Chunks". These are subdivided into chunks whose size is usually determined by the size of the encoder's buffer. The data may be stored in "interlaced order" allowing the image to be "faded in". The data may also be interlaced. Interlacing helps the appearance of an image as it displays while being decompressed, so that it "fades in". In a non-interlaced file, the presentation of the image data begins with row 1 and works downward to the last row of data. This method of display does not allow a quick preview of the whole image. When the data is interlaced, the lines are saved and displayed out of sequence. Every fourth row is displayed first and then filled in with every remaining fourth row, until all of the lines are displayed. This allows the eye to perceive the basic subject of the whole image before it is completely displayed.

"Ancillary Chunks" are optional. They must appear before the first IDAT and after the PLTE. One chunk is the "bKGD chunk" that sets the default background color for the image. Two of the other ancillary chunks are the "hHist Chunk" or histogram chunk, and the "tEXt" chunk. The histogram chunk appears if there is a palette. It stores the frequency of each color of the palette as it occurs in the image data. If the application doesn't support all of the colors in the palette, the histogram can be used to choose a subset of colors. There may be any number of text chunks. They can vary in length from 0 to the maximum chunk size. They include the image author, copyright information, and any desired comments.

Questions about PNG can be e-mailed to: png-info@uunet.uu.net

References Used

Murray, James D. "Graphic Image Format FAQ 3-4". James D. Murray, 1994-1996.

PNG (Portable Network Graphics), tenth draft. Page 5, copyright Thomas Boutell, May 1995.

Wegner, Tim. "Coding for PNG Graphics", "PC Techniques", Feb/Mar 1996, pp 32-38.