Core Optical, Inc.
SourceData Constructor (BitmapSource, GammaEncoding, Boolean)Industrial Strength, Scientific Grade
Creates a new SourceData object to encapsulate the data contained in the OnlineBitmapSource object.

Namespace: PrecisionImage
Assembly: PrecisionImage (in PrecisionImage.dll) Version: (

public SourceData(
	BitmapSource sourceImage,
	GammaEncoding gammaEncoding = GammaEncoding.sRGB,
	bool NormalizeValues = true


Type: OnlineSystem.Windows.Media.Imaging BitmapSource
The OnlineBitmapSource object containing the source data to encapsulate.
gammaEncoding (Optional)
Type: PrecisionImage GammaEncoding
A GammaEncoding enumeration specifying the gamma encoding of the source image. This parameter is optional. The default is GammaEncoding.sRGB
NormalizeValues (Optional)
Type: OnlineSystem Boolean
A OnlineBoolean type specifying whether or not the image values are to be normalized to the range (0.0 - 1.0) prior to storage. Default value is True.

OnlineSystem ArgumentException Thrown if the sourceImage is not completely downloaded prior to constructor call.

When invoking the SourceData constructor, a gamma encoding type can be specified in addition to the source image. This guarantees that the input pixels contained in the source image are properly converted to linearized RGB tristimulus values prior to storage in the SourceData object. If the source image gamma encoding is declared as sRGB, the values are normalized within the range of [0.0 - 1.0] and linearized assuming a forward gamma encoding of (1/2.4) with an initial linear ramp segment according to the ITUR BT.709 standard. If None is specified, the values are simply normalized and stored. The default behavior is to assume sRGB when no encoding type is specified.

The removal of gamma encoding is particularly important if images are to be properly converted to alternate color spaces for processing at some point. If color-space conversion is not included in the processing work-flow the removal of the gamma-encoding is less important and often not necessary.


The following demonstrates the instantiation of a SourceData object.
using PrecisionImage;

// Create the BitmapSource object: 
Uri imageUri             = new Uri("MyImage.bmp", UriKind.Relative);
BmpBitmapDecoder decoder = new BmpBitmapDecoder(imageUri, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
BitmapSource sourceImage = decoder.Frames[0];

// Instantiate SourceData object and load image data using default sRGB gamma encoding: 
SourceData imageData = new SourceData(sourceImage);

// Alternatively, if image is known to be linear (no gamma encoding) instantiate as follows: 
SourceData imageData = new SourceData(sourceImage, GammaEncoding.None);
See Also