texconv: add --ignore-srgb, --wic-uncompressed and revisit --wic-lossless (#555)
This commit is contained in:
Родитель
37a18e9021
Коммит
2b6f585157
|
@ -117,6 +117,7 @@ namespace
|
||||||
OPT_TGAZEROALPHA,
|
OPT_TGAZEROALPHA,
|
||||||
OPT_WIC_LOSSLESS,
|
OPT_WIC_LOSSLESS,
|
||||||
OPT_WIC_MULTIFRAME,
|
OPT_WIC_MULTIFRAME,
|
||||||
|
OPT_WIC_UNCOMPRESSED,
|
||||||
OPT_NOLOGO,
|
OPT_NOLOGO,
|
||||||
OPT_TIMING,
|
OPT_TIMING,
|
||||||
OPT_SEPALPHA,
|
OPT_SEPALPHA,
|
||||||
|
@ -140,6 +141,7 @@ namespace
|
||||||
OPT_INVERT_Y,
|
OPT_INVERT_Y,
|
||||||
OPT_RECONSTRUCT_Z,
|
OPT_RECONSTRUCT_Z,
|
||||||
OPT_BCNONMULT4FIX,
|
OPT_BCNONMULT4FIX,
|
||||||
|
OPT_IGNORE_SRGB_METADATA,
|
||||||
#ifdef USE_XBOX_EXTS
|
#ifdef USE_XBOX_EXTS
|
||||||
OPT_USE_XBOX,
|
OPT_USE_XBOX,
|
||||||
OPT_XGMODE,
|
OPT_XGMODE,
|
||||||
|
@ -282,6 +284,7 @@ namespace
|
||||||
{ L"help", OPT_HELP },
|
{ L"help", OPT_HELP },
|
||||||
{ L"horizontal-flip", OPT_HFLIP },
|
{ L"horizontal-flip", OPT_HFLIP },
|
||||||
{ L"ignore-mips", OPT_DDS_IGNORE_MIPS },
|
{ L"ignore-mips", OPT_DDS_IGNORE_MIPS },
|
||||||
|
{ L"ignore-srgb", OPT_IGNORE_SRGB_METADATA },
|
||||||
{ L"image-filter", OPT_FILTER },
|
{ L"image-filter", OPT_FILTER },
|
||||||
{ L"invert-y", OPT_INVERT_Y },
|
{ L"invert-y", OPT_INVERT_Y },
|
||||||
{ L"keep-coverage", OPT_PRESERVE_ALPHA_COVERAGE },
|
{ L"keep-coverage", OPT_PRESERVE_ALPHA_COVERAGE },
|
||||||
|
@ -311,6 +314,7 @@ namespace
|
||||||
{ L"vertical-flip", OPT_VFLIP },
|
{ L"vertical-flip", OPT_VFLIP },
|
||||||
{ L"wic-lossless", OPT_WIC_LOSSLESS },
|
{ L"wic-lossless", OPT_WIC_LOSSLESS },
|
||||||
{ L"wic-multiframe", OPT_WIC_MULTIFRAME },
|
{ L"wic-multiframe", OPT_WIC_MULTIFRAME },
|
||||||
|
{ L"wic-uncompressed", OPT_WIC_UNCOMPRESSED },
|
||||||
{ L"wic-quality", OPT_WIC_QUALITY },
|
{ L"wic-quality", OPT_WIC_QUALITY },
|
||||||
{ L"width", OPT_WIDTH },
|
{ L"width", OPT_WIDTH },
|
||||||
{ L"x2-bias", OPT_X2_BIAS },
|
{ L"x2-bias", OPT_X2_BIAS },
|
||||||
|
@ -591,7 +595,6 @@ namespace
|
||||||
#ifdef USE_OPENEXR
|
#ifdef USE_OPENEXR
|
||||||
{ L"exr", CODEC_EXR },
|
{ L"exr", CODEC_EXR },
|
||||||
#endif
|
#endif
|
||||||
{ L"heic", WIC_CODEC_HEIF },
|
|
||||||
{ L"heif", WIC_CODEC_HEIF },
|
{ L"heif", WIC_CODEC_HEIF },
|
||||||
{ nullptr, CODEC_DDS }
|
{ nullptr, CODEC_DDS }
|
||||||
};
|
};
|
||||||
|
@ -817,6 +820,9 @@ namespace
|
||||||
L" -xgmode <mode>, --xbox-mode <mode>\n"\
|
L" -xgmode <mode>, --xbox-mode <mode>\n"\
|
||||||
L" Tile/swizzle using provided memory layout mode\n"
|
L" Tile/swizzle using provided memory layout mode\n"
|
||||||
#endif
|
#endif
|
||||||
|
L"\n"
|
||||||
|
L" (PNG, JPG, TIF, TGA input only)\n"
|
||||||
|
L" --ignore-srgb Ignores any gamma setting in the metadata\n"
|
||||||
L"\n"
|
L"\n"
|
||||||
L" (TGA input only)\n"
|
L" (TGA input only)\n"
|
||||||
L" --tga-zero-alpha Allow all zero alpha channel files to be loaded 'as is'\n"
|
L" --tga-zero-alpha Allow all zero alpha channel files to be loaded 'as is'\n"
|
||||||
|
@ -824,10 +830,11 @@ namespace
|
||||||
L" (TGA output only)\n"
|
L" (TGA output only)\n"
|
||||||
L" -tga20 Write file including TGA 2.0 extension area\n"
|
L" -tga20 Write file including TGA 2.0 extension area\n"
|
||||||
L"\n"
|
L"\n"
|
||||||
L" (BMP, PNG, JPG, TIF, WDP output only)\n"
|
L" (BMP, PNG, JPG, TIF, WDP, and HIEF output only)\n"
|
||||||
L" -wicq <quality>, --wic-quality <quality>\n"
|
L" -wicq <quality>, --wic-quality <quality>\n"
|
||||||
L" When writing images with WIC use quality (0.0 to 1.0)\n"
|
L" When writing images with WIC use quality (0.0 to 1.0)\n"
|
||||||
L" --wic-lossless When writing images with WIC use lossless mode\n"
|
L" --wic-lossless When writing images with WIC use lossless mode\n"
|
||||||
|
L" --wic-uncompressed When writing images with WIC use uncompressed mode\n"
|
||||||
L" --wic-multiframe When writing images with WIC encode multiframe images\n"
|
L" --wic-multiframe When writing images with WIC encode multiframe images\n"
|
||||||
L"\n"
|
L"\n"
|
||||||
L" -nologo suppress copyright message\n"
|
L" -nologo suppress copyright message\n"
|
||||||
|
@ -2088,6 +2095,10 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||||
else if (_wcsicmp(ext.c_str(), L".tga") == 0)
|
else if (_wcsicmp(ext.c_str(), L".tga") == 0)
|
||||||
{
|
{
|
||||||
TGA_FLAGS tgaFlags = (IsBGR(format)) ? TGA_FLAGS_BGR : TGA_FLAGS_NONE;
|
TGA_FLAGS tgaFlags = (IsBGR(format)) ? TGA_FLAGS_BGR : TGA_FLAGS_NONE;
|
||||||
|
if (dwOptions & (UINT64_C(1) << OPT_IGNORE_SRGB_METADATA))
|
||||||
|
{
|
||||||
|
tgaFlags |= TGA_FLAGS_IGNORE_SRGB;
|
||||||
|
}
|
||||||
if (dwOptions & (UINT64_C(1) << OPT_TGAZEROALPHA))
|
if (dwOptions & (UINT64_C(1) << OPT_TGAZEROALPHA))
|
||||||
{
|
{
|
||||||
tgaFlags |= TGA_FLAGS_ALLOW_ALL_ZERO_ALPHA;
|
tgaFlags |= TGA_FLAGS_ALLOW_ALL_ZERO_ALPHA;
|
||||||
|
@ -2179,7 +2190,13 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||||
|
|
||||||
WIC_FLAGS wicFlags = WIC_FLAGS_NONE | dwFilter;
|
WIC_FLAGS wicFlags = WIC_FLAGS_NONE | dwFilter;
|
||||||
if (FileType == CODEC_DDS)
|
if (FileType == CODEC_DDS)
|
||||||
|
{
|
||||||
wicFlags |= WIC_FLAGS_ALL_FRAMES;
|
wicFlags |= WIC_FLAGS_ALL_FRAMES;
|
||||||
|
}
|
||||||
|
if (dwOptions & (UINT64_C(1) << OPT_IGNORE_SRGB_METADATA))
|
||||||
|
{
|
||||||
|
wicFlags |= WIC_FLAGS_IGNORE_SRGB;
|
||||||
|
}
|
||||||
|
|
||||||
hr = LoadFromWICFile(curpath.c_str(), wicFlags, &info, *image);
|
hr = LoadFromWICFile(curpath.c_str(), wicFlags, &info, *image);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
|
@ -2194,7 +2211,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||||
}
|
}
|
||||||
else if (_wcsicmp(ext.c_str(), L".webp") == 0)
|
else if (_wcsicmp(ext.c_str(), L".webp") == 0)
|
||||||
{
|
{
|
||||||
wprintf(L"INFO: This format requires installing the WEBP Image Extensions - https://www.microsoft.com/p/webp-image-extensions/9pg2dk419drg\n");
|
wprintf(L"INFO: This format requires installing the WEBP Image Extensions - https://apps.microsoft.com/detail/9PG2DK419DRG\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -3793,18 +3810,20 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||||
hr = SaveToWICFile(img, nimages, WIC_FLAGS_NONE, GetWICCodec(codec), destName.c_str(), nullptr,
|
hr = SaveToWICFile(img, nimages, WIC_FLAGS_NONE, GetWICCodec(codec), destName.c_str(), nullptr,
|
||||||
[&](IPropertyBag2* props)
|
[&](IPropertyBag2* props)
|
||||||
{
|
{
|
||||||
const bool wicLossless = (dwOptions & (UINT64_C(1) << OPT_WIC_LOSSLESS)) != 0;
|
const bool lossless = (dwOptions & (UINT64_C(1) << OPT_WIC_LOSSLESS)) != 0;
|
||||||
|
const bool uncompressed = (dwOptions & (UINT64_C(1) << OPT_WIC_UNCOMPRESSED)) != 0;
|
||||||
|
|
||||||
switch (FileType)
|
switch (FileType)
|
||||||
{
|
{
|
||||||
|
default:
|
||||||
case WIC_CODEC_JPEG:
|
case WIC_CODEC_JPEG:
|
||||||
if (wicLossless || wicQuality >= 0.f)
|
if (wicQuality >= 0.f)
|
||||||
{
|
{
|
||||||
PROPBAG2 options = {};
|
PROPBAG2 options = {};
|
||||||
VARIANT varValues = {};
|
VARIANT varValues = {};
|
||||||
options.pstrName = const_cast<wchar_t*>(L"ImageQuality");
|
options.pstrName = const_cast<wchar_t*>(L"ImageQuality");
|
||||||
varValues.vt = VT_R4;
|
varValues.vt = VT_R4;
|
||||||
varValues.fltVal = (wicLossless) ? 1.f : wicQuality;
|
varValues.fltVal = wicQuality;
|
||||||
std::ignore = props->Write(1, &options, &varValues);
|
std::ignore = props->Write(1, &options, &varValues);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -3813,7 +3832,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||||
{
|
{
|
||||||
PROPBAG2 options = {};
|
PROPBAG2 options = {};
|
||||||
VARIANT varValues = {};
|
VARIANT varValues = {};
|
||||||
if (wicLossless)
|
if (uncompressed)
|
||||||
{
|
{
|
||||||
options.pstrName = const_cast<wchar_t*>(L"TiffCompressionMethod");
|
options.pstrName = const_cast<wchar_t*>(L"TiffCompressionMethod");
|
||||||
varValues.vt = VT_UI1;
|
varValues.vt = VT_UI1;
|
||||||
|
@ -3829,13 +3848,37 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WIC_CODEC_HEIF:
|
||||||
|
{
|
||||||
|
PROPBAG2 options = {};
|
||||||
|
VARIANT varValues = {};
|
||||||
|
if (uncompressed)
|
||||||
|
{
|
||||||
|
options.pstrName = const_cast<wchar_t*>(L"HeifCompressionMethod");
|
||||||
|
varValues.vt = VT_UI1;
|
||||||
|
#if defined(NTDDI_WIN10_CU)
|
||||||
|
varValues.bVal = WICHeifCompressionNone;
|
||||||
|
#else
|
||||||
|
varValues.bVal = 0x1 /* WICHeifCompressionNone */;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if (wicQuality >= 0.f)
|
||||||
|
{
|
||||||
|
options.pstrName = const_cast<wchar_t*>(L"ImageQuality");
|
||||||
|
varValues.vt = VT_R4;
|
||||||
|
varValues.fltVal = wicQuality;
|
||||||
|
}
|
||||||
|
std::ignore = props->Write(1, &options, &varValues);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case WIC_CODEC_WMP:
|
case WIC_CODEC_WMP:
|
||||||
case CODEC_HDP:
|
case CODEC_HDP:
|
||||||
case CODEC_JXR:
|
case CODEC_JXR:
|
||||||
{
|
{
|
||||||
PROPBAG2 options = {};
|
PROPBAG2 options = {};
|
||||||
VARIANT varValues = {};
|
VARIANT varValues = {};
|
||||||
if (wicLossless)
|
if (lossless)
|
||||||
{
|
{
|
||||||
options.pstrName = const_cast<wchar_t*>(L"Lossless");
|
options.pstrName = const_cast<wchar_t*>(L"Lossless");
|
||||||
varValues.vt = VT_BOOL;
|
varValues.vt = VT_BOOL;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче