mirror of
https://github.com/microsoft/DirectXTex
synced 2024-11-24 13:20:13 +00:00
Updated Adding OpenEXR (markdown)
parent
8445712c37
commit
6788b303dc
@ -11,11 +11,69 @@ The DirectXTex auxiliary module for loading ``EXR`` files is in the [DirectXTexE
|
||||
|
||||
For the ``DirectXTexEXR.cpp`` file, update the project property _Additional Include Directories_ to include the OpenEXR library headers.
|
||||
|
||||
> If using the recommended scripts above, add ``.\openexr\local\include\OpenEXR``
|
||||
> If using the recommended scripts above, add ``.\local\include\OpenEXR``
|
||||
|
||||
For the executables that build with this support, you need to update the project property _Additional Library Directories_ to include the OpenEXR libraries.
|
||||
|
||||
> If using the recommended scripts above, add ``.\openexr\local\lib``
|
||||
> If using the recommended scripts above, add ``.\local\lib``
|
||||
|
||||
# Functions
|
||||
|
||||
# GetMetadataFromEXRFile
|
||||
Returns the _TexMetadata_ from a ``.EXR`` file.
|
||||
|
||||
HRESULT GetMetadataFromEXRFile( const wchar_t* szFile,
|
||||
TexMetadata& metadata );
|
||||
|
||||
# LoadFromEXRFile
|
||||
Loads a ``.EXR`` file.
|
||||
|
||||
HRESULT LoadFromEXRFile const wchar_t* szFile,
|
||||
TexMetadata* metadata, ScratchImage& image );
|
||||
|
||||
* The data is always loaded as ``R16G16B16A16_FLOAT``.
|
||||
|
||||
# SaveToEXRFile
|
||||
Saves a single image to a ``.EXR`` file.
|
||||
|
||||
HRESULT SaveToEXRFile( const Image& image, const wchar_t* szFile );
|
||||
|
||||
* ``R16G16B16A16_FLOAT``, ``R32G32B32A32_FLOAT``, and ``R32G32B32_FLOAT`` data are supported for writing.
|
||||
|
||||
# Parameters
|
||||
For the load functions, the _metadata_ parameter can be nullptr as this information is also available in the returned **ScratchImage**.
|
||||
|
||||
# Examples
|
||||
|
||||
This is a simple loading example. The ``EXR`` format cannot contain complicated multi-image formats, so the _TexMetadata_ info is redundant information.
|
||||
|
||||
auto image = std::make_unique<ScratchImage>();
|
||||
HRESULT hr = LoadFromEXRFile( L"flowers.exr", nullptr, *image );
|
||||
if ( FAILED(hr) )
|
||||
// error
|
||||
|
||||
A ``EXR`` file can only store one 2D image.
|
||||
|
||||
const Image* img = image->GetImage(0,0,0);
|
||||
assert( img );
|
||||
HRESULT hr = SaveToEXRFile( *img, L"NEW_IMAGE.EXR" );
|
||||
if ( FAILED(hr) )
|
||||
// error
|
||||
|
||||
You can also save data directly from memory without using the intermediate **ScratchImage** at all. This example assumes a single 2D image is being written out.
|
||||
|
||||
Image img;
|
||||
img.width = /*<width of pixel data>*/;
|
||||
img.height = /*<height of pixel data>*/;
|
||||
img.format = /* DXGI_FORMAT_R16G16B16A16_FLOAT,
|
||||
DXGI_FORMAT_R32G32B32A32_FLOAT
|
||||
or DXGI_FORMAT_R32G32B32_FLOAT */;
|
||||
img.rowPitch = /*<number of bytes in a scanline of the source data>*/;
|
||||
img.slicePitch = /*<number of bytes in the entire 2D image>*/;
|
||||
img.pixels = /*<pointer to pixel data>*/;
|
||||
HRESULT hr = SaveToEXRFile( img, L"NEW_IMAGE.EXR" );
|
||||
if ( FAILED(hr) )
|
||||
// error
|
||||
|
||||
# Samples
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user