mirror of
https://github.com/microsoft/DirectXTex.git
synced 2025-07-09 11:40:14 +02:00
DirectxTex: added optional targetFormat parameter to WIC save routines to control choice of output format
This commit is contained in:
parent
051f865120
commit
28faae7447
@ -274,11 +274,14 @@ namespace DirectX
|
|||||||
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image );
|
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image );
|
||||||
|
|
||||||
HRESULT SaveToWICMemory( _In_ const Image& image, _In_ DWORD flags, _In_ REFGUID guidContainerFormat,
|
HRESULT SaveToWICMemory( _In_ const Image& image, _In_ DWORD flags, _In_ REFGUID guidContainerFormat,
|
||||||
_Out_ Blob& blob );
|
_Out_ Blob& blob, _In_opt_ const GUID* targetFormat = nullptr );
|
||||||
HRESULT SaveToWICMemory( _In_count_(nimages) const Image* images, _In_ size_t nimages, _In_ DWORD flags, _In_ REFGUID guidContainerFormat, _Out_ Blob& blob );
|
HRESULT SaveToWICMemory( _In_count_(nimages) const Image* images, _In_ size_t nimages, _In_ DWORD flags, _In_ REFGUID guidContainerFormat,
|
||||||
|
_Out_ Blob& blob, _In_opt_ const GUID* targetFormat = nullptr );
|
||||||
|
|
||||||
HRESULT SaveToWICFile( _In_ const Image& image, _In_ DWORD flags, _In_ REFGUID guidContainerFormat, _In_z_ LPCWSTR szFile );
|
HRESULT SaveToWICFile( _In_ const Image& image, _In_ DWORD flags, _In_ REFGUID guidContainerFormat,
|
||||||
HRESULT SaveToWICFile( _In_count_(nimages) const Image* images, _In_ size_t nimages, _In_ DWORD flags, _In_ REFGUID guidContainerFormat, _In_z_ LPCWSTR szFile );
|
_In_z_ LPCWSTR szFile, _In_opt_ const GUID* targetFormat = nullptr );
|
||||||
|
HRESULT SaveToWICFile( _In_count_(nimages) const Image* images, _In_ size_t nimages, _In_ DWORD flags, _In_ REFGUID guidContainerFormat,
|
||||||
|
_In_z_ LPCWSTR szFile, _In_opt_ const GUID* targetFormat = nullptr );
|
||||||
|
|
||||||
enum WICCodecs
|
enum WICCodecs
|
||||||
{
|
{
|
||||||
|
@ -369,7 +369,7 @@ static HRESULT _DecodeMultiframe( _In_ DWORD flags, _In_ const TexMetadata& meta
|
|||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
// Encodes a single frame
|
// Encodes a single frame
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
static HRESULT _EncodeImage( _In_ const Image& image, _In_ DWORD flags, _In_ IWICBitmapFrameEncode* frame, _In_opt_ IPropertyBag2* props )
|
static HRESULT _EncodeImage( _In_ const Image& image, _In_ DWORD flags, _In_ IWICBitmapFrameEncode* frame, _In_opt_ IPropertyBag2* props, _In_opt_ const GUID* targetFormat )
|
||||||
{
|
{
|
||||||
if ( !frame )
|
if ( !frame )
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
@ -398,7 +398,7 @@ static HRESULT _EncodeImage( _In_ const Image& image, _In_ DWORD flags, _In_ IWI
|
|||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
WICPixelFormatGUID targetGuid = pfGuid;
|
WICPixelFormatGUID targetGuid = (targetFormat) ? (*targetFormat) : pfGuid;
|
||||||
hr = frame->SetPixelFormat( &targetGuid );
|
hr = frame->SetPixelFormat( &targetGuid );
|
||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
return hr;
|
return hr;
|
||||||
@ -448,7 +448,7 @@ static HRESULT _EncodeImage( _In_ const Image& image, _In_ DWORD flags, _In_ IWI
|
|||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT _EncodeSingleFrame( _In_ const Image& image, _In_ DWORD flags,
|
static HRESULT _EncodeSingleFrame( _In_ const Image& image, _In_ DWORD flags,
|
||||||
_In_ REFGUID guidContainerFormat, _Inout_ IStream* stream )
|
_In_ REFGUID guidContainerFormat, _Inout_ IStream* stream, _In_opt_ const GUID* targetFormat )
|
||||||
{
|
{
|
||||||
if ( !stream )
|
if ( !stream )
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
@ -490,7 +490,7 @@ static HRESULT _EncodeSingleFrame( _In_ const Image& image, _In_ DWORD flags,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = _EncodeImage( image, flags, frame.Get(), props.Get() );
|
hr = _EncodeImage( image, flags, frame.Get(), props.Get(), targetFormat );
|
||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
@ -506,7 +506,7 @@ static HRESULT _EncodeSingleFrame( _In_ const Image& image, _In_ DWORD flags,
|
|||||||
// Encodes an image array
|
// Encodes an image array
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
static HRESULT _EncodeMultiframe( _In_count_(nimages) const Image* images, _In_ size_t nimages, _In_ DWORD flags,
|
static HRESULT _EncodeMultiframe( _In_count_(nimages) const Image* images, _In_ size_t nimages, _In_ DWORD flags,
|
||||||
_In_ REFGUID guidContainerFormat, _Inout_ IStream* stream )
|
_In_ REFGUID guidContainerFormat, _Inout_ IStream* stream, _In_opt_ const GUID* targetFormat )
|
||||||
{
|
{
|
||||||
if ( !stream || nimages < 2 )
|
if ( !stream || nimages < 2 )
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
@ -548,7 +548,7 @@ static HRESULT _EncodeMultiframe( _In_count_(nimages) const Image* images, _In_
|
|||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
hr = _EncodeImage( images[index], flags, frame.Get(), nullptr );
|
hr = _EncodeImage( images[index], flags, frame.Get(), nullptr, targetFormat );
|
||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
@ -771,7 +771,7 @@ HRESULT LoadFromWICFile( LPCWSTR szFile, DWORD flags, TexMetadata* metadata, Scr
|
|||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
// Save a WIC-supported file to memory
|
// Save a WIC-supported file to memory
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
HRESULT SaveToWICMemory( const Image& image, DWORD flags, REFGUID guidContainerFormat, Blob& blob )
|
HRESULT SaveToWICMemory( const Image& image, DWORD flags, REFGUID guidContainerFormat, Blob& blob, const GUID* targetFormat )
|
||||||
{
|
{
|
||||||
if ( !image.pixels )
|
if ( !image.pixels )
|
||||||
return E_POINTER;
|
return E_POINTER;
|
||||||
@ -783,7 +783,7 @@ HRESULT SaveToWICMemory( const Image& image, DWORD flags, REFGUID guidContainerF
|
|||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
hr = _EncodeSingleFrame( image, flags, guidContainerFormat, stream.Get() );
|
hr = _EncodeSingleFrame( image, flags, guidContainerFormat, stream.Get(), targetFormat );
|
||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
@ -816,7 +816,7 @@ HRESULT SaveToWICMemory( const Image& image, DWORD flags, REFGUID guidContainerF
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT SaveToWICMemory( const Image* images, size_t nimages, DWORD flags, REFGUID guidContainerFormat, Blob& blob )
|
HRESULT SaveToWICMemory( const Image* images, size_t nimages, DWORD flags, REFGUID guidContainerFormat, Blob& blob, const GUID* targetFormat )
|
||||||
{
|
{
|
||||||
if ( !images || nimages == 0 )
|
if ( !images || nimages == 0 )
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
@ -829,9 +829,9 @@ HRESULT SaveToWICMemory( const Image* images, size_t nimages, DWORD flags, REFGU
|
|||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
if ( nimages > 1 )
|
if ( nimages > 1 )
|
||||||
hr = _EncodeMultiframe( images, nimages, flags, guidContainerFormat, stream.Get() );
|
hr = _EncodeMultiframe( images, nimages, flags, guidContainerFormat, stream.Get(), targetFormat );
|
||||||
else
|
else
|
||||||
hr = _EncodeSingleFrame( images[0], flags, guidContainerFormat, stream.Get() );
|
hr = _EncodeSingleFrame( images[0], flags, guidContainerFormat, stream.Get(), targetFormat );
|
||||||
|
|
||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
return hr;
|
return hr;
|
||||||
@ -869,7 +869,7 @@ HRESULT SaveToWICMemory( const Image* images, size_t nimages, DWORD flags, REFGU
|
|||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
// Save a WIC-supported file to disk
|
// Save a WIC-supported file to disk
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
HRESULT SaveToWICFile( const Image& image, DWORD flags, REFGUID guidContainerFormat, LPCWSTR szFile )
|
HRESULT SaveToWICFile( const Image& image, DWORD flags, REFGUID guidContainerFormat, LPCWSTR szFile, const GUID* targetFormat )
|
||||||
{
|
{
|
||||||
if ( !szFile )
|
if ( !szFile )
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
@ -890,14 +890,14 @@ HRESULT SaveToWICFile( const Image& image, DWORD flags, REFGUID guidContainerFor
|
|||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
hr = _EncodeSingleFrame( image, flags, guidContainerFormat, stream.Get() );
|
hr = _EncodeSingleFrame( image, flags, guidContainerFormat, stream.Get(), targetFormat );
|
||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT SaveToWICFile( const Image* images, size_t nimages, DWORD flags, REFGUID guidContainerFormat, LPCWSTR szFile )
|
HRESULT SaveToWICFile( const Image* images, size_t nimages, DWORD flags, REFGUID guidContainerFormat, LPCWSTR szFile, const GUID* targetFormat )
|
||||||
{
|
{
|
||||||
if ( !szFile || !images || nimages == 0 )
|
if ( !szFile || !images || nimages == 0 )
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
@ -916,9 +916,9 @@ HRESULT SaveToWICFile( const Image* images, size_t nimages, DWORD flags, REFGUID
|
|||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
if ( nimages > 1 )
|
if ( nimages > 1 )
|
||||||
hr = _EncodeMultiframe( images, nimages, flags, guidContainerFormat, stream.Get() );
|
hr = _EncodeMultiframe( images, nimages, flags, guidContainerFormat, stream.Get(), targetFormat );
|
||||||
else
|
else
|
||||||
hr = _EncodeSingleFrame( images[0], flags, guidContainerFormat, stream.Get() );
|
hr = _EncodeSingleFrame( images[0], flags, guidContainerFormat, stream.Get(), targetFormat );
|
||||||
|
|
||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
return hr;
|
return hr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user