mirror of
https://github.com/microsoft/DirectXTex.git
synced 2025-07-09 19:50:13 +02:00
Code review feedback
This commit is contained in:
parent
a30c37220b
commit
1dec86435d
@ -483,6 +483,9 @@ namespace DirectX
|
|||||||
TEX_PMALPHA_IGNORE_SRGB = 0x1,
|
TEX_PMALPHA_IGNORE_SRGB = 0x1,
|
||||||
// ignores sRGB colorspace conversions
|
// ignores sRGB colorspace conversions
|
||||||
|
|
||||||
|
TEX_PMALPHA_REVERSE = 0x2,
|
||||||
|
// converts from premultiplied alpha back to straight alpha
|
||||||
|
|
||||||
TEX_PMALPHA_SRGB_IN = 0x1000000,
|
TEX_PMALPHA_SRGB_IN = 0x1000000,
|
||||||
TEX_PMALPHA_SRGB_OUT = 0x2000000,
|
TEX_PMALPHA_SRGB_OUT = 0x2000000,
|
||||||
TEX_PMALPHA_SRGB = ( TEX_PMALPHA_SRGB_IN | TEX_PMALPHA_SRGB_OUT ),
|
TEX_PMALPHA_SRGB = ( TEX_PMALPHA_SRGB_IN | TEX_PMALPHA_SRGB_OUT ),
|
||||||
@ -490,9 +493,9 @@ namespace DirectX
|
|||||||
// if the output format type is IsSRGB(), then SRGB_OUT is on by default
|
// if the output format type is IsSRGB(), then SRGB_OUT is on by default
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT __cdecl PremultiplyAlpha( _In_ const Image& srcImage, _In_ DWORD flags, _Out_ ScratchImage& image, bool reverse = false );
|
HRESULT __cdecl PremultiplyAlpha( _In_ const Image& srcImage, _In_ DWORD flags, _Out_ ScratchImage& image );
|
||||||
HRESULT __cdecl PremultiplyAlpha( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
HRESULT __cdecl PremultiplyAlpha( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
||||||
_In_ DWORD flags, _Out_ ScratchImage& result, bool reverse = false);
|
_In_ DWORD flags, _Out_ ScratchImage& result );
|
||||||
// Converts to/from a premultiplied alpha version of the texture
|
// Converts to/from a premultiplied alpha version of the texture
|
||||||
|
|
||||||
enum TEX_COMPRESS_FLAGS
|
enum TEX_COMPRESS_FLAGS
|
||||||
|
@ -198,8 +198,7 @@ _Use_decl_annotations_
|
|||||||
HRESULT DirectX::PremultiplyAlpha(
|
HRESULT DirectX::PremultiplyAlpha(
|
||||||
const Image& srcImage,
|
const Image& srcImage,
|
||||||
DWORD flags,
|
DWORD flags,
|
||||||
ScratchImage& image,
|
ScratchImage& image)
|
||||||
bool reverse)
|
|
||||||
{
|
{
|
||||||
if (!srcImage.pixels)
|
if (!srcImage.pixels)
|
||||||
return E_POINTER;
|
return E_POINTER;
|
||||||
@ -225,7 +224,7 @@ HRESULT DirectX::PremultiplyAlpha(
|
|||||||
return E_POINTER;
|
return E_POINTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reverse)
|
if (flags & TEX_PMALPHA_REVERSE)
|
||||||
{
|
{
|
||||||
hr = (flags & TEX_PMALPHA_IGNORE_SRGB) ? DemultiplyAlpha(srcImage, *rimage) : DemultiplyAlphaLinear(srcImage, flags, *rimage);
|
hr = (flags & TEX_PMALPHA_IGNORE_SRGB) ? DemultiplyAlpha(srcImage, *rimage) : DemultiplyAlphaLinear(srcImage, flags, *rimage);
|
||||||
}
|
}
|
||||||
@ -252,8 +251,7 @@ HRESULT DirectX::PremultiplyAlpha(
|
|||||||
size_t nimages,
|
size_t nimages,
|
||||||
const TexMetadata& metadata,
|
const TexMetadata& metadata,
|
||||||
DWORD flags,
|
DWORD flags,
|
||||||
ScratchImage& result,
|
ScratchImage& result)
|
||||||
bool reverse)
|
|
||||||
{
|
{
|
||||||
if (!srcImages || !nimages)
|
if (!srcImages || !nimages)
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
@ -268,11 +266,11 @@ HRESULT DirectX::PremultiplyAlpha(
|
|||||||
if ((metadata.width > UINT32_MAX) || (metadata.height > UINT32_MAX))
|
if ((metadata.width > UINT32_MAX) || (metadata.height > UINT32_MAX))
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
if (metadata.IsPMAlpha() != reverse)
|
if (metadata.IsPMAlpha() != ((flags & TEX_PMALPHA_REVERSE) != 0))
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
TexMetadata mdata2 = metadata;
|
TexMetadata mdata2 = metadata;
|
||||||
mdata2.SetAlphaMode(reverse ? TEX_ALPHA_MODE_STRAIGHT : TEX_ALPHA_MODE_PREMULTIPLIED);
|
mdata2.SetAlphaMode((flags & TEX_PMALPHA_REVERSE) ? TEX_ALPHA_MODE_STRAIGHT : TEX_ALPHA_MODE_PREMULTIPLIED);
|
||||||
HRESULT hr = result.Initialize(mdata2);
|
HRESULT hr = result.Initialize(mdata2);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return hr;
|
return hr;
|
||||||
@ -311,7 +309,7 @@ HRESULT DirectX::PremultiplyAlpha(
|
|||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reverse)
|
if (flags & TEX_PMALPHA_REVERSE)
|
||||||
{
|
{
|
||||||
hr = (flags & TEX_PMALPHA_IGNORE_SRGB) ? DemultiplyAlpha(src, dst) : DemultiplyAlphaLinear(src, flags, dst);
|
hr = (flags & TEX_PMALPHA_IGNORE_SRGB) ? DemultiplyAlpha(src, dst) : DemultiplyAlphaLinear(src, flags, dst);
|
||||||
}
|
}
|
||||||
|
@ -1557,7 +1557,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = PremultiplyAlpha(img, nimg, info, dwSRGB, *timage, true);
|
hr = PremultiplyAlpha(img, nimg, info, TEX_PMALPHA_REVERSE | dwSRGB, *timage);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
wprintf(L" FAILED [demultiply alpha] (%x)\n", hr);
|
wprintf(L" FAILED [demultiply alpha] (%x)\n", hr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user