Skip to main content
.NET Framework Class Library
ColorContext Class

Represents the International Color Consortium (ICC) or Image Color Management (ICM) color profile that is associated with a bitmap image.

Inheritance Hierarchy
SystemObject
  System.Windows.MediaColorContext

Namespace:   System.Windows.Media
Assembly:  PresentationCore (in PresentationCore.dll)
Syntax
Public Class ColorContext
public class ColorContext
public ref class ColorContext
type ColorContext =  class end
public class ColorContext

The ColorContext type exposes the following members.

Constructors
  NameDescription
Public method ColorContext(PixelFormat)Initializes a new instance of ColorContext with the standard color profile (sRGB or RGB ) that most closely matches the supplied PixelFormat.
Public method ColorContext(Uri)Initializes a new instance of ColorContext with the International Color Consortium (ICC) or Image Color Management (ICM) color profile located at a given Uri.
Top
Properties
  NameDescription
Public property ProfileUriGets a Uri that represents the location of a International Color Consortium (ICC) or Image Color Management (ICM) color profile.
Top
Methods
  NameDescription
Public method EqualsDetermines whether an Object is equal to an instance of ColorContext. (Overrides ObjectEquals(Object).)
Protected method FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCodeGets the hash code for this instance of ColorContext. (Overrides ObjectGetHashCode.)
Public method GetTypeGets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public method OpenProfileStreamReturns a readable Stream of raw color profile data.
Public method ToStringReturns a string that represents the current object. (Inherited from Object.)
Top
Operators
  NameDescription
Public operator Static member EqualityOperates on two instances of ColorContext to determine equality.
Public operator Static member InequalityOperates on two instances of ColorContext to determine that they are not equal.
Top
Remarks

The supported standard color spaces are sRGB, ScRGB, RGB, CMYK, Gray, Multichannel, and unknown.

Examples

The following code example demonstrates how to get the color profile that is associated with a bitmap image.

Dim myColorConvertedBitmap As New ColorConvertedBitmap()
myColorConvertedBitmap.BeginInit()
myColorConvertedBitmap.SourceColorContext = myBitmapSourceFrame2.ColorContexts(0)
myColorConvertedBitmap.Source = myBitmapSource2
myColorConvertedBitmap.DestinationFormat = PixelFormats.Pbgra32
myColorConvertedBitmap.DestinationColorContext = New ColorContext(PixelFormats.Bgra32)
myColorConvertedBitmap.EndInit()
ColorConvertedBitmap myColorConvertedBitmap = new ColorConvertedBitmap();
myColorConvertedBitmap.BeginInit();
myColorConvertedBitmap.SourceColorContext = myBitmapSourceFrame2.ColorContexts[0];
myColorConvertedBitmap.Source = myBitmapSource2;
myColorConvertedBitmap.DestinationFormat = PixelFormats.Pbgra32;
myColorConvertedBitmap.DestinationColorContext = new ColorContext(PixelFormats.Bgra32);
myColorConvertedBitmap.EndInit();
Version Information

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.