C# 클래스 ImageUtility.Bitmap

The Bitmap class should be used to replace the standard System.Drawing.Bitmap The big advantage of the Bitmap class is to accurately read back the color profile and gamma correction data stored in the image's metadata so that, internally, the image is stored: • As device-independent CIE XYZ (http://en.wikipedia.org/wiki/CIE_1931_color_space) format, our Profile Connection Space • In linear space (i.e. no gamma curve is applied) • NOT pre-multiplied alpha (you can later re-pre-multiply if needed) This helps to ensure that whatever the source image format stored on disk, you always deal with a uniformized image internally. Later, you can cast from the CIE XYZ device-independent format into any number of pre-defined texture profiles: • sRGB or Linear space textures (for 8bits per component images only) • Compressed (BC1-BC5) or uncompressed (for 8bits per component images only) • 8-, 16-, 16F- 32- or 32F-bits per component • Pre-multiplied alpha or not The following image formats are currently supported: • JPG • PNG • TIFF • TGA • BMP • GIF • HDR • Any RAW camera format supported by the LibRaw library
The Bitmap class has been tested with various formats, various bit depths and color profiles all created from Adobe Photoshop CS4 using the "Save As" dialog and the "Save for Web & Devices" dialog box. In a general manner, you should NOT use the latter save option but rather select your working color profile from the "Edit > Color Settings" menu, then save your files and make sure you tick the "ICC Profile" checkbox using the DEFAULT save file dialog box to embed that profile in the image.
상속: IDisposable
파일 보기 프로젝트 열기: Patapom/GodComplex 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
m_Aperture float
m_Bitmap ].float4[
m_ColorProfile ColorProfile
m_FocalLength float
m_Height int
m_ISOSpeed float
m_ShutterSpeed float
m_Type FILE_TYPE
m_Width int
m_bHasAlpha bool
m_bHasValidShotInfo bool
ms_ConvertContent2XYZ bool
ms_ReadContent bool

공개 메소드들

메소드 설명
BilinearSample ( float X, float Y ) : float4

Performs bilinear sampling of the XYZ content

Bitmap ( System _ImageFileName ) : System

Creates a bitmap from a file

Bitmap ( System _ImageFileName, ColorProfile _ProfileOverride ) : System

Creates a bitmap from a file

Bitmap ( System _ImageStream, FILE_TYPE _FileType ) : System

Creates a bitmap from a stream

Bitmap ( System _ImageStream, FILE_TYPE _FileType, ColorProfile _ProfileOverride ) : System

Creates a bitmap from a stream

Bitmap ( System _ImageStream, System _ImageFileNameName ) : System

Creates a bitmap from a stream

Bitmap ( System _ImageStream, System _ImageFileNameName, ColorProfile _ProfileOverride ) : System

Creates a bitmap from a stream

Bitmap ( byte _ImageFileContent, FILE_TYPE _FileType ) : System

Creates a bitmap from memory

Bitmap ( byte _ImageFileContent, FILE_TYPE _FileType, ColorProfile _ProfileOverride ) : System

Creates a bitmap from memory

Bitmap ( byte _ImageFileContent, System _ImageFileNameName ) : System

Creates a bitmap from memory

Bitmap ( byte _ImageFileContent, System _ImageFileNameName, ColorProfile _ProfileOverride ) : System

Creates a bitmap from memory

Bitmap ( int _Width, int _Height, ColorProfile _Profile ) : System

Manual creation

DecodeRGBEImage ( PF_RGBE _Source, bool _bSourceIsXYZ, bool _bTargetNeedsXYZ, ColorProfile _ColorProfile ) : ].float4[

Decodes a RGBE formatted image into a plain floating-point image

DecodeRGBEImage ( PF_RGBE _Source, bool _bSourceIsXYZ, float4 _Target, bool _bTargetNeedsXYZ, ColorProfile _ColorProfile ) : void

Decodes a RGBE formatted image into a plain floating-point image

Dispose ( ) : void
GetFileType ( System _ImageFileNameName ) : FILE_TYPE

Retrieves the image file type based on the image file name

Load ( System _ImageFileName, FILE_TYPE _FileType ) : void

Loads from disk

Load ( System _ImageFileName, FILE_TYPE _FileType, ColorProfile _ProfileOverride ) : void
Load ( byte _ImageFileContent, FILE_TYPE _FileType ) : void

Actual load from a byte[] in memory

Load ( byte _ImageFileContent, FILE_TYPE _FileType, ColorProfile _ProfileOverride ) : void
LoadAndDecodeHDRFormat ( byte _HDRFormatBinary, bool _bTargetNeedsXYZ, ColorProfile _ProfileOverride, ColorProfile &_ColorProfile ) : ].float4[

Loads a bitmap in .HDR format into a float4 array directly useable by the image constructor

LoadBitmap ( System _Bitmap, int &_Width, int &_Height ) : byte[]

Loads a System.Drawing.Bitmap into a byte[] containing RGBARGBARG... pixels

LoadHDRFormat ( byte _HDRFormatBinary, ColorProfile _ProfileOverride, bool &_bIsXYZ, ColorProfile &_ColorProfile ) : ].PF_RGBE[

Loads a bitmap in .HDR format into a RGBE array

Save ( System _FileName ) : void

Save to a file

Save ( System _Stream, FILE_TYPE _FileType, FORMAT_FLAGS _Parms, FormatEncoderOptions _Options ) : void

Save to a stream

Save ( System _FileName, FORMAT_FLAGS _Parms ) : void
Save ( System _FileName, FORMAT_FLAGS _Parms, FormatEncoderOptions _Options ) : void

보호된 메소드들

메소드 설명
ConvertFrame ( System _Format ) : System.Windows.Media.Imaging.BitmapFrame

Converts the generic XYZ+A bitmap to the specified format frame

ConvertFrame ( System.Windows.Media.Imaging.BitmapSource _Frame ) : void

Converts the source bitmap to a generic RGBA32F format

I cannot use the FormatConvertedBitmap class because it applies some unwanted gamma correction depending on the source pixel format. For example, if the image is using the Bgr24 format that uses a 1/2.2 gamma internally, converting that to our generic format Rgba128Float (that uses a gamma of 1 internally) will automatically apply a pow( 2.2 ) to the RGB values, which is NOT what we're looking for since we're handling gamma correction ourselves here !

FLOAT_TO_BYTE ( float v ) : byte
FLOAT_TO_WORD ( float v ) : UInt16
RadianceFileFindInHeader ( List _HeaderLines, string _Search ) : string

메소드 상세

BilinearSample() 공개 메소드

Performs bilinear sampling of the XYZ content
public BilinearSample ( float X, float Y ) : float4
X float A column index in [0,Width[ (will be clamped if out of range)
Y float A row index in [0,Height[ (will be clamped if out of range)
리턴 float4

Bitmap() 공개 메소드

Creates a bitmap from a file
public Bitmap ( System _ImageFileName ) : System
_ImageFileName System
리턴 System

Bitmap() 공개 메소드

Creates a bitmap from a file
public Bitmap ( System _ImageFileName, ColorProfile _ProfileOverride ) : System
_ImageFileName System
_ProfileOverride ColorProfile
리턴 System

Bitmap() 공개 메소드

Creates a bitmap from a stream
public Bitmap ( System _ImageStream, FILE_TYPE _FileType ) : System
_ImageStream System The image stream to load the bitmap from
_FileType FILE_TYPE The image type
리턴 System

Bitmap() 공개 메소드

Creates a bitmap from a stream
public Bitmap ( System _ImageStream, FILE_TYPE _FileType, ColorProfile _ProfileOverride ) : System
_ImageStream System The image stream to load the bitmap from
_FileType FILE_TYPE The image type
_ProfileOverride ColorProfile
리턴 System

Bitmap() 공개 메소드

Creates a bitmap from a stream
public Bitmap ( System _ImageStream, System _ImageFileNameName ) : System
_ImageStream System The image stream to load the bitmap from
_ImageFileNameName System The name of the image file the stream is coming from originally (used to identify image file type)
리턴 System

Bitmap() 공개 메소드

Creates a bitmap from a stream
public Bitmap ( System _ImageStream, System _ImageFileNameName, ColorProfile _ProfileOverride ) : System
_ImageStream System The image stream to load the bitmap from
_ImageFileNameName System The name of the image file the stream is coming from originally (used to identify image file type)
_ProfileOverride ColorProfile
리턴 System

Bitmap() 공개 메소드

Creates a bitmap from memory
public Bitmap ( byte _ImageFileContent, FILE_TYPE _FileType ) : System
_ImageFileContent byte The memory buffer to load the bitmap from
_FileType FILE_TYPE The image type
리턴 System

Bitmap() 공개 메소드

Creates a bitmap from memory
public Bitmap ( byte _ImageFileContent, FILE_TYPE _FileType, ColorProfile _ProfileOverride ) : System
_ImageFileContent byte The memory buffer to load the bitmap from
_FileType FILE_TYPE The image type
_ProfileOverride ColorProfile
리턴 System

Bitmap() 공개 메소드

Creates a bitmap from memory
public Bitmap ( byte _ImageFileContent, System _ImageFileNameName ) : System
_ImageFileContent byte The memory buffer to load the bitmap from
_ImageFileNameName System The name of the image file the stream is coming from originally (used to identify image file type)
리턴 System

Bitmap() 공개 메소드

Creates a bitmap from memory
public Bitmap ( byte _ImageFileContent, System _ImageFileNameName, ColorProfile _ProfileOverride ) : System
_ImageFileContent byte The memory buffer to load the bitmap from
_ImageFileNameName System The name of the image file the stream is coming from originally (used to identify image file type)
_ProfileOverride ColorProfile
리턴 System

Bitmap() 공개 메소드

Manual creation
public Bitmap ( int _Width, int _Height, ColorProfile _Profile ) : System
_Width int
_Height int
_Profile ColorProfile An optional color profile, you will need a valid profile if you wish to save the bitmap!
리턴 System

ConvertFrame() 보호된 메소드

Converts the generic XYZ+A bitmap to the specified format frame
protected ConvertFrame ( System _Format ) : System.Windows.Media.Imaging.BitmapFrame
_Format System The format to convert into
리턴 System.Windows.Media.Imaging.BitmapFrame

ConvertFrame() 보호된 메소드

Converts the source bitmap to a generic RGBA32F format
I cannot use the FormatConvertedBitmap class because it applies some unwanted gamma correction depending on the source pixel format. For example, if the image is using the Bgr24 format that uses a 1/2.2 gamma internally, converting that to our generic format Rgba128Float (that uses a gamma of 1 internally) will automatically apply a pow( 2.2 ) to the RGB values, which is NOT what we're looking for since we're handling gamma correction ourselves here !
protected ConvertFrame ( System.Windows.Media.Imaging.BitmapSource _Frame ) : void
_Frame System.Windows.Media.Imaging.BitmapSource The source frame to convert
리턴 void

DecodeRGBEImage() 공개 정적인 메소드

Decodes a RGBE formatted image into a plain floating-point image
public static DecodeRGBEImage ( PF_RGBE _Source, bool _bSourceIsXYZ, bool _bTargetNeedsXYZ, ColorProfile _ColorProfile ) : ].float4[
_Source PF_RGBE The source RGBE formatted image
_bSourceIsXYZ bool Tells if the source image is encoded as XYZE rather than RGBE
_bTargetNeedsXYZ bool Tells if the target needs to be in CIE XYZ space (true) or RGB (false)
_ColorProfile ColorProfile The color profile for the image
리턴 ].float4[

DecodeRGBEImage() 공개 정적인 메소드

Decodes a RGBE formatted image into a plain floating-point image
public static DecodeRGBEImage ( PF_RGBE _Source, bool _bSourceIsXYZ, float4 _Target, bool _bTargetNeedsXYZ, ColorProfile _ColorProfile ) : void
_Source PF_RGBE The source RGBE formatted image
_bSourceIsXYZ bool Tells if the source image is encoded as XYZE rather than RGBE
_Target float4 The target float4 image
_bTargetNeedsXYZ bool Tells if the target needs to be in CIE XYZ space (true) or RGB (false)
_ColorProfile ColorProfile The color profile for the image
리턴 void

Dispose() 공개 메소드

public Dispose ( ) : void
리턴 void

FLOAT_TO_BYTE() 보호된 메소드

protected FLOAT_TO_BYTE ( float v ) : byte
v float
리턴 byte

FLOAT_TO_WORD() 보호된 메소드

protected FLOAT_TO_WORD ( float v ) : UInt16
v float
리턴 System.UInt16

GetFileType() 공개 정적인 메소드

Retrieves the image file type based on the image file name
public static GetFileType ( System _ImageFileNameName ) : FILE_TYPE
_ImageFileNameName System The image file name
리턴 FILE_TYPE

Load() 공개 메소드

Loads from disk
public Load ( System _ImageFileName, FILE_TYPE _FileType ) : void
_ImageFileName System
_FileType FILE_TYPE
리턴 void

Load() 공개 메소드

public Load ( System _ImageFileName, FILE_TYPE _FileType, ColorProfile _ProfileOverride ) : void
_ImageFileName System
_FileType FILE_TYPE
_ProfileOverride ColorProfile
리턴 void

Load() 공개 메소드

Actual load from a byte[] in memory
Occurs if the image type is not supported by the Bitmap class Occurs if the source image format cannot be converted to RGBA32F which is the generic format we read from
public Load ( byte _ImageFileContent, FILE_TYPE _FileType ) : void
_ImageFileContent byte The source image content as a byte[]
_FileType FILE_TYPE The type of file to load
리턴 void

Load() 공개 메소드

public Load ( byte _ImageFileContent, FILE_TYPE _FileType, ColorProfile _ProfileOverride ) : void
_ImageFileContent byte
_FileType FILE_TYPE
_ProfileOverride ColorProfile
리턴 void

LoadAndDecodeHDRFormat() 공개 정적인 메소드

Loads a bitmap in .HDR format into a float4 array directly useable by the image constructor
public static LoadAndDecodeHDRFormat ( byte _HDRFormatBinary, bool _bTargetNeedsXYZ, ColorProfile _ProfileOverride, ColorProfile &_ColorProfile ) : ].float4[
_HDRFormatBinary byte
_bTargetNeedsXYZ bool Tells if the target needs to be in CIE XYZ space (true) or RGB (false)
_ProfileOverride ColorProfile
_ColorProfile ColorProfile The color profile for the image
리턴 ].float4[

LoadBitmap() 공개 정적인 메소드

Loads a System.Drawing.Bitmap into a byte[] containing RGBARGBARG... pixels
public static LoadBitmap ( System _Bitmap, int &_Width, int &_Height ) : byte[]
_Bitmap System The source System.Drawing.Bitmap to load
_Width int The bitmap's width
_Height int The bitmaps's height
리턴 byte[]

LoadHDRFormat() 공개 정적인 메소드

Loads a bitmap in .HDR format into a RGBE array
public static LoadHDRFormat ( byte _HDRFormatBinary, ColorProfile _ProfileOverride, bool &_bIsXYZ, ColorProfile &_ColorProfile ) : ].PF_RGBE[
_HDRFormatBinary byte
_ProfileOverride ColorProfile
_bIsXYZ bool Tells if the image is encoded as XYZE rather than RGBE
_ColorProfile ColorProfile The color profile for the image
리턴 ].PF_RGBE[

RadianceFileFindInHeader() 보호된 정적인 메소드

protected static RadianceFileFindInHeader ( List _HeaderLines, string _Search ) : string
_HeaderLines List
_Search string
리턴 string

Save() 공개 메소드

Save to a file
public Save ( System _FileName ) : void
_FileName System
리턴 void

Save() 공개 메소드

Save to a stream
Occurs if the image type is not supported by the Bitmap class Occurs if the source image format cannot be converted to RGBA32F which is the generic format we read from
public Save ( System _Stream, FILE_TYPE _FileType, FORMAT_FLAGS _Parms, FormatEncoderOptions _Options ) : void
_Stream System The stream to write the image to
_FileType FILE_TYPE The file type to save as
_Parms FORMAT_FLAGS Additional formatting flags
_Options FormatEncoderOptions An optional block of options for encoding
리턴 void

Save() 공개 메소드

public Save ( System _FileName, FORMAT_FLAGS _Parms ) : void
_FileName System
_Parms FORMAT_FLAGS
리턴 void

Save() 공개 메소드

public Save ( System _FileName, FORMAT_FLAGS _Parms, FormatEncoderOptions _Options ) : void
_FileName System
_Parms FORMAT_FLAGS
_Options FormatEncoderOptions
리턴 void

프로퍼티 상세

m_Aperture 보호되어 있는 프로퍼티

protected float m_Aperture
리턴 float

m_Bitmap 보호되어 있는 프로퍼티

protected float4[,] m_Bitmap
리턴 ].float4[

m_ColorProfile 보호되어 있는 프로퍼티

protected ColorProfile,ImageUtility m_ColorProfile
리턴 ColorProfile

m_FocalLength 보호되어 있는 프로퍼티

protected float m_FocalLength
리턴 float

m_Height 보호되어 있는 프로퍼티

protected int m_Height
리턴 int

m_ISOSpeed 보호되어 있는 프로퍼티

protected float m_ISOSpeed
리턴 float

m_ShutterSpeed 보호되어 있는 프로퍼티

protected float m_ShutterSpeed
리턴 float

m_Type 보호되어 있는 프로퍼티

protected FILE_TYPE m_Type
리턴 FILE_TYPE

m_Width 보호되어 있는 프로퍼티

protected int m_Width
리턴 int

m_bHasAlpha 보호되어 있는 프로퍼티

protected bool m_bHasAlpha
리턴 bool

m_bHasValidShotInfo 보호되어 있는 프로퍼티

protected bool m_bHasValidShotInfo
리턴 bool

ms_ConvertContent2XYZ 보호되어 있는 정적으로 프로퍼티

protected static bool ms_ConvertContent2XYZ
리턴 bool

ms_ReadContent 보호되어 있는 정적으로 프로퍼티

protected static bool ms_ReadContent
리턴 bool