mirror of
https://github.com/microsoft/DirectXTex.git
synced 2026-02-04 04:16:12 +01:00
Convert command-line tools to use GNU-style long options (#541)
This commit is contained in:
@@ -115,15 +115,6 @@ namespace
|
||||
enum OPTIONS : uint32_t
|
||||
{
|
||||
OPT_RECURSIVE = 1,
|
||||
OPT_FILELIST,
|
||||
OPT_WIDTH,
|
||||
OPT_HEIGHT,
|
||||
OPT_FORMAT,
|
||||
OPT_FILTER,
|
||||
OPT_SRGBI,
|
||||
OPT_SRGBO,
|
||||
OPT_SRGB,
|
||||
OPT_OUTPUTFILE,
|
||||
OPT_TOLOWER,
|
||||
OPT_OVERWRITE,
|
||||
OPT_USE_DX10,
|
||||
@@ -133,15 +124,26 @@ namespace
|
||||
OPT_DEMUL_ALPHA,
|
||||
OPT_TA_WRAP,
|
||||
OPT_TA_MIRROR,
|
||||
OPT_FEATURE_LEVEL,
|
||||
OPT_TONEMAP,
|
||||
OPT_GIF_BGCOLOR,
|
||||
OPT_SWIZZLE,
|
||||
OPT_STRIP_MIPS,
|
||||
OPT_MAX
|
||||
OPT_FLAGS_MAX,
|
||||
OPT_FILELIST,
|
||||
OPT_WIDTH,
|
||||
OPT_HEIGHT,
|
||||
OPT_FORMAT,
|
||||
OPT_FILTER,
|
||||
OPT_SRGBI,
|
||||
OPT_SRGBO,
|
||||
OPT_SRGB,
|
||||
OPT_OUTPUTFILE,
|
||||
OPT_FEATURE_LEVEL,
|
||||
OPT_SWIZZLE,
|
||||
OPT_VERSION,
|
||||
OPT_HELP,
|
||||
};
|
||||
|
||||
static_assert(OPT_MAX <= 32, "dwOptions is a unsigned int bitfield");
|
||||
static_assert(OPT_FLAGS_MAX <= 32, "dwOptions is a unsigned int bitfield");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -194,13 +196,38 @@ namespace
|
||||
{ L"wrap", OPT_TA_WRAP },
|
||||
{ L"mirror", OPT_TA_MIRROR },
|
||||
{ L"fl", OPT_FEATURE_LEVEL },
|
||||
|
||||
// Deprecated options (recommend using new -- alternatives)
|
||||
{ L"tonemap", OPT_TONEMAP },
|
||||
{ L"bgcolor", OPT_GIF_BGCOLOR },
|
||||
{ L"swizzle", OPT_SWIZZLE },
|
||||
{ L"stripmips", OPT_STRIP_MIPS },
|
||||
|
||||
{ nullptr, 0 }
|
||||
};
|
||||
|
||||
const SValue<uint32_t> g_pOptionsLong[] =
|
||||
{
|
||||
{ L"feature-level", OPT_FEATURE_LEVEL },
|
||||
{ L"file-list", OPT_FILELIST },
|
||||
{ L"format", OPT_FORMAT },
|
||||
{ L"gif-bg-color", OPT_GIF_BGCOLOR },
|
||||
{ L"height", OPT_HEIGHT },
|
||||
{ L"help", OPT_HELP },
|
||||
{ L"image-filter", OPT_FILTER },
|
||||
{ L"overwrite", OPT_OVERWRITE },
|
||||
{ L"separate-alpha", OPT_SEPALPHA },
|
||||
{ L"srgb-in", OPT_SRGBI },
|
||||
{ L"srgb-out", OPT_SRGBO },
|
||||
{ L"strip-mips", OPT_STRIP_MIPS },
|
||||
{ L"swizzle", OPT_SWIZZLE },
|
||||
{ L"to-lowercase", OPT_TOLOWER },
|
||||
{ L"tonemap", OPT_TONEMAP },
|
||||
{ L"version", OPT_VERSION },
|
||||
{ L"width", OPT_WIDTH },
|
||||
{ nullptr, 0 }
|
||||
};
|
||||
|
||||
#define DEFFMT(fmt) { L## #fmt, DXGI_FORMAT_ ## fmt }
|
||||
|
||||
const SValue<DXGI_FORMAT> g_pFormats[] =
|
||||
@@ -317,18 +344,18 @@ namespace
|
||||
{ nullptr, TEX_FILTER_DEFAULT }
|
||||
};
|
||||
|
||||
#define CODEC_DDS 0xFFFF0001
|
||||
#define CODEC_TGA 0xFFFF0002
|
||||
#define CODEC_HDR 0xFFFF0005
|
||||
constexpr uint32_t CODEC_DDS = 0xFFFF0001;
|
||||
constexpr uint32_t CODEC_TGA = 0xFFFF0002;
|
||||
constexpr uint32_t CODEC_HDR = 0xFFFF0005;
|
||||
|
||||
#ifdef USE_OPENEXR
|
||||
#define CODEC_EXR 0xFFFF0006
|
||||
constexpr uint32_t CODEC_EXR = 0xFFFF0008;
|
||||
#endif
|
||||
#ifdef USE_LIBJPEG
|
||||
#define CODEC_JPEG 0xFFFF0007
|
||||
constexpr uint32_t CODEC_JPEG = 0xFFFF0009;
|
||||
#endif
|
||||
#ifdef USE_LIBPNG
|
||||
#define CODEC_PNG 0xFFFF0008
|
||||
constexpr uint32_t CODEC_PNG = 0xFFFF000A;
|
||||
#endif
|
||||
|
||||
const SValue<uint32_t> g_pExtFileTypes[] =
|
||||
@@ -500,7 +527,7 @@ namespace
|
||||
|
||||
static const wchar_t* const s_usage =
|
||||
L"Usage: texassemble <command> <options> [--] <files>\n"
|
||||
L"\n"
|
||||
L"\nCOMMANDS\n"
|
||||
L" cube create cubemap\n"
|
||||
L" volume create volume map\n"
|
||||
L" array create texture array\n"
|
||||
@@ -518,34 +545,43 @@ namespace
|
||||
L" cube-from-ht create cubemap from a h-tee image\n"
|
||||
L" cube-from-hs create cubemap from a h-strip image\n"
|
||||
L" cube-from-vs create cubemap from a v-strip image\n"
|
||||
L"\n"
|
||||
L"\nOPTIONS\n"
|
||||
L" -r wildcard filename search is recursive\n"
|
||||
L" -flist <filename> use text file with a list of input files (one per line)\n"
|
||||
L" -w <n> width\n"
|
||||
L" -h <n> height\n"
|
||||
L" -f <format> format\n"
|
||||
L" -if <filter> image filtering\n"
|
||||
L" -srgb{i|o} sRGB {input, output}\n"
|
||||
L" -o <filename> output filename\n"
|
||||
L" -l force output filename to lower case\n"
|
||||
L" -y overwrite existing output file (if any)\n"
|
||||
L" -sepalpha resize alpha channel separately from color channels\n"
|
||||
L" -flist <filename>, --file-list <filename>\n"
|
||||
L" use text file with a list of input files (one per line)\n"
|
||||
L"\n"
|
||||
L" -w <n>, --width <n> width for output\n"
|
||||
L" -h <n>, --height <n> height for output\n"
|
||||
L" -f <format>, --format <format> pixel format for output\n"
|
||||
L"\n"
|
||||
L" -if <filter>, --image-filter <filter> image filtering\n"
|
||||
L" -srgb{i|o}, --srgb-in, --srgb-out sRGB {input, output}\n"
|
||||
L"\n"
|
||||
L" -o <filename> output filename\n"
|
||||
L" -l, --to-lowercase force output filename to lower case\n"
|
||||
L" -y, --overwrite overwrite existing output file (if any)\n"
|
||||
L"\n"
|
||||
L" -sepalpha, --separate-alpha resize/generate mips alpha channel separately from color channels\n"
|
||||
L"\n"
|
||||
L" -nowic Force non-WIC filtering\n"
|
||||
L" -wrap, -mirror texture addressing mode (wrap, mirror, or clamp)\n"
|
||||
L" -alpha convert premultiplied alpha to straight alpha\n"
|
||||
L" -dx10 Force use of 'DX10' extended header\n"
|
||||
L" -nologo suppress copyright message\n"
|
||||
L" -fl <feature-level> Set maximum feature level target (defaults to 11.0)\n"
|
||||
L"\n"
|
||||
L" -fl <feature-level>, --feature-level <feature-level>\n"
|
||||
L" Set maximum feature level target (defaults to 11.0)\n"
|
||||
L"\n"
|
||||
L" -tonemap Apply a tonemap operator based on maximum luminance\n"
|
||||
L"\n"
|
||||
L" (gif only)\n"
|
||||
L" -bgcolor Use background color instead of transparency\n"
|
||||
L" --gif-bg-color Use background color instead of transparency\n"
|
||||
L"\n"
|
||||
L" (merge only)\n"
|
||||
L" -swizzle <rgba> Select channels for merge (defaults to rgbB)\n"
|
||||
L" --swizzle <rgba> Select channels for merge (defaults to rgbB)\n"
|
||||
L"\n"
|
||||
L" (cube, volume, array, cubearray, merge only)\n"
|
||||
L" -stripmips Use only base image from input dds files\n"
|
||||
L" --strip-mips Use only base image from input dds files\n"
|
||||
L"\n"
|
||||
L" '-- ' is needed if any input filepath starts with the '-' or '/' character\n";
|
||||
|
||||
@@ -775,6 +811,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
// check for these before the command
|
||||
if (('-' == argv[1][0]) && ('-' == argv[1][1]))
|
||||
{
|
||||
if (!_wcsicmp(argv[1], L"--version"))
|
||||
@@ -824,54 +861,94 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
std::list<SConversion> conversion;
|
||||
bool allowOpts = true;
|
||||
|
||||
for (int iArg = 2; iArg < argc; iArg++)
|
||||
for (int iArg = 2; iArg < argc; ++iArg)
|
||||
{
|
||||
PWSTR pArg = argv[iArg];
|
||||
|
||||
if (allowOpts
|
||||
&& ('-' == pArg[0]) && ('-' == pArg[1]))
|
||||
if (allowOpts && (('-' == pArg[0]) || ('/' == pArg[0])))
|
||||
{
|
||||
if (pArg[2] == 0)
|
||||
uint32_t dwOption = 0;
|
||||
PWSTR pValue = nullptr;
|
||||
|
||||
if (('-' == pArg[0]) && ('-' == pArg[1]))
|
||||
{
|
||||
// "-- " is the POSIX standard for "end of options" marking to escape the '-' and '/' characters at the start of filepaths.
|
||||
allowOpts = false;
|
||||
}
|
||||
else if (!_wcsicmp(pArg, L"--version"))
|
||||
{
|
||||
PrintLogo(true, g_ToolName, g_Description);
|
||||
return 0;
|
||||
}
|
||||
else if (!_wcsicmp(pArg, L"--help"))
|
||||
{
|
||||
PrintUsage();
|
||||
return 0;
|
||||
if (pArg[2] == 0)
|
||||
{
|
||||
// "-- " is the POSIX standard for "end of options" marking to escape the '-' and '/' characters at the start of filepaths.
|
||||
allowOpts = false;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
pArg += 2;
|
||||
|
||||
for (pValue = pArg; *pValue && (':' != *pValue) && ('=' != *pValue); ++pValue);
|
||||
|
||||
if (*pValue)
|
||||
*pValue++ = 0;
|
||||
|
||||
dwOption = LookupByName(pArg, g_pOptionsLong);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wprintf(L"Unknown option: %ls\n", pArg);
|
||||
return 1;
|
||||
pArg++;
|
||||
|
||||
for (pValue = pArg; *pValue && (':' != *pValue) && ('=' != *pValue); ++pValue);
|
||||
|
||||
if (*pValue)
|
||||
*pValue++ = 0;
|
||||
|
||||
dwOption = LookupByName(pArg, g_pOptions);
|
||||
|
||||
if (!dwOption)
|
||||
{
|
||||
if (LookupByName(pArg, g_pOptionsLong))
|
||||
{
|
||||
wprintf(L"ERROR: did you mean `--%ls` (with two dashes)?\n", pArg);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (allowOpts
|
||||
&& (('-' == pArg[0]) || ('/' == pArg[0])))
|
||||
{
|
||||
pArg++;
|
||||
PWSTR pValue;
|
||||
|
||||
for (pValue = pArg; *pValue && (':' != *pValue); pValue++);
|
||||
|
||||
if (*pValue)
|
||||
*pValue++ = 0;
|
||||
|
||||
const uint32_t dwOption = LookupByName(pArg, g_pOptions);
|
||||
|
||||
if (!dwOption || (dwOptions & (1 << dwOption)))
|
||||
switch (dwOption)
|
||||
{
|
||||
PrintUsage();
|
||||
case 0:
|
||||
wprintf(L"ERROR: Unknown option: `%ls`\n\nUse %ls --help\n", pArg, g_ToolName);
|
||||
return 1;
|
||||
}
|
||||
|
||||
dwOptions |= 1 << dwOption;
|
||||
case OPT_FILELIST:
|
||||
case OPT_WIDTH:
|
||||
case OPT_HEIGHT:
|
||||
case OPT_FORMAT:
|
||||
case OPT_FILTER:
|
||||
case OPT_SRGBI:
|
||||
case OPT_SRGBO:
|
||||
case OPT_SRGB:
|
||||
case OPT_OUTPUTFILE:
|
||||
case OPT_FEATURE_LEVEL:
|
||||
case OPT_SWIZZLE:
|
||||
// These don't use flag bits
|
||||
break;
|
||||
|
||||
case OPT_VERSION:
|
||||
PrintLogo(true, g_ToolName, g_Description);
|
||||
return 0;
|
||||
|
||||
case OPT_HELP:
|
||||
PrintUsage();
|
||||
return 0;
|
||||
|
||||
default:
|
||||
if (dwOptions & (UINT32_C(1) << dwOption))
|
||||
{
|
||||
wprintf(L"ERROR: Duplicate option: `%ls`\n\n", pArg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
dwOptions |= (UINT32_C(1) << dwOption);
|
||||
break;
|
||||
}
|
||||
|
||||
// Handle options with additional value parameter
|
||||
switch (dwOption)
|
||||
@@ -1034,8 +1111,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
maxVolume = LookupByName(pValue, g_pFeatureLevelsVolume);
|
||||
if (!maxSize || !maxCube || !maxArray || !maxVolume)
|
||||
{
|
||||
wprintf(L"Invalid value specified with -fl (%ls)\n", pValue);
|
||||
wprintf(L"\n");
|
||||
wprintf(L"Invalid value specified with -fl (%ls)\n\n", pValue);
|
||||
PrintUsage();
|
||||
return 1;
|
||||
}
|
||||
@@ -1092,7 +1168,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
{
|
||||
const size_t count = conversion.size();
|
||||
std::filesystem::path path(pArg);
|
||||
SearchForFiles(path.make_preferred(), conversion, (dwOptions & (1 << OPT_RECURSIVE)) != 0, nullptr);
|
||||
SearchForFiles(path.make_preferred(), conversion, (dwOptions & (UINT32_C(1) << OPT_RECURSIVE)) != 0, nullptr);
|
||||
if (conversion.size() <= count)
|
||||
{
|
||||
wprintf(L"No matching files found for %ls\n", pArg);
|
||||
@@ -1114,7 +1190,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (~dwOptions & (1 << OPT_NOLOGO))
|
||||
if (~dwOptions & (UINT32_C(1) << OPT_NOLOGO))
|
||||
PrintLogo(false, g_ToolName, g_Description);
|
||||
|
||||
switch (dwCommand)
|
||||
@@ -1169,7 +1245,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
outputFile = curpath.stem().concat(L".dds").native();
|
||||
}
|
||||
|
||||
hr = LoadAnimatedGif(curpath.c_str(), loadedImages, (dwOptions & (1 << OPT_GIF_BGCOLOR)) != 0);
|
||||
hr = LoadAnimatedGif(curpath.c_str(), loadedImages, (dwOptions & (UINT32_C(1) << OPT_GIF_BGCOLOR)) != 0);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
wprintf(L" FAILED (%08X%ls)\n", static_cast<unsigned int>(hr), GetErrorDesc(hr));
|
||||
@@ -1296,7 +1372,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
wprintf(L"\nERROR: Can't assemble complex surfaces\n");
|
||||
return 1;
|
||||
}
|
||||
else if ((info.mipLevels > 1) && ((dwOptions & (1 << OPT_STRIP_MIPS)) == 0))
|
||||
else if ((info.mipLevels > 1) && ((dwOptions & (UINT32_C(1) << OPT_STRIP_MIPS)) == 0))
|
||||
{
|
||||
switch (dwCommand)
|
||||
{
|
||||
@@ -1476,7 +1552,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
}
|
||||
|
||||
// --- Strip Mips (if requested) -----------------------------------------------
|
||||
if ((info.mipLevels > 1) && (dwOptions & (1 << OPT_STRIP_MIPS)))
|
||||
if ((info.mipLevels > 1) && (dwOptions & (UINT32_C(1) << OPT_STRIP_MIPS)))
|
||||
{
|
||||
std::unique_ptr<ScratchImage> timage(new (std::nothrow) ScratchImage);
|
||||
if (!timage)
|
||||
@@ -1526,7 +1602,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
}
|
||||
|
||||
// --- Undo Premultiplied Alpha (if requested) ---------------------------------
|
||||
if ((dwOptions & (1 << OPT_DEMUL_ALPHA))
|
||||
if ((dwOptions & (UINT32_C(1) << OPT_DEMUL_ALPHA))
|
||||
&& HasAlpha(info.format)
|
||||
&& info.format != DXGI_FORMAT_A8_UNORM)
|
||||
{
|
||||
@@ -1633,7 +1709,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
}
|
||||
|
||||
// --- Tonemap (if requested) --------------------------------------------------
|
||||
if (dwOptions & (1 << OPT_TONEMAP))
|
||||
if (dwOptions & (UINT32_C(1) << OPT_TONEMAP))
|
||||
{
|
||||
std::unique_ptr<ScratchImage> timage(new (std::nothrow) ScratchImage);
|
||||
if (!timage)
|
||||
@@ -1973,12 +2049,12 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
wprintf(L"\n");
|
||||
fflush(stdout);
|
||||
|
||||
if (dwOptions & (1 << OPT_TOLOWER))
|
||||
if (dwOptions & (UINT32_C(1) << OPT_TOLOWER))
|
||||
{
|
||||
std::transform(outputFile.begin(), outputFile.end(), outputFile.begin(), towlower);
|
||||
}
|
||||
|
||||
if (~dwOptions & (1 << OPT_OVERWRITE))
|
||||
if (~dwOptions & (UINT32_C(1) << OPT_OVERWRITE))
|
||||
{
|
||||
if (GetFileAttributesW(outputFile.c_str()) != INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
@@ -2041,12 +2117,12 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
wprintf(L"\n");
|
||||
fflush(stdout);
|
||||
|
||||
if (dwOptions & (1 << OPT_TOLOWER))
|
||||
if (dwOptions & (UINT32_C(1) << OPT_TOLOWER))
|
||||
{
|
||||
std::transform(outputFile.begin(), outputFile.end(), outputFile.begin(), towlower);
|
||||
}
|
||||
|
||||
if (~dwOptions & (1 << OPT_OVERWRITE))
|
||||
if (~dwOptions & (UINT32_C(1) << OPT_OVERWRITE))
|
||||
{
|
||||
if (GetFileAttributesW(outputFile.c_str()) != INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
@@ -2110,12 +2186,12 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
wprintf(L"\n");
|
||||
fflush(stdout);
|
||||
|
||||
if (dwOptions & (1 << OPT_TOLOWER))
|
||||
if (dwOptions & (UINT32_C(1) << OPT_TOLOWER))
|
||||
{
|
||||
std::transform(outputFile.begin(), outputFile.end(), outputFile.begin(), towlower);
|
||||
}
|
||||
|
||||
if (~dwOptions & (1 << OPT_OVERWRITE))
|
||||
if (~dwOptions & (UINT32_C(1) << OPT_OVERWRITE))
|
||||
{
|
||||
if (GetFileAttributesW(outputFile.c_str()) != INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
@@ -2309,12 +2385,12 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
wprintf(L"\n");
|
||||
fflush(stdout);
|
||||
|
||||
if (dwOptions & (1 << OPT_TOLOWER))
|
||||
if (dwOptions & (UINT32_C(1) << OPT_TOLOWER))
|
||||
{
|
||||
std::transform(outputFile.begin(), outputFile.end(), outputFile.begin(), towlower);
|
||||
}
|
||||
|
||||
if (~dwOptions & (1 << OPT_OVERWRITE))
|
||||
if (~dwOptions & (UINT32_C(1) << OPT_OVERWRITE))
|
||||
{
|
||||
if (GetFileAttributesW(outputFile.c_str()) != INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
@@ -2324,7 +2400,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
}
|
||||
|
||||
hr = SaveToDDSFile(result.GetImages(), result.GetImageCount(), result.GetMetadata(),
|
||||
(dwOptions & (1 << OPT_USE_DX10)) ? (DDS_FLAGS_FORCE_DX10_EXT | DDS_FLAGS_FORCE_DX10_EXT_MISC2) : DDS_FLAGS_NONE,
|
||||
(dwOptions & (UINT32_C(1) << OPT_USE_DX10)) ? (DDS_FLAGS_FORCE_DX10_EXT | DDS_FLAGS_FORCE_DX10_EXT_MISC2) : DDS_FLAGS_NONE,
|
||||
outputFile.c_str());
|
||||
if (FAILED(hr))
|
||||
{
|
||||
@@ -2367,12 +2443,12 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
wprintf(L"\n");
|
||||
fflush(stdout);
|
||||
|
||||
if (dwOptions & (1 << OPT_TOLOWER))
|
||||
if (dwOptions & (UINT32_C(1) << OPT_TOLOWER))
|
||||
{
|
||||
std::transform(outputFile.begin(), outputFile.end(), outputFile.begin(), towlower);
|
||||
}
|
||||
|
||||
if (~dwOptions & (1 << OPT_OVERWRITE))
|
||||
if (~dwOptions & (UINT32_C(1) << OPT_OVERWRITE))
|
||||
{
|
||||
if (GetFileAttributesW(outputFile.c_str()) != INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
@@ -2382,7 +2458,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
}
|
||||
|
||||
hr = SaveToDDSFile(result.GetImages(), result.GetImageCount(), result.GetMetadata(),
|
||||
(dwOptions & (1 << OPT_USE_DX10)) ? (DDS_FLAGS_FORCE_DX10_EXT | DDS_FLAGS_FORCE_DX10_EXT_MISC2) : DDS_FLAGS_NONE,
|
||||
(dwOptions & (UINT32_C(1) << OPT_USE_DX10)) ? (DDS_FLAGS_FORCE_DX10_EXT | DDS_FLAGS_FORCE_DX10_EXT_MISC2) : DDS_FLAGS_NONE,
|
||||
outputFile.c_str());
|
||||
if (FAILED(hr))
|
||||
{
|
||||
@@ -2456,7 +2532,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
|
||||
case CMD_ARRAY:
|
||||
case CMD_GIF:
|
||||
hr = result.InitializeArrayFromImages(&imageArray[0], imageArray.size(), (dwOptions & (1 << OPT_USE_DX10)) != 0);
|
||||
hr = result.InitializeArrayFromImages(&imageArray[0], imageArray.size(), (dwOptions & (UINT32_C(1) << OPT_USE_DX10)) != 0);
|
||||
break;
|
||||
|
||||
case CMD_CUBE:
|
||||
@@ -2480,12 +2556,12 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
wprintf(L"\n");
|
||||
fflush(stdout);
|
||||
|
||||
if (dwOptions & (1 << OPT_TOLOWER))
|
||||
if (dwOptions & (UINT32_C(1) << OPT_TOLOWER))
|
||||
{
|
||||
std::transform(outputFile.begin(), outputFile.end(), outputFile.begin(), towlower);
|
||||
}
|
||||
|
||||
if (~dwOptions & (1 << OPT_OVERWRITE))
|
||||
if (~dwOptions & (UINT32_C(1) << OPT_OVERWRITE))
|
||||
{
|
||||
if (GetFileAttributesW(outputFile.c_str()) != INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
@@ -2495,7 +2571,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
}
|
||||
|
||||
hr = SaveToDDSFile(result.GetImages(), result.GetImageCount(), result.GetMetadata(),
|
||||
(dwOptions & (1 << OPT_USE_DX10)) ? (DDS_FLAGS_FORCE_DX10_EXT | DDS_FLAGS_FORCE_DX10_EXT_MISC2) : DDS_FLAGS_NONE,
|
||||
(dwOptions & (UINT32_C(1) << OPT_USE_DX10)) ? (DDS_FLAGS_FORCE_DX10_EXT | DDS_FLAGS_FORCE_DX10_EXT_MISC2) : DDS_FLAGS_NONE,
|
||||
outputFile.c_str());
|
||||
if (FAILED(hr))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user