public static void float2rgbe ( byte [ ] rgbe , float red , float green , float blue ) { float v ; int e ; v = red ; if ( green > v ) { v = green ; } if ( blue > v ) { v = blue ; } if ( v < 1e-32f ) { rgbe [ 0 ] = rgbe [ 1 ] = rgbe [ 2 ] = rgbe [ 3 ] = 0 ; } else { FracExp fe = frexp ( v ) ; v = ( float ) ( fe . getFraction ( ) * 256.0 / v ) ; rgbe [ 0 ] = ( byte ) ( red * v ) ; rgbe [ 1 ] = ( byte ) ( green * v ) ; rgbe [ 2 ] = ( byte ) ( blue * v ) ; rgbe [ 3 ] = ( byte ) ( fe . getExponent ( ) + 128 ) ; } }
Standard conversion from float pixels to rgbe pixels .