зеркало из https://github.com/microsoft/DXUT.git
Resync'd DDSTextureLoader, ScreenGrab, WICTextureLoadeR
This commit is contained in:
Родитель
547598dbe4
Коммит
0f6e987a99
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,7 +1,7 @@
|
|||
//--------------------------------------------------------------------------------------
|
||||
// File: DDSTextureLoader.h
|
||||
//
|
||||
// Functions for loading a DDS texture and creating a Direct3D 11 runtime resource for it
|
||||
// Functions for loading a DDS texture and creating a Direct3D runtime resource for it
|
||||
//
|
||||
// Note these functions are useful as a light-weight runtime loader for DDS files. For
|
||||
// a full-featured DDS file reader, writer, and texture processing pipeline see
|
||||
|
@ -36,98 +36,98 @@ namespace DirectX
|
|||
};
|
||||
|
||||
// Standard version
|
||||
HRESULT CreateDDSTextureFromMemory( _In_ ID3D11Device* d3dDevice,
|
||||
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
|
||||
_In_ size_t ddsDataSize,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0,
|
||||
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr
|
||||
);
|
||||
HRESULT CreateDDSTextureFromMemory(
|
||||
_In_ ID3D11Device* d3dDevice,
|
||||
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
|
||||
_In_ size_t ddsDataSize,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0,
|
||||
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr);
|
||||
|
||||
HRESULT CreateDDSTextureFromFile( _In_ ID3D11Device* d3dDevice,
|
||||
_In_z_ const wchar_t* szFileName,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0,
|
||||
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr
|
||||
);
|
||||
HRESULT CreateDDSTextureFromFile(
|
||||
_In_ ID3D11Device* d3dDevice,
|
||||
_In_z_ const wchar_t* szFileName,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0,
|
||||
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr);
|
||||
|
||||
// Standard version with optional auto-gen mipmap support
|
||||
HRESULT CreateDDSTextureFromMemory( _In_ ID3D11Device* d3dDevice,
|
||||
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
|
||||
_In_ size_t ddsDataSize,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0,
|
||||
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr
|
||||
);
|
||||
HRESULT CreateDDSTextureFromMemory(
|
||||
_In_ ID3D11Device* d3dDevice,
|
||||
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
|
||||
_In_ size_t ddsDataSize,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0,
|
||||
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr);
|
||||
|
||||
HRESULT CreateDDSTextureFromFile( _In_ ID3D11Device* d3dDevice,
|
||||
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||
_In_z_ const wchar_t* szFileName,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0,
|
||||
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr
|
||||
);
|
||||
HRESULT CreateDDSTextureFromFile(
|
||||
_In_ ID3D11Device* d3dDevice,
|
||||
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||
_In_z_ const wchar_t* szFileName,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0,
|
||||
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr);
|
||||
|
||||
// Extended version
|
||||
HRESULT CreateDDSTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice,
|
||||
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
|
||||
_In_ size_t ddsDataSize,
|
||||
_In_ size_t maxsize,
|
||||
_In_ D3D11_USAGE usage,
|
||||
_In_ unsigned int bindFlags,
|
||||
_In_ unsigned int cpuAccessFlags,
|
||||
_In_ unsigned int miscFlags,
|
||||
_In_ bool forceSRGB,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr
|
||||
);
|
||||
HRESULT CreateDDSTextureFromMemoryEx(
|
||||
_In_ ID3D11Device* d3dDevice,
|
||||
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
|
||||
_In_ size_t ddsDataSize,
|
||||
_In_ size_t maxsize,
|
||||
_In_ D3D11_USAGE usage,
|
||||
_In_ unsigned int bindFlags,
|
||||
_In_ unsigned int cpuAccessFlags,
|
||||
_In_ unsigned int miscFlags,
|
||||
_In_ bool forceSRGB,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr);
|
||||
|
||||
HRESULT CreateDDSTextureFromFileEx( _In_ ID3D11Device* d3dDevice,
|
||||
_In_z_ const wchar_t* szFileName,
|
||||
_In_ size_t maxsize,
|
||||
_In_ D3D11_USAGE usage,
|
||||
_In_ unsigned int bindFlags,
|
||||
_In_ unsigned int cpuAccessFlags,
|
||||
_In_ unsigned int miscFlags,
|
||||
_In_ bool forceSRGB,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr
|
||||
);
|
||||
HRESULT CreateDDSTextureFromFileEx(
|
||||
_In_ ID3D11Device* d3dDevice,
|
||||
_In_z_ const wchar_t* szFileName,
|
||||
_In_ size_t maxsize,
|
||||
_In_ D3D11_USAGE usage,
|
||||
_In_ unsigned int bindFlags,
|
||||
_In_ unsigned int cpuAccessFlags,
|
||||
_In_ unsigned int miscFlags,
|
||||
_In_ bool forceSRGB,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr);
|
||||
|
||||
// Extended version with optional auto-gen mipmap support
|
||||
HRESULT CreateDDSTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice,
|
||||
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
|
||||
_In_ size_t ddsDataSize,
|
||||
_In_ size_t maxsize,
|
||||
_In_ D3D11_USAGE usage,
|
||||
_In_ unsigned int bindFlags,
|
||||
_In_ unsigned int cpuAccessFlags,
|
||||
_In_ unsigned int miscFlags,
|
||||
_In_ bool forceSRGB,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr
|
||||
);
|
||||
HRESULT CreateDDSTextureFromMemoryEx(
|
||||
_In_ ID3D11Device* d3dDevice,
|
||||
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
|
||||
_In_ size_t ddsDataSize,
|
||||
_In_ size_t maxsize,
|
||||
_In_ D3D11_USAGE usage,
|
||||
_In_ unsigned int bindFlags,
|
||||
_In_ unsigned int cpuAccessFlags,
|
||||
_In_ unsigned int miscFlags,
|
||||
_In_ bool forceSRGB,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr);
|
||||
|
||||
HRESULT CreateDDSTextureFromFileEx( _In_ ID3D11Device* d3dDevice,
|
||||
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||
_In_z_ const wchar_t* szFileName,
|
||||
_In_ size_t maxsize,
|
||||
_In_ D3D11_USAGE usage,
|
||||
_In_ unsigned int bindFlags,
|
||||
_In_ unsigned int cpuAccessFlags,
|
||||
_In_ unsigned int miscFlags,
|
||||
_In_ bool forceSRGB,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr
|
||||
);
|
||||
HRESULT CreateDDSTextureFromFileEx(
|
||||
_In_ ID3D11Device* d3dDevice,
|
||||
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||
_In_z_ const wchar_t* szFileName,
|
||||
_In_ size_t maxsize,
|
||||
_In_ D3D11_USAGE usage,
|
||||
_In_ unsigned int bindFlags,
|
||||
_In_ unsigned int cpuAccessFlags,
|
||||
_In_ unsigned int miscFlags,
|
||||
_In_ bool forceSRGB,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr);
|
||||
}
|
|
@ -18,6 +18,7 @@
|
|||
// http://go.microsoft.com/fwlink/?LinkId=248926
|
||||
// http://go.microsoft.com/fwlink/?LinkId=248929
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
#include "dxut.h"
|
||||
|
||||
// Does not capture 1D textures or 3D textures (volume maps)
|
||||
|
@ -26,6 +27,8 @@
|
|||
|
||||
// For 2D array textures and cubemaps, it captures only the first image in the array
|
||||
|
||||
#include "ScreenGrab.h"
|
||||
|
||||
#include <dxgiformat.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
@ -36,8 +39,6 @@
|
|||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#include "ScreenGrab.h"
|
||||
|
||||
using Microsoft::WRL::ComPtr;
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
@ -212,7 +213,7 @@ namespace
|
|||
{
|
||||
if (m_handle)
|
||||
{
|
||||
FILE_DISPOSITION_INFO info = {0};
|
||||
FILE_DISPOSITION_INFO info = {};
|
||||
info.DeleteFile = TRUE;
|
||||
(void)SetFileInformationByHandle(m_handle, FileDispositionInfo, &info, sizeof(info));
|
||||
}
|
||||
|
@ -230,7 +231,7 @@ namespace
|
|||
class auto_delete_file_wic
|
||||
{
|
||||
public:
|
||||
auto_delete_file_wic(ComPtr<IWICStream>& hFile, LPCWSTR szFile) : m_handle(hFile), m_filename(szFile) {}
|
||||
auto_delete_file_wic(ComPtr<IWICStream>& hFile, const wchar_t* szFile) : m_handle(hFile), m_filename(szFile) {}
|
||||
~auto_delete_file_wic()
|
||||
{
|
||||
if (m_filename)
|
||||
|
@ -243,7 +244,7 @@ namespace
|
|||
void clear() { m_filename = 0; }
|
||||
|
||||
private:
|
||||
LPCWSTR m_filename;
|
||||
const wchar_t* m_filename;
|
||||
ComPtr<IWICStream>& m_handle;
|
||||
|
||||
auto_delete_file_wic(const auto_delete_file_wic&) = delete;
|
||||
|
@ -603,8 +604,8 @@ namespace
|
|||
HRESULT CaptureTexture(
|
||||
_In_ ID3D11DeviceContext* pContext,
|
||||
_In_ ID3D11Resource* pSource,
|
||||
_Inout_ D3D11_TEXTURE2D_DESC& desc,
|
||||
_Inout_ ComPtr<ID3D11Texture2D>& pStaging )
|
||||
D3D11_TEXTURE2D_DESC& desc,
|
||||
ComPtr<ID3D11Texture2D>& pStaging )
|
||||
{
|
||||
if ( !pContext || !pSource )
|
||||
return E_INVALIDARG;
|
||||
|
@ -616,7 +617,7 @@ namespace
|
|||
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
|
||||
|
||||
ComPtr<ID3D11Texture2D> pTexture;
|
||||
HRESULT hr = pSource->QueryInterface( IID_PPV_ARGS( pTexture.GetAddressOf() ) );
|
||||
HRESULT hr = pSource->QueryInterface(IID_PPV_ARGS(pTexture.GetAddressOf()));
|
||||
if ( FAILED(hr) )
|
||||
return hr;
|
||||
|
||||
|
@ -664,7 +665,7 @@ namespace
|
|||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
|
||||
desc.Usage = D3D11_USAGE_STAGING;
|
||||
|
||||
hr = d3dDevice->CreateTexture2D( &desc, 0, pStaging.GetAddressOf() );
|
||||
hr = d3dDevice->CreateTexture2D(&desc, 0, pStaging.ReleaseAndGetAddressOf());
|
||||
if ( FAILED(hr) )
|
||||
return hr;
|
||||
|
||||
|
@ -685,7 +686,7 @@ namespace
|
|||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
|
||||
desc.Usage = D3D11_USAGE_STAGING;
|
||||
|
||||
hr = d3dDevice->CreateTexture2D( &desc, 0, pStaging.GetAddressOf() );
|
||||
hr = d3dDevice->CreateTexture2D(&desc, 0, pStaging.ReleaseAndGetAddressOf());
|
||||
if ( FAILED(hr) )
|
||||
return hr;
|
||||
|
||||
|
@ -696,21 +697,68 @@ namespace
|
|||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
bool g_WIC2 = false;
|
||||
|
||||
IWICImagingFactory* _GetWIC()
|
||||
{
|
||||
static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT;
|
||||
|
||||
IWICImagingFactory* factory = nullptr;
|
||||
InitOnceExecuteOnce(&s_initOnce,
|
||||
[](PINIT_ONCE, PVOID, LPVOID *factory) -> BOOL
|
||||
{
|
||||
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
|
||||
HRESULT hr = CoCreateInstance(
|
||||
CLSID_WICImagingFactory2,
|
||||
nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
__uuidof(IWICImagingFactory2),
|
||||
factory
|
||||
);
|
||||
|
||||
if ( SUCCEEDED(hr) )
|
||||
{
|
||||
// WIC2 is available on Windows 10, Windows 8.x, and Windows 7 SP1 with KB 2670838 installed
|
||||
g_WIC2 = true;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
hr = CoCreateInstance(
|
||||
CLSID_WICImagingFactory1,
|
||||
nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
__uuidof(IWICImagingFactory),
|
||||
factory
|
||||
);
|
||||
return SUCCEEDED(hr) ? TRUE : FALSE;
|
||||
}
|
||||
#else
|
||||
return SUCCEEDED( CoCreateInstance(
|
||||
CLSID_WICImagingFactory,
|
||||
nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
__uuidof(IWICImagingFactory),
|
||||
factory) ) ? TRUE : FALSE;
|
||||
#endif
|
||||
}, nullptr, reinterpret_cast<LPVOID*>(&factory));
|
||||
|
||||
return factory;
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
extern bool g_WIC2;
|
||||
|
||||
extern IWICImagingFactory* _GetWIC();
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
HRESULT DirectX::SaveDDSTextureToFile( _In_ ID3D11DeviceContext* pContext,
|
||||
_In_ ID3D11Resource* pSource,
|
||||
_In_z_ LPCWSTR fileName )
|
||||
_In_z_ const wchar_t* fileName )
|
||||
{
|
||||
if ( !fileName )
|
||||
return E_INVALIDARG;
|
||||
|
||||
D3D11_TEXTURE2D_DESC desc = { 0 };
|
||||
D3D11_TEXTURE2D_DESC desc = {};
|
||||
ComPtr<ID3D11Texture2D> pStaging;
|
||||
HRESULT hr = CaptureTexture( pContext, pSource, desc, pStaging );
|
||||
if ( FAILED(hr) )
|
||||
|
@ -718,9 +766,9 @@ HRESULT DirectX::SaveDDSTextureToFile( _In_ ID3D11DeviceContext* pContext,
|
|||
|
||||
// Create file
|
||||
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
|
||||
ScopedHandle hFile( safe_handle( CreateFile2( fileName, GENERIC_WRITE | DELETE, 0, CREATE_ALWAYS, 0 ) ) );
|
||||
ScopedHandle hFile( safe_handle( CreateFile2( fileName, GENERIC_WRITE | DELETE, 0, CREATE_ALWAYS, nullptr ) ) );
|
||||
#else
|
||||
ScopedHandle hFile( safe_handle( CreateFileW( fileName, GENERIC_WRITE | DELETE, 0, 0, CREATE_ALWAYS, 0, 0 ) ) );
|
||||
ScopedHandle hFile( safe_handle( CreateFileW( fileName, GENERIC_WRITE | DELETE, 0, nullptr, CREATE_ALWAYS, 0, nullptr ) ) );
|
||||
#endif
|
||||
if ( !hFile )
|
||||
return HRESULT_FROM_WIN32( GetLastError() );
|
||||
|
@ -845,13 +893,13 @@ HRESULT DirectX::SaveDDSTextureToFile( _In_ ID3D11DeviceContext* pContext,
|
|||
|
||||
// Write header & pixels
|
||||
DWORD bytesWritten;
|
||||
if ( !WriteFile( hFile.get(), fileHeader, static_cast<DWORD>( headerSize ), &bytesWritten, 0 ) )
|
||||
if ( !WriteFile( hFile.get(), fileHeader, static_cast<DWORD>( headerSize ), &bytesWritten, nullptr ) )
|
||||
return HRESULT_FROM_WIN32( GetLastError() );
|
||||
|
||||
if ( bytesWritten != headerSize )
|
||||
return E_FAIL;
|
||||
|
||||
if ( !WriteFile( hFile.get(), pixels.get(), static_cast<DWORD>( slicePitch ), &bytesWritten, 0 ) )
|
||||
if ( !WriteFile( hFile.get(), pixels.get(), static_cast<DWORD>( slicePitch ), &bytesWritten, nullptr ) )
|
||||
return HRESULT_FROM_WIN32( GetLastError() );
|
||||
|
||||
if ( bytesWritten != slicePitch )
|
||||
|
@ -866,14 +914,14 @@ HRESULT DirectX::SaveDDSTextureToFile( _In_ ID3D11DeviceContext* pContext,
|
|||
HRESULT DirectX::SaveWICTextureToFile( _In_ ID3D11DeviceContext* pContext,
|
||||
_In_ ID3D11Resource* pSource,
|
||||
_In_ REFGUID guidContainerFormat,
|
||||
_In_z_ LPCWSTR fileName,
|
||||
_In_z_ const wchar_t* fileName,
|
||||
_In_opt_ const GUID* targetFormat,
|
||||
_In_opt_ std::function<void(IPropertyBag2*)> setCustomProps )
|
||||
{
|
||||
if ( !fileName )
|
||||
return E_INVALIDARG;
|
||||
|
||||
D3D11_TEXTURE2D_DESC desc = { 0 };
|
||||
D3D11_TEXTURE2D_DESC desc = {};
|
||||
ComPtr<ID3D11Texture2D> pStaging;
|
||||
HRESULT hr = CaptureTexture( pContext, pSource, desc, pStaging );
|
||||
if ( FAILED(hr) )
|
||||
|
@ -928,7 +976,7 @@ HRESULT DirectX::SaveWICTextureToFile( _In_ ID3D11DeviceContext* pContext,
|
|||
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
IWICImagingFactory* pWIC = _GetWIC();
|
||||
auto pWIC = _GetWIC();
|
||||
if ( !pWIC )
|
||||
return E_NOINTERFACE;
|
||||
|
||||
|
@ -961,7 +1009,7 @@ HRESULT DirectX::SaveWICTextureToFile( _In_ ID3D11DeviceContext* pContext,
|
|||
if ( targetFormat && memcmp( &guidContainerFormat, &GUID_ContainerFormatBmp, sizeof(WICPixelFormatGUID) ) == 0 && g_WIC2 )
|
||||
{
|
||||
// Opt-in to the WIC2 support for writing 32-bit Windows BMP files with an alpha channel
|
||||
PROPBAG2 option = { 0 };
|
||||
PROPBAG2 option = {};
|
||||
option.pstrName = const_cast<wchar_t*>(L"EnableV5Header32bppBGRA");
|
||||
|
||||
VARIANT varValue;
|
||||
|
@ -1056,11 +1104,21 @@ HRESULT DirectX::SaveWICTextureToFile( _In_ ID3D11DeviceContext* pContext,
|
|||
(void)metawriter->SetMetadataByName( L"/tEXt/{str=Software}", &value );
|
||||
|
||||
// Set sRGB chunk
|
||||
if ( sRGB )
|
||||
if (sRGB)
|
||||
{
|
||||
value.vt = VT_UI1;
|
||||
value.bVal = 0;
|
||||
(void)metawriter->SetMetadataByName( L"/sRGB/RenderingIntent", &value );
|
||||
(void)metawriter->SetMetadataByName(L"/sRGB/RenderingIntent", &value);
|
||||
}
|
||||
else
|
||||
{
|
||||
// add gAMA chunk with gamma 1.0
|
||||
value.vt = VT_UI4;
|
||||
value.uintVal = 100000; // gama value * 100,000 -- i.e. gamma 1.0
|
||||
(void)metawriter->SetMetadataByName(L"/gAMA/ImageGamma", &value);
|
||||
|
||||
// remove sRGB chunk which is added by default.
|
||||
(void)metawriter->RemoveMetadataByName(L"/sRGB/RenderingIntent");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -32,12 +32,12 @@ namespace DirectX
|
|||
{
|
||||
HRESULT SaveDDSTextureToFile( _In_ ID3D11DeviceContext* pContext,
|
||||
_In_ ID3D11Resource* pSource,
|
||||
_In_z_ LPCWSTR fileName );
|
||||
_In_z_ const wchar_t* fileName );
|
||||
|
||||
HRESULT SaveWICTextureToFile( _In_ ID3D11DeviceContext* pContext,
|
||||
_In_ ID3D11Resource* pSource,
|
||||
_In_ REFGUID guidContainerFormat,
|
||||
_In_z_ LPCWSTR fileName,
|
||||
_In_z_ const wchar_t* fileName,
|
||||
_In_opt_ const GUID* targetFormat = nullptr,
|
||||
_In_opt_ std::function<void(IPropertyBag2*)> setCustomProps = nullptr );
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,7 +1,7 @@
|
|||
//--------------------------------------------------------------------------------------
|
||||
// File: WICTextureLoader.h
|
||||
//
|
||||
// Function for loading a WIC image and creating a Direct3D 11 runtime texture for it
|
||||
// Function for loading a WIC image and creating a Direct3D runtime texture for it
|
||||
// (auto-generating mipmaps if possible)
|
||||
//
|
||||
// Note: Assumes application has already called CoInitializeEx
|
||||
|
@ -33,91 +33,98 @@
|
|||
|
||||
namespace DirectX
|
||||
{
|
||||
// Standard version
|
||||
HRESULT CreateWICTextureFromMemory( _In_ ID3D11Device* d3dDevice,
|
||||
_In_reads_bytes_(wicDataSize) const uint8_t* wicData,
|
||||
_In_ size_t wicDataSize,
|
||||
_Out_opt_ ID3D11Resource** texture,
|
||||
_Out_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0
|
||||
);
|
||||
enum WIC_LOADER_FLAGS
|
||||
{
|
||||
WIC_LOADER_DEFAULT = 0,
|
||||
WIC_LOADER_FORCE_SRGB = 0x1,
|
||||
WIC_LOADER_IGNORE_SRGB = 0x2,
|
||||
};
|
||||
|
||||
HRESULT CreateWICTextureFromFile( _In_ ID3D11Device* d3dDevice,
|
||||
_In_z_ const wchar_t* szFileName,
|
||||
_Out_opt_ ID3D11Resource** texture,
|
||||
_Out_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0
|
||||
);
|
||||
// Standard version
|
||||
HRESULT CreateWICTextureFromMemory(
|
||||
_In_ ID3D11Device* d3dDevice,
|
||||
_In_reads_bytes_(wicDataSize) const uint8_t* wicData,
|
||||
_In_ size_t wicDataSize,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0);
|
||||
|
||||
HRESULT CreateWICTextureFromFile(
|
||||
_In_ ID3D11Device* d3dDevice,
|
||||
_In_z_ const wchar_t* szFileName,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0);
|
||||
|
||||
// Standard version with optional auto-gen mipmap support
|
||||
HRESULT CreateWICTextureFromMemory( _In_ ID3D11Device* d3dDevice,
|
||||
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||
_In_reads_bytes_(wicDataSize) const uint8_t* wicData,
|
||||
_In_ size_t wicDataSize,
|
||||
_Out_opt_ ID3D11Resource** texture,
|
||||
_Out_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0
|
||||
);
|
||||
HRESULT CreateWICTextureFromMemory(
|
||||
_In_ ID3D11Device* d3dDevice,
|
||||
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||
_In_reads_bytes_(wicDataSize) const uint8_t* wicData,
|
||||
_In_ size_t wicDataSize,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0);
|
||||
|
||||
HRESULT CreateWICTextureFromFile( _In_ ID3D11Device* d3dDevice,
|
||||
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||
_In_z_ const wchar_t* szFileName,
|
||||
_Out_opt_ ID3D11Resource** texture,
|
||||
_Out_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0
|
||||
);
|
||||
HRESULT CreateWICTextureFromFile(
|
||||
_In_ ID3D11Device* d3dDevice,
|
||||
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||
_In_z_ const wchar_t* szFileName,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0);
|
||||
|
||||
// Extended version
|
||||
HRESULT CreateWICTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice,
|
||||
_In_reads_bytes_(wicDataSize) const uint8_t* wicData,
|
||||
_In_ size_t wicDataSize,
|
||||
_In_ size_t maxsize,
|
||||
_In_ D3D11_USAGE usage,
|
||||
_In_ unsigned int bindFlags,
|
||||
_In_ unsigned int cpuAccessFlags,
|
||||
_In_ unsigned int miscFlags,
|
||||
_In_ bool forceSRGB,
|
||||
_Out_opt_ ID3D11Resource** texture,
|
||||
_Out_opt_ ID3D11ShaderResourceView** textureView
|
||||
);
|
||||
HRESULT CreateWICTextureFromMemoryEx(
|
||||
_In_ ID3D11Device* d3dDevice,
|
||||
_In_reads_bytes_(wicDataSize) const uint8_t* wicData,
|
||||
_In_ size_t wicDataSize,
|
||||
_In_ size_t maxsize,
|
||||
_In_ D3D11_USAGE usage,
|
||||
_In_ unsigned int bindFlags,
|
||||
_In_ unsigned int cpuAccessFlags,
|
||||
_In_ unsigned int miscFlags,
|
||||
_In_ unsigned int loadFlags,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView);
|
||||
|
||||
HRESULT CreateWICTextureFromFileEx( _In_ ID3D11Device* d3dDevice,
|
||||
_In_z_ const wchar_t* szFileName,
|
||||
_In_ size_t maxsize,
|
||||
_In_ D3D11_USAGE usage,
|
||||
_In_ unsigned int bindFlags,
|
||||
_In_ unsigned int cpuAccessFlags,
|
||||
_In_ unsigned int miscFlags,
|
||||
_In_ bool forceSRGB,
|
||||
_Out_opt_ ID3D11Resource** texture,
|
||||
_Out_opt_ ID3D11ShaderResourceView** textureView
|
||||
);
|
||||
HRESULT CreateWICTextureFromFileEx(
|
||||
_In_ ID3D11Device* d3dDevice,
|
||||
_In_z_ const wchar_t* szFileName,
|
||||
_In_ size_t maxsize,
|
||||
_In_ D3D11_USAGE usage,
|
||||
_In_ unsigned int bindFlags,
|
||||
_In_ unsigned int cpuAccessFlags,
|
||||
_In_ unsigned int miscFlags,
|
||||
_In_ unsigned int loadFlags,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView);
|
||||
|
||||
// Extended version with optional auto-gen mipmap support
|
||||
HRESULT CreateWICTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice,
|
||||
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||
_In_reads_bytes_(wicDataSize) const uint8_t* wicData,
|
||||
_In_ size_t wicDataSize,
|
||||
_In_ size_t maxsize,
|
||||
_In_ D3D11_USAGE usage,
|
||||
_In_ unsigned int bindFlags,
|
||||
_In_ unsigned int cpuAccessFlags,
|
||||
_In_ unsigned int miscFlags,
|
||||
_In_ bool forceSRGB,
|
||||
_Out_opt_ ID3D11Resource** texture,
|
||||
_Out_opt_ ID3D11ShaderResourceView** textureView
|
||||
);
|
||||
HRESULT CreateWICTextureFromMemoryEx(
|
||||
_In_ ID3D11Device* d3dDevice,
|
||||
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||
_In_reads_bytes_(wicDataSize) const uint8_t* wicData,
|
||||
_In_ size_t wicDataSize,
|
||||
_In_ size_t maxsize,
|
||||
_In_ D3D11_USAGE usage,
|
||||
_In_ unsigned int bindFlags,
|
||||
_In_ unsigned int cpuAccessFlags,
|
||||
_In_ unsigned int miscFlags,
|
||||
_In_ unsigned int loadFlags,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView);
|
||||
|
||||
HRESULT CreateWICTextureFromFileEx( _In_ ID3D11Device* d3dDevice,
|
||||
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||
_In_z_ const wchar_t* szFileName,
|
||||
_In_ size_t maxsize,
|
||||
_In_ D3D11_USAGE usage,
|
||||
_In_ unsigned int bindFlags,
|
||||
_In_ unsigned int cpuAccessFlags,
|
||||
_In_ unsigned int miscFlags,
|
||||
_In_ bool forceSRGB,
|
||||
_Out_opt_ ID3D11Resource** texture,
|
||||
_Out_opt_ ID3D11ShaderResourceView** textureView
|
||||
);
|
||||
HRESULT CreateWICTextureFromFileEx(
|
||||
_In_ ID3D11Device* d3dDevice,
|
||||
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||
_In_z_ const wchar_t* szFileName,
|
||||
_In_ size_t maxsize,
|
||||
_In_ D3D11_USAGE usage,
|
||||
_In_ unsigned int bindFlags,
|
||||
_In_ unsigned int cpuAccessFlags,
|
||||
_In_ unsigned int miscFlags,
|
||||
_In_ unsigned int loadFlags,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView);
|
||||
}
|
Загрузка…
Ссылка в новой задаче