@@ -140,6 +140,7 @@ namespace
140
140
OPT_INVERT_Y,
141
141
OPT_RECONSTRUCT_Z,
142
142
OPT_BCNONMULT4FIX,
143
+ OPT_IGNORE_SRGB_METADATA,
143
144
#ifdef USE_XBOX_EXTS
144
145
OPT_USE_XBOX,
145
146
OPT_XGMODE,
@@ -282,6 +283,7 @@ namespace
282
283
{ L" help" , OPT_HELP },
283
284
{ L" horizontal-flip" , OPT_HFLIP },
284
285
{ L" ignore-mips" , OPT_DDS_IGNORE_MIPS },
286
+ { L" ignore-srgb" , OPT_IGNORE_SRGB_METADATA },
285
287
{ L" image-filter" , OPT_FILTER },
286
288
{ L" invert-y" , OPT_INVERT_Y },
287
289
{ L" keep-coverage" , OPT_PRESERVE_ALPHA_COVERAGE },
@@ -817,6 +819,9 @@ namespace
817
819
L" -xgmode <mode>, --xbox-mode <mode>\n " \
818
820
L" Tile/swizzle using provided memory layout mode\n "
819
821
#endif
822
+ L" \n "
823
+ L" (PNG, JPG, TIF, TGA input only)\n "
824
+ L" --ignore-srgb Ignores any gamma setting in the metadata\n "
820
825
L" \n "
821
826
L" (TGA input only)\n "
822
827
L" --tga-zero-alpha Allow all zero alpha channel files to be loaded 'as is'\n "
@@ -2088,6 +2093,10 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
2088
2093
else if (_wcsicmp (ext.c_str (), L" .tga" ) == 0 )
2089
2094
{
2090
2095
TGA_FLAGS tgaFlags = (IsBGR (format)) ? TGA_FLAGS_BGR : TGA_FLAGS_NONE;
2096
+ if (dwOptions & (UINT64_C (1 ) << OPT_IGNORE_SRGB_METADATA))
2097
+ {
2098
+ tgaFlags |= TGA_FLAGS_IGNORE_SRGB;
2099
+ }
2091
2100
if (dwOptions & (UINT64_C (1 ) << OPT_TGAZEROALPHA))
2092
2101
{
2093
2102
tgaFlags |= TGA_FLAGS_ALLOW_ALL_ZERO_ALPHA;
@@ -2179,7 +2188,13 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
2179
2188
2180
2189
WIC_FLAGS wicFlags = WIC_FLAGS_NONE | dwFilter;
2181
2190
if (FileType == CODEC_DDS)
2191
+ {
2182
2192
wicFlags |= WIC_FLAGS_ALL_FRAMES;
2193
+ }
2194
+ if (dwOptions & (UINT64_C (1 ) << OPT_IGNORE_SRGB_METADATA))
2195
+ {
2196
+ wicFlags |= WIC_FLAGS_IGNORE_SRGB;
2197
+ }
2183
2198
2184
2199
hr = LoadFromWICFile (curpath.c_str (), wicFlags, &info, *image);
2185
2200
if (FAILED (hr))
@@ -3798,13 +3813,13 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
3798
3813
switch (FileType)
3799
3814
{
3800
3815
case WIC_CODEC_JPEG:
3801
- if (wicLossless || wicQuality >= 0 .f )
3816
+ if (wicQuality >= 0 .f )
3802
3817
{
3803
3818
PROPBAG2 options = {};
3804
3819
VARIANT varValues = {};
3805
3820
options.pstrName = const_cast <wchar_t *>(L" ImageQuality" );
3806
3821
varValues.vt = VT_R4;
3807
- varValues.fltVal = (wicLossless) ? 1 . f : wicQuality;
3822
+ varValues.fltVal = wicQuality;
3808
3823
std::ignore = props->Write (1 , &options, &varValues);
3809
3824
}
3810
3825
break ;
@@ -3829,6 +3844,30 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
3829
3844
}
3830
3845
break ;
3831
3846
3847
+ case WIC_CODEC_HEIF:
3848
+ {
3849
+ PROPBAG2 options = {};
3850
+ VARIANT varValues = {};
3851
+ if (wicLossless)
3852
+ {
3853
+ options.pstrName = const_cast <wchar_t *>(L" HeifCompressionMethod" );
3854
+ varValues.vt = VT_UI1;
3855
+ #if defined(NTDDI_WIN10_CU)
3856
+ varValues.bVal = WICHeifCompressionNone;
3857
+ #else
3858
+ varValues.bVal = 0x1 /* WICHeifCompressionNone */ ;
3859
+ #endif
3860
+ }
3861
+ else if (wicQuality >= 0 .f )
3862
+ {
3863
+ options.pstrName = const_cast <wchar_t *>(L" ImageQuality" );
3864
+ varValues.vt = VT_R4;
3865
+ varValues.fltVal = wicQuality;
3866
+ }
3867
+ std::ignore = props->Write (1 , &options, &varValues);
3868
+ }
3869
+ break ;
3870
+
3832
3871
case WIC_CODEC_WMP:
3833
3872
case CODEC_HDP:
3834
3873
case CODEC_JXR:
0 commit comments