mirror of
https://github.com/microsoft/DirectXTex
synced 2024-11-21 20:10:05 +00:00
Optional callback from WIC readers to get additional metadata queries
This commit is contained in:
parent
9c322a47e9
commit
a7ffe96b3e
@ -60,6 +60,7 @@
|
|||||||
#define DIRECTX_TEX_VERSION 134
|
#define DIRECTX_TEX_VERSION 134
|
||||||
|
|
||||||
struct IWICImagingFactory;
|
struct IWICImagingFactory;
|
||||||
|
struct IWICMetadataQueryReader;
|
||||||
|
|
||||||
|
|
||||||
namespace DirectX
|
namespace DirectX
|
||||||
@ -238,9 +239,12 @@ namespace DirectX
|
|||||||
_Out_ TexMetadata& metadata );
|
_Out_ TexMetadata& metadata );
|
||||||
|
|
||||||
HRESULT __cdecl GetMetadataFromWICMemory( _In_reads_bytes_(size) LPCVOID pSource, _In_ size_t size, _In_ DWORD flags,
|
HRESULT __cdecl GetMetadataFromWICMemory( _In_reads_bytes_(size) LPCVOID pSource, _In_ size_t size, _In_ DWORD flags,
|
||||||
_Out_ TexMetadata& metadata );
|
_Out_ TexMetadata& metadata,
|
||||||
|
_In_opt_ std::function<void DIRECTX_STD_CALLCONV(IWICMetadataQueryReader*)> getMQR = nullptr);
|
||||||
|
|
||||||
HRESULT __cdecl GetMetadataFromWICFile( _In_z_ LPCWSTR szFile, _In_ DWORD flags,
|
HRESULT __cdecl GetMetadataFromWICFile( _In_z_ LPCWSTR szFile, _In_ DWORD flags,
|
||||||
_Out_ TexMetadata& metadata );
|
_Out_ TexMetadata& metadata,
|
||||||
|
_In_opt_ std::function<void DIRECTX_STD_CALLCONV(IWICMetadataQueryReader*)> getMQR = nullptr);
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
// Bitmap image container
|
// Bitmap image container
|
||||||
@ -359,9 +363,11 @@ namespace DirectX
|
|||||||
|
|
||||||
// WIC operations
|
// WIC operations
|
||||||
HRESULT __cdecl LoadFromWICMemory( _In_reads_bytes_(size) LPCVOID pSource, _In_ size_t size, _In_ DWORD flags,
|
HRESULT __cdecl LoadFromWICMemory( _In_reads_bytes_(size) LPCVOID pSource, _In_ size_t size, _In_ DWORD flags,
|
||||||
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image );
|
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image,
|
||||||
|
_In_opt_ std::function<void DIRECTX_STD_CALLCONV(IWICMetadataQueryReader*)> getMQR = nullptr);
|
||||||
HRESULT __cdecl LoadFromWICFile( _In_z_ LPCWSTR szFile, _In_ DWORD flags,
|
HRESULT __cdecl LoadFromWICFile( _In_z_ LPCWSTR szFile, _In_ DWORD flags,
|
||||||
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image );
|
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image,
|
||||||
|
_In_opt_ std::function<void DIRECTX_STD_CALLCONV(IWICMetadataQueryReader*)> getMQR = nullptr);
|
||||||
|
|
||||||
HRESULT __cdecl SaveToWICMemory( _In_ const Image& image, _In_ DWORD flags, _In_ REFGUID guidContainerFormat,
|
HRESULT __cdecl SaveToWICMemory( _In_ const Image& image, _In_ DWORD flags, _In_ REFGUID guidContainerFormat,
|
||||||
_Out_ Blob& blob, _In_opt_ const GUID* targetFormat = nullptr,
|
_Out_ Blob& blob, _In_opt_ const GUID* targetFormat = nullptr,
|
||||||
|
@ -238,7 +238,8 @@ static DXGI_FORMAT _DetermineFormat( _In_ const WICPixelFormatGUID& pixelFormat,
|
|||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
static HRESULT _DecodeMetadata( _In_ DWORD flags, _In_ bool iswic2,
|
static HRESULT _DecodeMetadata( _In_ DWORD flags, _In_ bool iswic2,
|
||||||
_In_ IWICBitmapDecoder *decoder, _In_ IWICBitmapFrameDecode *frame,
|
_In_ IWICBitmapDecoder *decoder, _In_ IWICBitmapFrameDecode *frame,
|
||||||
_Out_ TexMetadata& metadata, _Out_opt_ WICPixelFormatGUID* pConvert )
|
_Out_ TexMetadata& metadata, _Out_opt_ WICPixelFormatGUID* pConvert,
|
||||||
|
_In_opt_ std::function<void(IWICMetadataQueryReader*)> getMQR )
|
||||||
{
|
{
|
||||||
if ( !decoder || !frame )
|
if ( !decoder || !frame )
|
||||||
return E_POINTER;
|
return E_POINTER;
|
||||||
@ -336,6 +337,15 @@ static HRESULT _DecodeMetadata( _In_ DWORD flags, _In_ bool iswic2,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getMQR)
|
||||||
|
{
|
||||||
|
ComPtr<IWICMetadataQueryReader> metareader;
|
||||||
|
if (SUCCEEDED(frame->GetMetadataQueryReader(metareader.GetAddressOf())))
|
||||||
|
{
|
||||||
|
getMQR(metareader.Get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -847,7 +857,7 @@ static HRESULT _EncodeMultiframe( _In_reads_(nimages) const Image* images, _In_
|
|||||||
// Obtain metadata from WIC-supported file in memory
|
// Obtain metadata from WIC-supported file in memory
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
_Use_decl_annotations_
|
_Use_decl_annotations_
|
||||||
HRESULT GetMetadataFromWICMemory( LPCVOID pSource, size_t size, DWORD flags, TexMetadata& metadata )
|
HRESULT GetMetadataFromWICMemory( LPCVOID pSource, size_t size, DWORD flags, TexMetadata& metadata, std::function<void(IWICMetadataQueryReader*)> getMQR )
|
||||||
{
|
{
|
||||||
if ( !pSource || size == 0 )
|
if ( !pSource || size == 0 )
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
@ -885,7 +895,7 @@ HRESULT GetMetadataFromWICMemory( LPCVOID pSource, size_t size, DWORD flags, Tex
|
|||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
// Get metadata
|
// Get metadata
|
||||||
hr = _DecodeMetadata( flags, iswic2, decoder.Get(), frame.Get(), metadata, 0 );
|
hr = _DecodeMetadata( flags, iswic2, decoder.Get(), frame.Get(), metadata, nullptr, getMQR );
|
||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
@ -897,7 +907,7 @@ HRESULT GetMetadataFromWICMemory( LPCVOID pSource, size_t size, DWORD flags, Tex
|
|||||||
// Obtain metadata from WIC-supported file on disk
|
// Obtain metadata from WIC-supported file on disk
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
_Use_decl_annotations_
|
_Use_decl_annotations_
|
||||||
HRESULT GetMetadataFromWICFile( LPCWSTR szFile, DWORD flags, TexMetadata& metadata )
|
HRESULT GetMetadataFromWICFile( LPCWSTR szFile, DWORD flags, TexMetadata& metadata, std::function<void(IWICMetadataQueryReader*)> getMQR )
|
||||||
{
|
{
|
||||||
if ( !szFile )
|
if ( !szFile )
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
@ -919,7 +929,7 @@ HRESULT GetMetadataFromWICFile( LPCWSTR szFile, DWORD flags, TexMetadata& metada
|
|||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
// Get metadata
|
// Get metadata
|
||||||
hr = _DecodeMetadata( flags, iswic2, decoder.Get(), frame.Get(), metadata, 0 );
|
hr = _DecodeMetadata( flags, iswic2, decoder.Get(), frame.Get(), metadata, nullptr, getMQR );
|
||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
@ -931,7 +941,7 @@ HRESULT GetMetadataFromWICFile( LPCWSTR szFile, DWORD flags, TexMetadata& metada
|
|||||||
// Load a WIC-supported file in memory
|
// Load a WIC-supported file in memory
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
_Use_decl_annotations_
|
_Use_decl_annotations_
|
||||||
HRESULT LoadFromWICMemory( LPCVOID pSource, size_t size, DWORD flags, TexMetadata* metadata, ScratchImage& image )
|
HRESULT LoadFromWICMemory( LPCVOID pSource, size_t size, DWORD flags, TexMetadata* metadata, ScratchImage& image, std::function<void(IWICMetadataQueryReader*)> getMQR )
|
||||||
{
|
{
|
||||||
if ( !pSource || size == 0 )
|
if ( !pSource || size == 0 )
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
@ -972,7 +982,7 @@ HRESULT LoadFromWICMemory( LPCVOID pSource, size_t size, DWORD flags, TexMetadat
|
|||||||
// Get metadata
|
// Get metadata
|
||||||
TexMetadata mdata;
|
TexMetadata mdata;
|
||||||
WICPixelFormatGUID convertGUID = {0};
|
WICPixelFormatGUID convertGUID = {0};
|
||||||
hr = _DecodeMetadata( flags, iswic2, decoder.Get(), frame.Get(), mdata, &convertGUID );
|
hr = _DecodeMetadata( flags, iswic2, decoder.Get(), frame.Get(), mdata, &convertGUID, getMQR );
|
||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
@ -1002,7 +1012,7 @@ HRESULT LoadFromWICMemory( LPCVOID pSource, size_t size, DWORD flags, TexMetadat
|
|||||||
// Load a WIC-supported file from disk
|
// Load a WIC-supported file from disk
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
_Use_decl_annotations_
|
_Use_decl_annotations_
|
||||||
HRESULT LoadFromWICFile( LPCWSTR szFile, DWORD flags, TexMetadata* metadata, ScratchImage& image )
|
HRESULT LoadFromWICFile( LPCWSTR szFile, DWORD flags, TexMetadata* metadata, ScratchImage& image, std::function<void(IWICMetadataQueryReader*)> getMQR )
|
||||||
{
|
{
|
||||||
if ( !szFile )
|
if ( !szFile )
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
@ -1028,7 +1038,7 @@ HRESULT LoadFromWICFile( LPCWSTR szFile, DWORD flags, TexMetadata* metadata, Scr
|
|||||||
// Get metadata
|
// Get metadata
|
||||||
TexMetadata mdata;
|
TexMetadata mdata;
|
||||||
WICPixelFormatGUID convertGUID = {0};
|
WICPixelFormatGUID convertGUID = {0};
|
||||||
hr = _DecodeMetadata( flags, iswic2, decoder.Get(), frame.Get(), mdata, &convertGUID );
|
hr = _DecodeMetadata( flags, iswic2, decoder.Get(), frame.Get(), mdata, &convertGUID, getMQR );
|
||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user