Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

texconv: add --ignore-srgb, --wic-uncompressed and revisit --wic-lossless #555

Merged
merged 3 commits into from
Nov 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 41 additions & 2 deletions Texconv/texconv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ namespace
OPT_INVERT_Y,
OPT_RECONSTRUCT_Z,
OPT_BCNONMULT4FIX,
OPT_IGNORE_SRGB_METADATA,
#ifdef USE_XBOX_EXTS
OPT_USE_XBOX,
OPT_XGMODE,
Expand Down Expand Up @@ -282,6 +283,7 @@ namespace
{ L"help", OPT_HELP },
{ L"horizontal-flip", OPT_HFLIP },
{ L"ignore-mips", OPT_DDS_IGNORE_MIPS },
{ L"ignore-srgb", OPT_IGNORE_SRGB_METADATA },
{ L"image-filter", OPT_FILTER },
{ L"invert-y", OPT_INVERT_Y },
{ L"keep-coverage", OPT_PRESERVE_ALPHA_COVERAGE },
Expand Down Expand Up @@ -817,6 +819,9 @@ namespace
L" -xgmode <mode>, --xbox-mode <mode>\n"\
L" Tile/swizzle using provided memory layout mode\n"
#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" (TGA input only)\n"
L" --tga-zero-alpha Allow all zero alpha channel files to be loaded 'as is'\n"
Expand Down Expand Up @@ -2088,6 +2093,10 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
else if (_wcsicmp(ext.c_str(), L".tga") == 0)
{
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))
{
tgaFlags |= TGA_FLAGS_ALLOW_ALL_ZERO_ALPHA;
Expand Down Expand Up @@ -2179,7 +2188,13 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])

WIC_FLAGS wicFlags = WIC_FLAGS_NONE | dwFilter;
if (FileType == CODEC_DDS)
{
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);
if (FAILED(hr))
Expand Down Expand Up @@ -3798,13 +3813,13 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
switch (FileType)
{
case WIC_CODEC_JPEG:
if (wicLossless || wicQuality >= 0.f)
if (wicQuality >= 0.f)
{
PROPBAG2 options = {};
VARIANT varValues = {};
options.pstrName = const_cast<wchar_t*>(L"ImageQuality");
varValues.vt = VT_R4;
varValues.fltVal = (wicLossless) ? 1.f : wicQuality;
varValues.fltVal = wicQuality;
std::ignore = props->Write(1, &options, &varValues);
}
break;
Expand All @@ -3829,6 +3844,30 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
}
break;

case WIC_CODEC_HEIF:
{
PROPBAG2 options = {};
VARIANT varValues = {};
if (wicLossless)
{
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 CODEC_HDP:
case CODEC_JXR:
Expand Down
Loading