From f8871159b391da0894e2365728b96d16897f41a6 Mon Sep 17 00:00:00 2001 From: walbourn_cp Date: Tue, 9 Oct 2012 14:53:39 -0700 Subject: [PATCH] Screengrab updated to handle SRGB formats --- Src/ScreenGrab.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Src/ScreenGrab.cpp b/Src/ScreenGrab.cpp index 0b1b1fc13..273937010 100644 --- a/Src/ScreenGrab.cpp +++ b/Src/ScreenGrab.cpp @@ -572,9 +572,6 @@ HRESULT DirectX::SaveWICTextureToFile( _In_ ID3D11DeviceContext* pContext, case DXGI_FORMAT_R32G32B32A32_FLOAT: pfGuid = GUID_WICPixelFormat128bppRGBAFloat; break; case DXGI_FORMAT_R16G16B16A16_FLOAT: pfGuid = GUID_WICPixelFormat64bppRGBAHalf; break; case DXGI_FORMAT_R16G16B16A16_UNORM: pfGuid = GUID_WICPixelFormat64bppRGBA; break; - case DXGI_FORMAT_R8G8B8A8_UNORM: pfGuid = GUID_WICPixelFormat32bppRGBA; break; - case DXGI_FORMAT_B8G8R8A8_UNORM: pfGuid = GUID_WICPixelFormat32bppBGRA; break; // DXGI 1.1 - case DXGI_FORMAT_B8G8R8X8_UNORM: pfGuid = GUID_WICPixelFormat32bppBGR; break; // DXGI 1.1 case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: pfGuid = GUID_WICPixelFormat32bppRGBA1010102XR; break; // DXGI 1.1 case DXGI_FORMAT_R10G10B10A2_UNORM: pfGuid = GUID_WICPixelFormat32bppRGBA1010102; break; case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: pfGuid = GUID_WICPixelFormat32bppRGBE; break; @@ -586,6 +583,21 @@ HRESULT DirectX::SaveWICTextureToFile( _In_ ID3D11DeviceContext* pContext, case DXGI_FORMAT_R8_UNORM: pfGuid = GUID_WICPixelFormat8bppGray; break; case DXGI_FORMAT_A8_UNORM: pfGuid = GUID_WICPixelFormat8bppAlpha; break; + case DXGI_FORMAT_R8G8B8A8_UNORM: + case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: + pfGuid = GUID_WICPixelFormat32bppRGBA; + break; + + case DXGI_FORMAT_B8G8R8A8_UNORM: // DXGI 1.1 + case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: + pfGuid = GUID_WICPixelFormat32bppBGRA; + break; + + case DXGI_FORMAT_B8G8R8X8_UNORM: // DXGI 1.1 + case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: + pfGuid = GUID_WICPixelFormat32bppBGR; + break; + default: return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); }