Table of Contents

Class VideoEffectContrast

Namespace
VisioForge.Core.Types.VideoEffects
Assembly
VisioForge.Core.dll

Represents a contrast adjustment effect that modifies the difference between light and dark areas in the video.

public class VideoEffectContrast : VideoEffect, IVideoEffectContrast, IVideoEffect

Inheritance

Implements

Inherited Members

Remarks

Contrast adjustment increases or decreases the visual separation between bright and dark regions of the image. Increasing contrast makes bright areas brighter and dark areas darker, creating more dramatic images. Decreasing contrast reduces the tonal range, creating flatter, less dramatic images.

This effect supports animated contrast changes through the VisioForge.Core.Types.VideoEffects.VideoEffectContrast.ValueStop property, which enables smooth transitions from one contrast level to another over the effect duration.

Contrast works on each RGB channel around the mid-point 128: newChannel = (channel - 128) * factor + 128, where factor = 259 * (value + 255) / (255 * (259 - value)). The factor is 1 at value 0, so the image is left unchanged, and grows with the value.

A value of 0 leaves the image unchanged; higher values expand the tonal range, and values near 255 produce an extreme, heavily clipped image.

For GPU-accelerated contrast adjustment with better performance on high-resolution video, consider using VisioForge.Core.Types.VideoEffects.GPUVideoEffectContrast. Note that the GPU effect uses the opposite scale: 255 leaves the image unchanged there, and lower values flatten it.

Constructors

VideoEffectContrast(bool, int, int, string, TimeSpan, TimeSpan)

Initializes a new instance of the VisioForge.Core.Types.VideoEffects.VideoEffectContrast class with specified parameters.

public VideoEffectContrast(bool enabled, int value, int valueStop = 0, string name = "Contrast", TimeSpan startTime = default, TimeSpan stopTime = default)

Parameters

enabled bool

true to enable the effect immediately; false to create the effect in a disabled state.

value int

The initial contrast value (0-255). 0 leaves the image unchanged; higher values increase contrast.

valueStop int

The ending contrast value for animated transitions (0-255). Default is 0 (no animation). When non-zero and different from value, creates a smooth transition.

name string

An optional name identifier for this effect instance. Default is "Contrast".

startTime TimeSpan

The time at which the effect should start being applied. Default is zero (from beginning).

stopTime TimeSpan

The time at which the effect should stop being applied. Default is zero (until end). Required when using valueStop to define the animation duration.

Remarks

For static contrast adjustment, only set the value parameter. For animated contrast changes, set both value and valueStop along with appropriate startTime and stopTime values.

Properties

Value

Gets or sets the contrast adjustment value.

public int Value { get; set; }

Property Value

int

Remarks

The contrast value controls the tonal range of the image:

  • 0: No change (original contrast)
  • 1-127: Mild to moderate increase
  • 128-199: Strong increase (128 is already roughly 3x)
  • 200-255: Extreme (heavy clipping)

When combined with VisioForge.Core.Types.VideoEffects.VideoEffectContrast.ValueStop, the contrast will smoothly animate from this value to the stop value over the effect's time range.

Extreme contrast values may cause loss of detail in highlights or shadows due to clipping at the minimum (0) or maximum (255) color values.

ValueStop

Gets or sets the ending contrast value for animated contrast transitions.

public int ValueStop { get; set; }

Property Value

int

Remarks

When VisioForge.Core.Types.VideoEffects.VideoEffectContrast.ValueStop is set to a non-zero value different from VisioForge.Core.Types.VideoEffects.VideoEffectContrast.Value, the contrast will smoothly transition from VisioForge.Core.Types.VideoEffects.VideoEffectContrast.Value to this value over the time period defined by VisioForge.Core.Types.VideoEffects.VideoEffect.StartTime and VisioForge.Core.Types.VideoEffects.VideoEffect.StopTime.

If set to 0 (default), the contrast remains constant at VisioForge.Core.Types.VideoEffects.VideoEffectContrast.Value throughout the effect.

This enables creating dynamic contrast effects such as gradual enhancement or reduction, fade-in/fade-out effects, or dramatic reveals.

Because 0 means "no animation", a transition that ends at the unchanged contrast cannot be expressed by a single effect instance; animate to a small non-zero value instead.

Methods

GetEffectType()

Gets the specific type of this video effect.

public VideoEffectType GetEffectType()

Returns

VideoEffectType

Returns VisioForge.Core.Types.VideoEffects.VideoEffectType.Contrast to identify this as a contrast adjustment effect.

Remarks

This method is used by the video processing pipeline to route the effect to the appropriate contrast adjustment processor.