diff options
Diffstat (limited to 'indra/llimage')
| -rw-r--r-- | indra/llimage/llimage.cpp | 36 | ||||
| -rw-r--r-- | indra/llimage/llimage.h | 8 | ||||
| -rw-r--r-- | indra/llimage/llimagedimensionsinfo.cpp | 2 | ||||
| -rw-r--r-- | indra/llimage/llimagetga.cpp | 2 |
4 files changed, 42 insertions, 6 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index ca8a4199e8..bea33c04ed 100644 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -2036,6 +2036,25 @@ file_extensions[] = { "dxt", IMG_CODEC_DXT }, { "png", IMG_CODEC_PNG } }; + +static struct +{ + const wchar_t* exten; + EImageCodec codec; +} +wide_file_extensions[] = +{ + { L"bmp", IMG_CODEC_BMP }, + { L"tga", IMG_CODEC_TGA }, + { L"j2c", IMG_CODEC_J2C }, + { L"jp2", IMG_CODEC_J2C }, + { L"texture", IMG_CODEC_J2C }, + { L"jpg", IMG_CODEC_JPEG }, + { L"jpeg", IMG_CODEC_JPEG }, + { L"mip", IMG_CODEC_DXT }, + { L"dxt", IMG_CODEC_DXT }, + { L"png", IMG_CODEC_PNG } +}; #define NUM_FILE_EXTENSIONS LL_ARRAY_SIZE(file_extensions) #if 0 static std::string find_file(std::string &name, S8 *codec) @@ -2056,7 +2075,8 @@ static std::string find_file(std::string &name, S8 *codec) return std::string(""); } #endif -EImageCodec LLImageBase::getCodecFromExtension(const std::string& exten) + +EImageCodec LLImageBase::getCodecFromExtension(std::string_view exten) { if (!exten.empty()) { @@ -2068,6 +2088,20 @@ EImageCodec LLImageBase::getCodecFromExtension(const std::string& exten) } return IMG_CODEC_INVALID; } + +EImageCodec LLImageBase::getCodecFromExtension(std::wstring_view exten) +{ + if (!exten.empty()) + { + for (int i = 0; i < (int)(NUM_FILE_EXTENSIONS); i++) + { + if (exten == wide_file_extensions[i].exten) + return wide_file_extensions[i].codec; + } + } + return IMG_CODEC_INVALID; +} + #if 0 bool LLImageRaw::createFromFile(const std::string &filename, bool j2c_lowest_mip_only) { diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index 6b14b68c78..8569c28528 100644 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -27,10 +27,11 @@ #ifndef LL_LLIMAGE_H #define LL_LLIMAGE_H -#include "lluuid.h" -#include "llstring.h" +#include "llmutex.h" #include "llpointer.h" +#include "llstring.h" #include "lltrace.h" +#include "lluuid.h" constexpr S32 MIN_IMAGE_MIP = 2; // 4x4, only used for expand/contract power of 2 constexpr S32 MAX_IMAGE_MIP = 12; // 4096x4096 @@ -158,7 +159,8 @@ public: // <= 0 priority means that there's no need for more data. static F32 calc_download_priority(F32 virtual_size, F32 visible_area, S32 bytes_sent); - static EImageCodec getCodecFromExtension(const std::string& exten); + static EImageCodec getCodecFromExtension(std::string_view exten); + static EImageCodec getCodecFromExtension(std::wstring_view exten); //static LLTrace::MemStatHandle sMemStat; diff --git a/indra/llimage/llimagedimensionsinfo.cpp b/indra/llimage/llimagedimensionsinfo.cpp index c896d60c85..2ae7760d4c 100644 --- a/indra/llimage/llimagedimensionsinfo.cpp +++ b/indra/llimage/llimagedimensionsinfo.cpp @@ -166,7 +166,7 @@ bool LLImageDimensionsInfo::getImageDimensionsJpeg() { sJpegErrorEncountered = false; clean(); - FILE* fp = LLFile::fopen(mSrcFilename, "rb"); + FILE* fp = LLFile::fopen(mSrcFilename, LLFILE_MODE("rb")); if (!fp) { setLastError("Unable to open file for reading", mSrcFilename); diff --git a/indra/llimage/llimagetga.cpp b/indra/llimage/llimagetga.cpp index 25232b77aa..7b09553974 100644 --- a/indra/llimage/llimagetga.cpp +++ b/indra/llimage/llimagetga.cpp @@ -1191,7 +1191,7 @@ bool LLImageTGA::loadFile( const std::string& path ) return false; } - LLFILE* file = LLFile::fopen(path, "rb"); /* Flawfinder: ignore */ + LLFILE* file = LLFile::fopen(path, LLFILE_MODE("rb")); /* Flawfinder: ignore */ if( !file ) { LL_WARNS() << "Couldn't open file " << path << LL_ENDL; |
