C# Class ImageUtility.ColorProfile

The source color for the bitmap The color profile helps converting between the original color space and the internal CIEXYZ color space used in the Bitmap class For now, only standard profiles like Linear, sRGB, Adobe RGB, ProPhoto RGB or any custom chromaticities are supported. I believe it would be overkill to include a library for parsing embedded ICC profiles...
Inheritance: IColorConverter
ファイルを表示 Open project: Patapom/GodComplex Class Usage Examples

Public Properties

Property Type Description
ILLUMINANT_A float2
ILLUMINANT_D50 float2
ILLUMINANT_D55 float2
ILLUMINANT_D65 float2
ILLUMINANT_E float2

Protected Properties

Property Type Description
m_Chromaticities Chromaticities
m_Exposure float
m_Gamma float
m_GammaCurve GAMMA_CURVE
m_InternalConverter IColorConverter
m_RGB2XYZ float4x4
m_XYZ2RGB float4x4
m_bProfileFoundInFile bool

Public Methods

Method Description
ColorProfile ( BitmapMetadata _MetaData, Bitmap _FileType ) : System

Creates the color profile from metadata embedded in the image file

ColorProfile ( Chromaticities _Chromaticities, GAMMA_CURVE _GammaCurve, float _Gamma ) : System

Creates a color profile from chromaticities

ColorProfile ( STANDARD_PROFILE _Profile ) : System

Build from a standard profile

GammaCorrect ( float c, float _ImageGamma ) : float

Applies gamma correction to the provided color

GammaUnCorrect ( float c, float _ImageGamma ) : float

Un-aplies gamma correction to the provided color

Linear2sRGB ( float c ) : float

Converts from linear space to sRGB Code borrowed from D3DX_DXGIFormatConvert.inl from the DX10 SDK

RGB2XYZ ( float4 _RGB ) : float4

Converts a RGB color to a CIEXYZ color

RGB2XYZ ( float4 _RGB, float4 _XYZ ) : void

Converts a RGB color to a CIEXYZ color

XYZ2RGB ( float4 _XYZ ) : float4

Converts a CIEXYZ color to a RGB color

XYZ2RGB ( float4 _XYZ, float4 _RGB ) : void

Converts a CIEXYZ color to a RGB color

XYZ2xyY ( float3 _XYZ ) : float3

Converts from XYZ to xyY

sRGB2Linear ( float c ) : float

Converts from sRGB to linear space Code borrowed from D3DX_DXGIFormatConvert.inl from the DX10 SDK

xyY2XYZ ( float3 _xyY ) : float3

Converts from xyY to XYZ

Protected Methods

Method Description
BuildTransformFromChroma ( bool _bCheckGammaCurveOverride ) : void

Builds the RGB<->XYZ transforms from chromaticities (refer to http://wiki.nuaj.net/index.php/Color_Transforms#XYZ_Matrices for explanations)

DumpMetaData ( BitmapMetadata _Root ) : string
DumpMetaData ( BitmapMetadata _Root, string _Tab ) : string
EnsureGamma ( GAMMA_CURVE _Curve, float _Gamma ) : bool

Ensures the current gamma curve type and value are the ones we want

EnumerateMetaData ( BitmapMetadata _Root ) : void
EnumerateMetaDataJPG ( BitmapMetadata _MetaData, bool &_bProfileFound, bool &_bGammaWasSpecified ) : void
EnumerateMetaDataPNG ( BitmapMetadata _MetaData, bool &_bProfileFound, bool &_bGammaWasSpecified ) : void
EnumerateMetaDataTIFF ( BitmapMetadata _MetaData, bool &_bProfileFound, bool &_bGammaWasSpecified ) : void
FindAttribute ( string _XMLContent, string _AttributeName ) : string

Attempts to find an XML attribute by name

FindEXIFColorProfile ( BitmapMetadata _Meta ) : bool

Attempts to find the color profile in the EXIF metadata

FindICCProfileString ( BitmapMetadata _Meta, bool &_bGammaWasSpecified ) : bool

Attempts to find the "photoshop:ICCProfile" string in the metadata dump and retrieve a known profile from it

FindPhotometricInterpretation ( BitmapMetadata _Meta, string _MetaPath ) : bool

Attempts to find the TIFF "PhotometricInterpretation" metadata

HandleEXIFColorSpace ( int _ColorSpace ) : bool

Attempts to handle a color profile from the EXIF ColorSpace tag

HandleEXIFColorSpace ( string _ColorSpace ) : bool
HandleICCProfileString ( string _ProfilName ) : bool

Attempts to handle an ICC profile by name

Method Details

BuildTransformFromChroma() protected method

Builds the RGB<->XYZ transforms from chromaticities (refer to http://wiki.nuaj.net/index.php/Color_Transforms#XYZ_Matrices for explanations)
protected BuildTransformFromChroma ( bool _bCheckGammaCurveOverride ) : void
_bCheckGammaCurveOverride bool
return void

ColorProfile() public method

Creates the color profile from metadata embedded in the image file
public ColorProfile ( BitmapMetadata _MetaData, Bitmap _FileType ) : System
_MetaData BitmapMetadata
_FileType Bitmap
return System

ColorProfile() public method

Creates a color profile from chromaticities
public ColorProfile ( Chromaticities _Chromaticities, GAMMA_CURVE _GammaCurve, float _Gamma ) : System
_Chromaticities Chromaticities The chromaticities for this profile
_GammaCurve GAMMA_CURVE The type of gamma curve to use
_Gamma float The gamma power
return System

ColorProfile() public method

Build from a standard profile
public ColorProfile ( STANDARD_PROFILE _Profile ) : System
_Profile STANDARD_PROFILE
return System

DumpMetaData() protected method

protected DumpMetaData ( BitmapMetadata _Root ) : string
_Root BitmapMetadata
return string

DumpMetaData() protected method

protected DumpMetaData ( BitmapMetadata _Root, string _Tab ) : string
_Root BitmapMetadata
_Tab string
return string

EnsureGamma() protected method

Ensures the current gamma curve type and value are the ones we want
protected EnsureGamma ( GAMMA_CURVE _Curve, float _Gamma ) : bool
_Curve GAMMA_CURVE
_Gamma float
return bool

EnumerateMetaData() protected method

protected EnumerateMetaData ( BitmapMetadata _Root ) : void
_Root BitmapMetadata
return void

EnumerateMetaDataJPG() protected method

protected EnumerateMetaDataJPG ( BitmapMetadata _MetaData, bool &_bProfileFound, bool &_bGammaWasSpecified ) : void
_MetaData BitmapMetadata
_bProfileFound bool
_bGammaWasSpecified bool
return void

EnumerateMetaDataPNG() protected method

protected EnumerateMetaDataPNG ( BitmapMetadata _MetaData, bool &_bProfileFound, bool &_bGammaWasSpecified ) : void
_MetaData BitmapMetadata
_bProfileFound bool
_bGammaWasSpecified bool
return void

EnumerateMetaDataTIFF() protected method

protected EnumerateMetaDataTIFF ( BitmapMetadata _MetaData, bool &_bProfileFound, bool &_bGammaWasSpecified ) : void
_MetaData BitmapMetadata
_bProfileFound bool
_bGammaWasSpecified bool
return void

FindAttribute() protected method

Attempts to find an XML attribute by name
protected FindAttribute ( string _XMLContent, string _AttributeName ) : string
_XMLContent string
_AttributeName string
return string

FindEXIFColorProfile() protected method

Attempts to find the color profile in the EXIF metadata
protected FindEXIFColorProfile ( BitmapMetadata _Meta ) : bool
_Meta BitmapMetadata
return bool

FindICCProfileString() protected method

Attempts to find the "photoshop:ICCProfile" string in the metadata dump and retrieve a known profile from it
protected FindICCProfileString ( BitmapMetadata _Meta, bool &_bGammaWasSpecified ) : bool
_Meta BitmapMetadata
_bGammaWasSpecified bool
return bool

FindPhotometricInterpretation() protected method

Attempts to find the TIFF "PhotometricInterpretation" metadata
protected FindPhotometricInterpretation ( BitmapMetadata _Meta, string _MetaPath ) : bool
_Meta BitmapMetadata
_MetaPath string
return bool

GammaCorrect() public static method

Applies gamma correction to the provided color
public static GammaCorrect ( float c, float _ImageGamma ) : float
c float The color to gamma-correct
_ImageGamma float The gamma correction the image was encoded with (JPEG is 2.2 for example, if not sure use 1.0)
return float

GammaUnCorrect() public static method

Un-aplies gamma correction to the provided color
public static GammaUnCorrect ( float c, float _ImageGamma ) : float
c float The color to gamma-uncorrect
_ImageGamma float The gamma correction the image was encoded with (JPEG is 2.2 for example, if not sure use 1.0)
return float

HandleEXIFColorSpace() protected method

Attempts to handle a color profile from the EXIF ColorSpace tag
protected HandleEXIFColorSpace ( int _ColorSpace ) : bool
_ColorSpace int
return bool

HandleEXIFColorSpace() protected method

protected HandleEXIFColorSpace ( string _ColorSpace ) : bool
_ColorSpace string
return bool

HandleICCProfileString() protected method

Attempts to handle an ICC profile by name
protected HandleICCProfileString ( string _ProfilName ) : bool
_ProfilName string
return bool

Linear2sRGB() public static method

Converts from linear space to sRGB Code borrowed from D3DX_DXGIFormatConvert.inl from the DX10 SDK
public static Linear2sRGB ( float c ) : float
c float
return float

RGB2XYZ() public method

Converts a RGB color to a CIEXYZ color
public RGB2XYZ ( float4 _RGB ) : float4
_RGB float4
return float4

RGB2XYZ() public method

Converts a RGB color to a CIEXYZ color
public RGB2XYZ ( float4 _RGB, float4 _XYZ ) : void
_RGB float4
_XYZ float4
return void

XYZ2RGB() public method

Converts a CIEXYZ color to a RGB color
public XYZ2RGB ( float4 _XYZ ) : float4
_XYZ float4
return float4

XYZ2RGB() public method

Converts a CIEXYZ color to a RGB color
public XYZ2RGB ( float4 _XYZ, float4 _RGB ) : void
_XYZ float4
_RGB float4
return void

XYZ2xyY() public static method

Converts from XYZ to xyY
public static XYZ2xyY ( float3 _XYZ ) : float3
_XYZ float3
return float3

sRGB2Linear() public static method

Converts from sRGB to linear space Code borrowed from D3DX_DXGIFormatConvert.inl from the DX10 SDK
public static sRGB2Linear ( float c ) : float
c float
return float

xyY2XYZ() public static method

Converts from xyY to XYZ
public static xyY2XYZ ( float3 _xyY ) : float3
_xyY float3
return float3

Property Details

ILLUMINANT_A public_oe static_oe property

public static float2,ImageUtility ILLUMINANT_A
return float2

ILLUMINANT_D50 public_oe static_oe property

public static float2,ImageUtility ILLUMINANT_D50
return float2

ILLUMINANT_D55 public_oe static_oe property

public static float2,ImageUtility ILLUMINANT_D55
return float2

ILLUMINANT_D65 public_oe static_oe property

public static float2,ImageUtility ILLUMINANT_D65
return float2

ILLUMINANT_E public_oe static_oe property

public static float2,ImageUtility ILLUMINANT_E
return float2

m_Chromaticities protected_oe property

protected Chromaticities m_Chromaticities
return Chromaticities

m_Exposure protected_oe property

protected float m_Exposure
return float

m_Gamma protected_oe property

protected float m_Gamma
return float

m_GammaCurve protected_oe property

protected GAMMA_CURVE m_GammaCurve
return GAMMA_CURVE

m_InternalConverter protected_oe property

protected IColorConverter m_InternalConverter
return IColorConverter

m_RGB2XYZ protected_oe property

protected float4x4,ImageUtility m_RGB2XYZ
return float4x4

m_XYZ2RGB protected_oe property

protected float4x4,ImageUtility m_XYZ2RGB
return float4x4

m_bProfileFoundInFile protected_oe property

protected bool m_bProfileFoundInFile
return bool