Table of Contents

Method Gather

Namespace
PaintDotNet.Imaging
Assembly
PaintDotNet.Windows.Core.dll

Gather(IBitmapSource<ColorRgba128Float>, double, float, bool)

Scans source in a single pass to gather the luminance statistics needed to tone-map it. The image is measured in horizontal bands; the per-band measurement work is spread across threads, while reads from source are governed by allowMultithreadedCopyPixels.

public static HdrToneMapStatistics Gather(IBitmapSource<ColorRgba128Float> source, double peakPercentile = 0.9999, float sceneReferredSdrWhiteLevelNits = 80, bool allowMultithreadedCopyPixels = false)

Parameters

source IBitmapSource<ColorRgba128Float>

The linear HDR source to analyze.

peakPercentile double

The percentile of the per-pixel max(r, g, b) distribution to report as the peak. Using a high percentile rather than the absolute maximum keeps a few stray specular/hot pixels from forcing an overly aggressive roll-off. Defaults to the 99.99th percentile.

sceneReferredSdrWhiteLevelNits float

The luminance, in cd/m² (nits), that the source's linear 1.0 represents, used to express the results in nits. Defaults to the scRGB scene-referred SDR white level (80 nits).

allowMultithreadedCopyPixels bool

Whether it is safe to call CopyPixels(void*, int, uint, in RectInt32?) on source concurrently and out of order. Pass true only when the source is known to support it — e.g. a materialized in-memory bitmap. When false (the default), reads are serialized to one at a time and issued strictly top to bottom, which is required for sources that are neither thread-safe nor random-access (most notably a streaming IBitmapFrameDecode, where out-of-order reads force expensive re-decoding). The per-band measurement still runs in parallel in either case, since it touches only the already-copied band, never the source.

Returns

HdrToneMapStatistics

The gathered statistics, in nits (cd/m²).