Table of Contents

Class PNGParseBlock

Namespace
VisioForge.Core.MediaBlocks.Parsers
Assembly
VisioForge.Core.dll

Parses PNG (Portable Network Graphics) image streams for chunk validation and metadata extraction.

public class PNGParseBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals

Inheritance

Implements

Inherited Members

Extension Methods

Remarks

The PNGParseBlock processes PNG image streams, parsing the chunk-based structure to validate image integrity and extract metadata. PNG is a lossless image format widely used for web graphics, screenshots, and images requiring transparency support.

Key features: - PNG signature validation (89 50 4E 47 0D 0A 1A 0A) - Critical chunk parsing: IHDR, PLTE, IDAT, IEND - Ancillary chunk support: tEXt, iTXt, gAMA, cHRM, sRGB, etc. - CRC-32 validation for each chunk - Interlaced PNG support (Adam7 interlacing) - Color type detection (grayscale, RGB, palette, alpha) - Bit depth validation (1, 2, 4, 8, 16 bits per channel) - APNG (Animated PNG) frame detection

Common use cases: - Image processing: Validating PNG files before decoding - Streaming: Extracting PNG images from video or data streams - Metadata extraction: Reading text chunks and color space information - Format conversion: Preparing PNG data for transcoding - Web applications: Processing uploaded PNG images - Animation: Handling APNG sequences

The parser ensures PNG specification compliance (ISO/IEC 15948:2003) and handles various PNG variants including standard PNG, APNG (animated), and PNG with extensive metadata. It validates chunk ordering and detects malformed files.

Constructors

PNGParseBlock()

Initializes a new instance of the VisioForge.Core.MediaBlocks.Parsers.PNGParseBlock class.

public PNGParseBlock()

Remarks

Creates input and output pads configured for video media type. The parser will validate PNG signatures and chunk structure, supporting both standard PNG images and APNG (Animated PNG) sequences.

Properties

Input

Gets the primary input pad for receiving PNG image data.

public override MediaBlockPad Input { get; }

Property Value

MediaBlockPad

Inputs

Gets all input pads available on this block.

public override MediaBlockPad[] Inputs { get; }

Property Value

MediaBlockPad[]

Output

Gets the primary output pad that provides parsed PNG images.

public override MediaBlockPad Output { get; }

Property Value

MediaBlockPad

Outputs

Gets all output pads available on this block.

public override MediaBlockPad[] Outputs { get; }

Property Value

MediaBlockPad[]

Type

Gets the type of this media block.

public override MediaBlockType Type { get; }

Property Value

MediaBlockType

Methods

Build()

Builds and initializes the PNG parser element within the media pipeline.

public override bool Build()

Returns

bool

true if the parser was successfully created and configured; false if initialization failed or required plugins are missing.

Remarks

This method creates the GStreamer PNG parser element, initializes it within the pipeline context, and connects the input/output pads. The parser will begin validating PNG chunks once the pipeline transitions to the playing state.

CleanUp()

Performs cleanup of the parser resources and resets the build state.

public void CleanUp()

Remarks

This method disposes of the GStreamer element and resets internal state. It is called during disposal to ensure proper resource cleanup.

Dispose(bool)

Releases unmanaged and - optionally - managed resources.

protected override void Dispose(bool disposing)

Parameters

disposing bool

true to release both managed and unmanaged resources; false to release only unmanaged resources.

GetCore()

Gets the core GStreamer element wrapper.

public BaseElement GetCore()

Returns

BaseElement

The base element wrapper providing access to common GStreamer functionality.

GetElement()

Gets the underlying native GStreamer element.

public Element GetElement()

Returns

Element

The native GStreamer element instance used for PNG chunk parsing.

IsAvailable()

Determines whether the PNG parser is available in the current GStreamer installation.

public static bool IsAvailable()

Returns

bool

true if the PNG parser plugin is available; otherwise, false. This requires the GStreamer bad plugins to be installed.

Remarks

The PNG parser is provided by the GStreamer bad plugins collection. Ensure the appropriate VisioForge SDK redistribution package is included in your project.

IMediaBlockInternals.SetContext(MediaBlocksPipeline)

Sets the media pipeline context for this block.

void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)

Parameters

pipeline MediaBlocksPipeline

The media pipeline that will contain this parser block.

See Also