Hi Juan,
thanks for pointing me into the right direction. After setting options as follows everything works as it should:
const ImageVariant &rImage =*pImage_p;
...
ImageOptions options;
options.bitsPerSample=rImage.BitsPerSample();
options.ieeefpSampleFormat=rImage.IsFloatSample();
options.complexSample=rImage.IsComplexSample();
options.signedIntegers=false;
fileWriter.SetOptions(options);
...
Let me say however that I find this behaviour non-intuitive:
1. What I would expect is that FileInstance.WriteImage() evaluates the available image type information (just as it evaluates width, height, number of channels,...) to write in the format that best preserves the data -unless the user gives specific options. If necessary, a type conversion should be done. What happens now that WriteImage() interprets any Image as uint16, and just writes out the binary data that it finds in the Image (without type conversion).
The current design nicely abstract the specifics of the different writers, but via ImageOptions I get them again into my code, even if I just want to write out my existing data the best way supported by the FileFormat.
2. The documentation says:
/*!
* Writes a 32-bit floating point image to this file. Returns true if the
* image was successfully written.
*/
bool WriteImage( const FImage& image );
So I would expect to get a result of false
if I try to write a float Image as 16bit int, because the Image was not successfully written. Or it should actually do what the documentation says: Write a 32 bit floating point image to a file (which it does not, because it interprets float data as 16 bit integer data).
3. As the very minimum, I would hope to see a warning message.
Consider this as an improvement request in this area.
Georg