/// <summary> /// Decodes a RGBE formatted image into a plain floating-point image /// </summary> /// <param name="_Source">The source RGBE formatted image</param> /// <param name="_bSourceIsXYZ">Tells if the source image is encoded as XYZE rather than RGBE</param> /// <param name="_Target">The target float4 image</param> /// <param name="_bTargetNeedsXYZ">Tells if the target needs to be in CIE XYZ space (true) or RGB (false)</param> /// <param name="_ColorProfile">The color profile for the image</param> public static void DecodeRGBEImage( PF_RGBE[,] _Source, bool _bSourceIsXYZ, float4[,] _Target, bool _bTargetNeedsXYZ, ColorProfile _ColorProfile ) { if ( _bSourceIsXYZ ^ _bTargetNeedsXYZ ) { // Requires conversion... if ( _bSourceIsXYZ ) { // Convert from XYZ to RGB for ( int Y=0; Y < _Source.GetLength( 1 ); Y++ ) for ( int X=0; X < _Source.GetLength( 0 ); X++ ) _Target[X,Y] = _ColorProfile.XYZ2RGB( new float4( _Source[X,Y].DecodedColor.x, _Source[X,Y].DecodedColor.y, _Source[X,Y].DecodedColor.z, 1.0f ) ); } else { // Convert from RGB to XYZ for ( int Y=0; Y < _Source.GetLength( 1 ); Y++ ) for ( int X=0; X < _Source.GetLength( 0 ); X++ ) _Target[X,Y] = _ColorProfile.RGB2XYZ( new float4( _Source[X,Y].DecodedColor.x, _Source[X,Y].DecodedColor.y, _Source[X,Y].DecodedColor.z, 1.0f ) ); } return; } // Simply decode vector and leave as-is for ( int Y=0; Y < _Source.GetLength( 1 ); Y++ ) for ( int X=0; X < _Source.GetLength( 0 ); X++ ) _Target[X,Y] = new float4( _Source[X,Y].DecodedColor.x, _Source[X,Y].DecodedColor.y, _Source[X,Y].DecodedColor.z, 1.0f ); }
/// <summary> /// Decodes a RGBE formatted image into a plain floating-point image /// </summary> /// <param name="_Source">The source RGBE formatted image</param> /// <param name="_bSourceIsXYZ">Tells if the source image is encoded as XYZE rather than RGBE</param> /// <param name="_bTargetNeedsXYZ">Tells if the target needs to be in CIE XYZ space (true) or RGB (false)</param> /// <param name="_ColorProfile">The color profile for the image</param> /// <returns>A HDR image as floats</returns> public static float4[,] DecodeRGBEImage( PF_RGBE[,] _Source, bool _bSourceIsXYZ, bool _bTargetNeedsXYZ, ColorProfile _ColorProfile ) { if ( _Source == null ) return null; float4[,] Result = new float4[_Source.GetLength( 0 ), _Source.GetLength( 1 )]; DecodeRGBEImage( _Source, _bSourceIsXYZ, Result, _bTargetNeedsXYZ, _ColorProfile ); return Result; }