From 69512a3e6fbfcbfe142accf601458043f733b49b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sat, 22 Apr 2017 14:46:22 -0700 Subject: [PATCH] Renaming string functions. --- src/image.cpp | 2 +- src/image_decode.cpp | 8 ++++---- tools/texturec/texturec.cpp | 34 +++++++++++++++++++++++++--------- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/image.cpp b/src/image.cpp index 217ac96..e2eee05 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -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; } diff --git a/src/image_decode.cpp b/src/image_decode.cpp index 5103580..3067d74 100644 --- a/src/image_decode.cpp +++ b/src/image_decode.cpp @@ -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; } diff --git a/tools/texturec/texturec.cpp b/tools/texturec/texturec.cpp index 70bcfb6..334cd34 100644 --- a/tools/texturec/texturec.cpp +++ b/tools/texturec/texturec.cpp @@ -370,6 +370,7 @@ void help(const char* _error = NULL) " --iqa Image Quality Assesment\n" " --max Maximum width/height (image will be scaled down and\n" " aspect ratio will be preserved.\n" + " --as 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); }