I'm trying to load an image, but load() always gives me a StreamTexture in RGBA8 format. My image is a 24-bit BMP texture. Is there a way I can load it with 24-bit precision?

My image is a 24-bit BMP texture. Is there a way I can load it with 24-bit precision?

As far as I know, BMP does not support high dynamic range/higher precision than 8 bpc. A 24-bit BMP image is just a RGB8 image (with no alpha channel).

If you need to import high dynamic range images, use the Radiance HDR (.hdr) or OpenEXR (.exr) format. While both are perfectly functional for HDR images, OpenEXR has better compression and is more modern overall. Godot can also load and save OpenEXR images at run-time using the Image class. Edit: Run-time OpenEXR loading and saving is only available in editor builds, see below.

Note that Godot will clamp PNG precision to 8 bpc, so PNGs that were saved with 16 bpc will be clamped to 8 bpc. This is done because many people aren't aware that they are saving PNGs with a higher color depth than 8 bpc, and end up wasting lots of disk space and memory in the end. This is why we chose to make the HDR decision explicit by using formats specifically tailored for HDR, rather than relying on PNG for this purpose.

a month later

If you need to import high dynamic range images, use the Radiance HDR (.hdr) or OpenEXR (.exr) format. While both are perfectly functional for HDR images, OpenEXR has better compression and is more modern overall. Godot can also load and save OpenEXR images at run-time using the Image class.

Sadly, untrue. The EXR module inexplicably only builds with the editor. https://github.com/godotengine/godot/blob/master/modules/tinyexr/config.py#L2

@voxtech said:

Sadly, untrue. The EXR module inexplicably only builds with the editor. https://github.com/godotengine/godot/blob/master/modules/tinyexr/config.py#L2

Indeed, thanks for pointing it out. I added a note in the class reference. As a workaround, you can modify that modules/tinyexr/config.py file and compile export templates for all the platforms you plan to export to.

As I wrote in https://github.com/godotengine/godot/pull/42947, here's the reason for the tinyexr module being disabled in non-editor builds:

As you can see in the demo project, I've also included a run-time OpenEXR loading example. However, I stripped OpenEXR loading from the PR as it increased the binary size for export templates noticeably (+115 KB for a release LTO'd Linux 64-bit export template).

This may not be much of a difference on desktop platforms, but it's a lot for mobile/web platforms where download and initialization times are critical.

a year later