Minor fixes for WICTextureLoader

This commit is contained in:
Chuck Walbourn 2016-12-08 14:26:41 -08:00
parent 0abee99a11
commit 101c306eaf
2 changed files with 9 additions and 7 deletions

View File

@ -353,12 +353,12 @@ namespace
if (width > height) if (width > height)
{ {
twidth = static_cast<UINT>(maxsize); twidth = static_cast<UINT>(maxsize);
theight = static_cast<UINT>(static_cast<float>(maxsize) * ar); theight = std::max<UINT>(1, static_cast<UINT>(static_cast<float>(maxsize) * ar));
} }
else else
{ {
theight = static_cast<UINT>(maxsize); theight = static_cast<UINT>(maxsize);
twidth = static_cast<UINT>(static_cast<float>(maxsize) / ar); twidth = std::max<UINT>(1, static_cast<UINT>(static_cast<float>(maxsize) / ar));
} }
assert(twidth <= maxsize && theight <= maxsize); assert(twidth <= maxsize && theight <= maxsize);
} }
@ -389,12 +389,14 @@ namespace
{ {
memcpy(&convertGUID, &GUID_WICPixelFormat96bppRGBFloat, sizeof(WICPixelFormatGUID)); memcpy(&convertGUID, &GUID_WICPixelFormat96bppRGBFloat, sizeof(WICPixelFormatGUID));
format = DXGI_FORMAT_R32G32B32_FLOAT; format = DXGI_FORMAT_R32G32B32_FLOAT;
bpp = 96;
} }
else else
#endif #endif
{ {
memcpy(&convertGUID, &GUID_WICPixelFormat128bppRGBAFloat, sizeof(WICPixelFormatGUID)); memcpy(&convertGUID, &GUID_WICPixelFormat128bppRGBAFloat, sizeof(WICPixelFormatGUID));
format = DXGI_FORMAT_R32G32B32A32_FLOAT; format = DXGI_FORMAT_R32G32B32A32_FLOAT;
bpp = 128;
} }
} }
else else
@ -472,7 +474,7 @@ namespace
sRGB = true; sRGB = true;
} }
PropVariantClear(&value); (void)PropVariantClear(&value);
if (sRGB) if (sRGB)
format = MakeSRGB(format); format = MakeSRGB(format);

View File

@ -296,12 +296,12 @@ namespace
if (width > height) if (width > height)
{ {
twidth = static_cast<UINT>(maxsize); twidth = static_cast<UINT>(maxsize);
theight = static_cast<UINT>(static_cast<float>(maxsize) * ar); theight = std::max<UINT>(1, static_cast<UINT>(static_cast<float>(maxsize) * ar));
} }
else else
{ {
theight = static_cast<UINT>(maxsize); theight = static_cast<UINT>(maxsize);
twidth = static_cast<UINT>(static_cast<float>(maxsize) / ar); twidth = std::max<UINT>(1, static_cast<UINT>(static_cast<float>(maxsize) / ar));
} }
assert(twidth <= maxsize && theight <= maxsize); assert(twidth <= maxsize && theight <= maxsize);
} }
@ -381,7 +381,7 @@ namespace
sRGB = true; sRGB = true;
} }
PropVariantClear(&value); (void)PropVariantClear(&value);
if (sRGB) if (sRGB)
format = MakeSRGB(format); format = MakeSRGB(format);