Renaming string functions.

This commit is contained in:
Branimir Karadžić
2017-04-22 14:46:22 -07:00
parent 8c79e05df0
commit 69512a3e6f
3 changed files with 30 additions and 14 deletions

View File

@@ -234,7 +234,7 @@ namespace bimg
const TextureFormat::Enum fmt = TextureFormat::Enum(ii);
if (isValid(fmt) )
{
if (0 == bx::strincmp(s_textureFormatName[ii], _name) )
if (0 == bx::strCmpI(s_textureFormatName[ii], _name) )
{
return fmt;
}

View File

@@ -258,22 +258,22 @@ namespace bimg
{
const EXRChannelInfo& channel = exrHeader.channels[ii];
if (UINT8_MAX == idxR
&& 0 == bx::strncmp(channel.name, "R") )
&& 0 == bx::strCmp(channel.name, "R") )
{
idxR = ii;
}
else if (UINT8_MAX == idxG
&& 0 == bx::strncmp(channel.name, "G") )
&& 0 == bx::strCmp(channel.name, "G") )
{
idxG = ii;
}
else if (UINT8_MAX == idxB
&& 0 == bx::strncmp(channel.name, "B") )
&& 0 == bx::strCmp(channel.name, "B") )
{
idxB = ii;
}
else if (UINT8_MAX == idxA
&& 0 == bx::strncmp(channel.name, "A") )
&& 0 == bx::strCmp(channel.name, "A") )
{
idxA = ii;
}

View File

@@ -370,6 +370,7 @@ void help(const char* _error = NULL)
" --iqa Image Quality Assesment\n"
" --max <max size> Maximum width/height (image will be scaled down and\n"
" aspect ratio will be preserved.\n"
" --as <extension> Save as.\n"
"\n"
"For additional information, see https://github.com/bkaradzic/bgfx\n"
@@ -400,6 +401,14 @@ int main(int _argc, const char* _argv[])
return EXIT_FAILURE;
}
const char* saveAs = cmdLine.findOption("as");
saveAs = NULL == saveAs ? bx::strFindI(outputFileName, ".ktx") : saveAs;
if (NULL == saveAs)
{
help("Output file format must be specified.");
return EXIT_FAILURE;
}
Options options;
const char* edgeOpt = cmdLine.findOption("sdf");
@@ -419,13 +428,6 @@ int main(int _argc, const char* _argv[])
options.maxSize = atoi(maxSize);
}
bx::CrtFileReader reader;
if (!bx::open(&reader, inputFileName) )
{
help("Failed to open input file.");
return EXIT_FAILURE;
}
options.format = bimg::TextureFormat::Count;
const char* type = cmdLine.findOption('t');
if (NULL != type)
@@ -439,14 +441,28 @@ int main(int _argc, const char* _argv[])
}
}
bx::CrtFileReader reader;
if (!bx::open(&reader, inputFileName) )
{
help("Failed to open input file.");
return EXIT_FAILURE;
}
bx::CrtAllocator allocator;
uint32_t inputSize = (uint32_t)bx::getSize(&reader);
uint8_t* inputData = (uint8_t*)BX_ALLOC(&allocator, inputSize);
bx::read(&reader, inputData, inputSize);
bx::Error err;
bx::read(&reader, inputData, inputSize, &err);
bx::close(&reader);
if (!err.isOk() )
{
help("Failed to read input file.");
return EXIT_FAILURE;
}
bimg::ImageContainer* output = convert(&allocator, inputData, inputSize, options);
BX_FREE(&allocator, inputData);
@@ -456,7 +472,7 @@ int main(int _argc, const char* _argv[])
bx::CrtFileWriter writer;
if (bx::open(&writer, outputFileName) )
{
if (NULL != bx::stristr(outputFileName, ".ktx") )
if (NULL != bx::strFindI(saveAs, "ktx") )
{
bimg::imageWriteKtx(&writer, *output, output->m_data, output->m_size);
}