Class GPUVideoEffectContrast
- Namespace
- VisioForge.Core.Types.VideoEffects
- Assembly
- VisioForge.Core.dll
Represents a GPU-accelerated contrast adjustment effect that compresses the tonal range around middle gray using DirectX hardware acceleration.
public class GPUVideoEffectContrast : GPUVideoEffect, IGPUVideoEffectContrast, IGPUVideoEffectInheritance
Implements
Inherited Members
Remarks
Available in: VideoCaptureCore, MediaPlayerCore, VideoEditCore (Windows only)
GPU-accelerated version using DirectX. Significantly faster than CPU equivalent for real-time processing of high-resolution video streams.
The contrast effect adjusts the difference between light and dark areas around middle gray. The shader applies output = (input - 0.5) * (value / 255) + 0.5 to each channel, so 255 leaves the image unchanged and lower values flatten it, reaching flat gray at 0. Note that this scale is the opposite of the CPU VisioForge.Core.Types.VideoEffects.VideoEffectContrast, where 0 is neutral. The effect uses DirectX compute shaders, enabling real-time processing with minimal CPU overhead.
Common use cases include: deliberately flattening footage for washed-out or faded looks, reducing contrast for vintage/retro effects, matching clips with different contrast before grading, taming over-contrasty captures, and creating a low-contrast base behind titles or graphics.
Performance characteristics: GPU acceleration provides near-zero overhead, processing 4K frames in under 1ms on modern GPUs. The operation is compute-efficient and can be chained with other effects without significant performance degradation. Ideal for real-time adjustment during live capture or playback.
Technical notes: within the documented 0-255 range the factor is 1 at 255 and never exceeds it, so the effect can only reduce contrast. The value is not clamped: keep it in 0-255, since a higher value makes the shader over-sharpen the difference instead of flattening it. To raise contrast use the CPU VisioForge.Core.Types.VideoEffects.VideoEffectContrast. The effect operates independently on each RGB channel, preserving color hue while adjusting luminance relationships.
Cross-reference to CPU equivalent: See VisioForge.Core.Types.VideoEffects.VideoEffectContrast for CPU-based alternative with animation support.
Constructors
GPUVideoEffectContrast(bool, int, string, TimeSpan, TimeSpan)
Initializes a new instance of the VisioForge.Core.Types.VideoEffects.GPUVideoEffectContrast class with specified parameters.
public GPUVideoEffectContrast(bool enabled, int value, string name = "Contrast", TimeSpan startTime = default, TimeSpan stopTime = default)Parameters
enabledbool-
Whether the effect is enabled. Set to
trueto apply immediately,falseto create in disabled state. valueint-
Contrast adjustment value (0-255, 255 = no change). Values below 255 flatten the image.
namestring-
Optional effect name for identification and retrieval. Default is "Contrast".
startTimeTimeSpan-
Start time for timed effects. Default is zero (apply from beginning).
stopTimeTimeSpan-
Stop time for timed effects. Default is zero (apply until end).
Remarks
When both start and stop times are zero, the effect applies for the entire video duration. The effect type is automatically set to VisioForge.Core.Types.VideoEffects.GPUVideoEffectType.Contrast. The value fades the image toward middle gray: values just below 255 flatten it slightly, values near 0 flatten it almost completely.
Properties
Value
Gets or sets the contrast adjustment value (0-255, 255 = no change).
public int Value { get; set; }Property Value
Remarks
Controls the tonal range compression. A value of 255 leaves the image unchanged (factor 1); lower values compress the range, and 0 produces a flat gray image.
Value ranges: 0 = Flat gray, 1-127 = Strongly reduced contrast, 128-254 = Reduced contrast, with the effect fading out as the value approaches 255 = No change (original contrast).
Methods
GetEffectType()
Gets the specific type of this GPU video effect.
public GPUVideoEffectType GetEffectType()Returns
- GPUVideoEffectType
-
Returns VisioForge.Core.Types.VideoEffects.GPUVideoEffectType.Contrast to identify this as a GPU-accelerated contrast effect.
Remarks
Used by the video processing pipeline to select the appropriate DirectX shader for contrast adjustment processing.