@@ -117,6 +117,7 @@ namespace
117
117
OPT_TGAZEROALPHA,
118
118
OPT_WIC_LOSSLESS,
119
119
OPT_WIC_MULTIFRAME,
120
+ OPT_WIC_UNCOMPRESSED,
120
121
OPT_NOLOGO,
121
122
OPT_TIMING,
122
123
OPT_SEPALPHA,
@@ -140,6 +141,7 @@ namespace
140
141
OPT_INVERT_Y,
141
142
OPT_RECONSTRUCT_Z,
142
143
OPT_BCNONMULT4FIX,
144
+ OPT_IGNORE_SRGB_METADATA,
143
145
#ifdef USE_XBOX_EXTS
144
146
OPT_USE_XBOX,
145
147
OPT_XGMODE,
@@ -282,6 +284,7 @@ namespace
282
284
{ L" help" , OPT_HELP },
283
285
{ L" horizontal-flip" , OPT_HFLIP },
284
286
{ L" ignore-mips" , OPT_DDS_IGNORE_MIPS },
287
+ { L" ignore-srgb" , OPT_IGNORE_SRGB_METADATA },
285
288
{ L" image-filter" , OPT_FILTER },
286
289
{ L" invert-y" , OPT_INVERT_Y },
287
290
{ L" keep-coverage" , OPT_PRESERVE_ALPHA_COVERAGE },
@@ -311,6 +314,7 @@ namespace
311
314
{ L" vertical-flip" , OPT_VFLIP },
312
315
{ L" wic-lossless" , OPT_WIC_LOSSLESS },
313
316
{ L" wic-multiframe" , OPT_WIC_MULTIFRAME },
317
+ { L" wic-uncompressed" , OPT_WIC_UNCOMPRESSED },
314
318
{ L" wic-quality" , OPT_WIC_QUALITY },
315
319
{ L" width" , OPT_WIDTH },
316
320
{ L" x2-bias" , OPT_X2_BIAS },
@@ -591,7 +595,6 @@ namespace
591
595
#ifdef USE_OPENEXR
592
596
{ L" exr" , CODEC_EXR },
593
597
#endif
594
- { L" heic" , WIC_CODEC_HEIF },
595
598
{ L" heif" , WIC_CODEC_HEIF },
596
599
{ nullptr , CODEC_DDS }
597
600
};
@@ -817,17 +820,21 @@ namespace
817
820
L" -xgmode <mode>, --xbox-mode <mode>\n " \
818
821
L" Tile/swizzle using provided memory layout mode\n "
819
822
#endif
823
+ L" \n "
824
+ L" (PNG, JPG, TIF, TGA input only)\n "
825
+ L" --ignore-srgb Ignores any gamma setting in the metadata\n "
820
826
L" \n "
821
827
L" (TGA input only)\n "
822
828
L" --tga-zero-alpha Allow all zero alpha channel files to be loaded 'as is'\n "
823
829
L" \n "
824
830
L" (TGA output only)\n "
825
831
L" -tga20 Write file including TGA 2.0 extension area\n "
826
832
L" \n "
827
- L" (BMP, PNG, JPG, TIF, WDP output only)\n "
833
+ L" (BMP, PNG, JPG, TIF, WDP, and HIEF output only)\n "
828
834
L" -wicq <quality>, --wic-quality <quality>\n "
829
835
L" When writing images with WIC use quality (0.0 to 1.0)\n "
830
836
L" --wic-lossless When writing images with WIC use lossless mode\n "
837
+ L" --wic-uncompressed When writing images with WIC use uncompressed mode\n "
831
838
L" --wic-multiframe When writing images with WIC encode multiframe images\n "
832
839
L" \n "
833
840
L" -nologo suppress copyright message\n "
@@ -2088,6 +2095,10 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
2088
2095
else if (_wcsicmp (ext.c_str (), L" .tga" ) == 0 )
2089
2096
{
2090
2097
TGA_FLAGS tgaFlags = (IsBGR (format)) ? TGA_FLAGS_BGR : TGA_FLAGS_NONE;
2098
+ if (dwOptions & (UINT64_C (1 ) << OPT_IGNORE_SRGB_METADATA))
2099
+ {
2100
+ tgaFlags |= TGA_FLAGS_IGNORE_SRGB;
2101
+ }
2091
2102
if (dwOptions & (UINT64_C (1 ) << OPT_TGAZEROALPHA))
2092
2103
{
2093
2104
tgaFlags |= TGA_FLAGS_ALLOW_ALL_ZERO_ALPHA;
@@ -2179,7 +2190,13 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
2179
2190
2180
2191
WIC_FLAGS wicFlags = WIC_FLAGS_NONE | dwFilter;
2181
2192
if (FileType == CODEC_DDS)
2193
+ {
2182
2194
wicFlags |= WIC_FLAGS_ALL_FRAMES;
2195
+ }
2196
+ if (dwOptions & (UINT64_C (1 ) << OPT_IGNORE_SRGB_METADATA))
2197
+ {
2198
+ wicFlags |= WIC_FLAGS_IGNORE_SRGB;
2199
+ }
2183
2200
2184
2201
hr = LoadFromWICFile (curpath.c_str (), wicFlags, &info, *image);
2185
2202
if (FAILED (hr))
@@ -2194,7 +2211,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
2194
2211
}
2195
2212
else if (_wcsicmp (ext.c_str (), L" .webp" ) == 0 )
2196
2213
{
2197
- wprintf (L" INFO: This format requires installing the WEBP Image Extensions - https://www .microsoft.com/p/webp-image-extensions/9pg2dk419drg \n " );
2214
+ wprintf (L" INFO: This format requires installing the WEBP Image Extensions - https://apps .microsoft.com/detail/9PG2DK419DRG \n " );
2198
2215
}
2199
2216
}
2200
2217
continue ;
@@ -3793,18 +3810,20 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
3793
3810
hr = SaveToWICFile (img, nimages, WIC_FLAGS_NONE, GetWICCodec (codec), destName.c_str (), nullptr ,
3794
3811
[&](IPropertyBag2* props)
3795
3812
{
3796
- const bool wicLossless = (dwOptions & (UINT64_C (1 ) << OPT_WIC_LOSSLESS)) != 0 ;
3813
+ const bool lossless = (dwOptions & (UINT64_C (1 ) << OPT_WIC_LOSSLESS)) != 0 ;
3814
+ const bool uncompressed = (dwOptions & (UINT64_C (1 ) << OPT_WIC_UNCOMPRESSED)) != 0 ;
3797
3815
3798
3816
switch (FileType)
3799
3817
{
3818
+ default :
3800
3819
case WIC_CODEC_JPEG:
3801
- if (wicLossless || wicQuality >= 0 .f )
3820
+ if (wicQuality >= 0 .f )
3802
3821
{
3803
3822
PROPBAG2 options = {};
3804
3823
VARIANT varValues = {};
3805
3824
options.pstrName = const_cast <wchar_t *>(L" ImageQuality" );
3806
3825
varValues.vt = VT_R4;
3807
- varValues.fltVal = (wicLossless) ? 1 . f : wicQuality;
3826
+ varValues.fltVal = wicQuality;
3808
3827
std::ignore = props->Write (1 , &options, &varValues);
3809
3828
}
3810
3829
break ;
@@ -3813,7 +3832,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
3813
3832
{
3814
3833
PROPBAG2 options = {};
3815
3834
VARIANT varValues = {};
3816
- if (wicLossless )
3835
+ if (uncompressed )
3817
3836
{
3818
3837
options.pstrName = const_cast <wchar_t *>(L" TiffCompressionMethod" );
3819
3838
varValues.vt = VT_UI1;
@@ -3829,13 +3848,37 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
3829
3848
}
3830
3849
break ;
3831
3850
3851
+ case WIC_CODEC_HEIF:
3852
+ {
3853
+ PROPBAG2 options = {};
3854
+ VARIANT varValues = {};
3855
+ if (uncompressed)
3856
+ {
3857
+ options.pstrName = const_cast <wchar_t *>(L" HeifCompressionMethod" );
3858
+ varValues.vt = VT_UI1;
3859
+ #if defined(NTDDI_WIN10_CU)
3860
+ varValues.bVal = WICHeifCompressionNone;
3861
+ #else
3862
+ varValues.bVal = 0x1 /* WICHeifCompressionNone */ ;
3863
+ #endif
3864
+ }
3865
+ else if (wicQuality >= 0 .f )
3866
+ {
3867
+ options.pstrName = const_cast <wchar_t *>(L" ImageQuality" );
3868
+ varValues.vt = VT_R4;
3869
+ varValues.fltVal = wicQuality;
3870
+ }
3871
+ std::ignore = props->Write (1 , &options, &varValues);
3872
+ }
3873
+ break ;
3874
+
3832
3875
case WIC_CODEC_WMP:
3833
3876
case CODEC_HDP:
3834
3877
case CODEC_JXR:
3835
3878
{
3836
3879
PROPBAG2 options = {};
3837
3880
VARIANT varValues = {};
3838
- if (wicLossless )
3881
+ if (lossless )
3839
3882
{
3840
3883
options.pstrName = const_cast <wchar_t *>(L" Lossless" );
3841
3884
varValues.vt = VT_BOOL;
0 commit comments