Table of Contents

Class PNGEncoderBlock

Namespace
VisioForge.Core.MediaBlocks.VideoEncoders
Assembly
VisioForge.Core.dll

PNG encoder block for efficient PNG image compression with high quality and advanced features. This block provides PNG encoding capabilities using the rspngenc (Rust PNG encoder) GStreamer element offering superior compression efficiency and performance compared to traditional PNG encoders. Features configurable compression levels, filter types, and metadata handling.

Key features:

  • Rust-based implementation for optimal performance
  • Configurable compression levels (0-9)
  • Multiple filter types for optimal compression
  • PNG metadata and info chunk handling
  • Lossless compression maintaining image quality
  • Support for transparency and alpha channels
  • Efficient memory usage and processing

Common use cases:

  • High-quality image archival and storage
  • Lossless video frame extraction
  • Scientific and medical image processing
  • Web content requiring transparency
  • Screenshot and screen capture applications
  • Digital photography workflows
  • Document scanning and processing

The PNG format provides excellent compression for images with sharp edges, text, and areas of solid color while preserving perfect image quality. Consider JPEG for photographic content where slight quality loss is acceptable. Implements the VisioForge.Core.MediaBlocks.MediaBlock. Implements the VisioForge.Core.MediaBlocks.IMediaBlockInternals. Implements the IDisposable.

public class PNGEncoderBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals

Inheritance

Implements

Inherited Members

Extension Methods

Constructors

PNGEncoderBlock(PNGEncoderSettings)

Initializes a new instance of the VisioForge.Core.MediaBlocks.VideoEncoders.PNGEncoderBlock class. Creates a PNG encoder block with the specified compression and quality settings.

public PNGEncoderBlock(PNGEncoderSettings settings)

Parameters

settings PNGEncoderSettings

The PNG encoder configuration including compression level, filter type, and metadata options.

PNGEncoderBlock(PNGEncoderSettings, string)

Initializes a new instance of the VisioForge.Core.MediaBlocks.VideoEncoders.PNGEncoderBlock class. Creates a PNG encoder block with the specified compression and quality settings and output filename.

public PNGEncoderBlock(PNGEncoderSettings settings, string filename)

Parameters

settings PNGEncoderSettings

The PNG encoder configuration including compression level, filter type, and metadata options.

filename string

The output file path where the PNG will be written.

Properties

Input

Gets the primary input pad for receiving raw video frames.

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 for PNG data stream.

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[]

Settings

Gets the PNG encoder configuration settings.

public PNGEncoderSettings Settings { get; }

Property Value

PNGEncoderSettings

Type

Gets the block type identifier for the PNG encoder.

public override MediaBlockType Type { get; }

Property Value

MediaBlockType

Methods

Build()

Builds and initializes the PNG encoder pipeline. Creates the PNG encoder with specified quality settings and optional file output, configuring it for high-quality image compression.

public override bool Build()

Returns

bool

true if the encoder was successfully built; false if initialization failed.

CleanUp()

Releases all resources and performs cleanup operations for this PNG encoder block. This method disposes of GStreamer elements, releases memory, and ensures proper shutdown of the block. Called automatically during pipeline teardown.

public void CleanUp()

Dispose(bool)

Releases all resources used by the PNG encoder block. This includes disposing of GStreamer elements and clearing internal references.

protected override void Dispose(bool disposing)

Parameters

disposing bool

True if disposing managed resources; false if called from finalizer.

GetCore()

Gets the core GStreamer element wrapper for advanced configuration.

public BaseElement GetCore()

Returns

BaseElement

The BaseElement wrapper for the PNG encoder.

GetElement()

Gets the underlying GStreamer PNG encoder element.

public Element GetElement()

Returns

Element

The native GStreamer element performing PNG encoding.

GetFilenameOrURL()

Gets the output destination filename or URL where the media data will be written. This could be a local file path, network URL, or device identifier depending on the sink type.

public string GetFilenameOrURL()

Returns

string

The filename, URL, or destination identifier as a string.

IsAvailable()

Checks if the PNG encoder element is available in the current GStreamer installation. This method verifies that the rspngenc element can be found and instantiated.

public static bool IsAvailable()

Returns

bool

true if the PNG encoder is available and can be used; otherwise, false.

SetContext(MediaBlocksPipeline)

Associates this PNG encoder block with a pipeline and initializes its internal context. This method is called internally when the block is added to a pipeline.

public void SetContext(MediaBlocksPipeline pipeline)

Parameters

pipeline MediaBlocksPipeline

The MediaBlocksPipeline instance that will manage this block.

SetFilenameOrURL(string)

Sets the output destination filename or URL where the media data should be written. This configures where the sink block will send its processed media data.

public void SetFilenameOrURL(string value)

Parameters

value string

The filename, URL, or destination identifier to set.

SetPipelineContext(BlockPipelineContext)

Sets the media pipeline context for this PNG encoder block.

public void SetPipelineContext(BlockPipelineContext ctx)

Parameters

ctx BlockPipelineContext

The pipeline context.

SyncStateWithParent()

Synchronizes the state of all internal GStreamer elements with their parent pipeline. This ensures proper state transitions during pipeline start, pause, and stop operations.

public void SyncStateWithParent()

UpdateFilename(string)

Updates the output filename for the PNG encoder. This method allows changing the output destination during operation, though it requires pipeline restart to take effect.

public void UpdateFilename(string filename)

Parameters

filename string

The new output filename for PNG data.

See Also