[.net] Single16 to float
Does anyone know how to cast a DirectX.Single16 to a float?
I'm trying to port some of the texture encoding code in the SDK's HDRFormats sample so I can encode HDR images as RGBE. I managed to find a 16-bit floating point value in DirectX.Single16 and I was like: yes!
However, there does not appear to be a cast defined for (float)single16Val and indeed, its only members are the ordinary constants such as Epsilon.
Their Single16 type seems to be useless! What can I do?
Thanks in advance.
Have you tried somthing like:
float SingleCaster(Single16 input){
unsafe{return (float)((single*)&input)[0];}
}
What is the difference between System.Single and DirectX.Single16?
hope this helps.
turnpast (out of town)
float SingleCaster(Single16 input){
unsafe{return (float)((single*)&input)[0];}
}
What is the difference between System.Single and DirectX.Single16?
hope this helps.
turnpast (out of town)
Quote:Original post by Anonymous Poster
What is the difference between System.Single and DirectX.Single16?
System.Single is 32 bits.
Thanks for the help.
But the 16-bit floats have a different number of mantissa and exponent bits so a straight cast wouldn't work.
I downloaded the August SDK the day before yesterday and that has a managed HDRFormats sample! So I wasted an hour the day before the day before yesterday porting the encoding code :(
Their encoding code doesn't use the Single16 at all - they use a 2D array of ColorValue with unsafe code.
But I'm waiting until the SDK can be installed - needs admin privileges. I had those on the old computer :(
But the 16-bit floats have a different number of mantissa and exponent bits so a straight cast wouldn't work.
I downloaded the August SDK the day before yesterday and that has a managed HDRFormats sample! So I wasted an hour the day before the day before yesterday porting the encoding code :(
Their encoding code doesn't use the Single16 at all - they use a 2D array of ColorValue with unsafe code.
But I'm waiting until the SDK can be installed - needs admin privileges. I had those on the old computer :(
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement