diff options
author | Jacek Antonelli | 2008-09-06 18:24:57 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-09-06 18:25:07 -0500 |
commit | 798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch) | |
tree | 1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/llimage/llimage.cpp | |
parent | Second Life viewer sources 1.20.15 (diff) | |
download | meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2 meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz |
Second Life viewer sources 1.21.0-RC
Diffstat (limited to 'linden/indra/llimage/llimage.cpp')
-rw-r--r-- | linden/indra/llimage/llimage.cpp | 60 |
1 files changed, 27 insertions, 33 deletions
diff --git a/linden/indra/llimage/llimage.cpp b/linden/indra/llimage/llimage.cpp index 52a210f..814e82f 100644 --- a/linden/indra/llimage/llimage.cpp +++ b/linden/indra/llimage/llimage.cpp | |||
@@ -40,9 +40,7 @@ | |||
40 | #include "llimagebmp.h" | 40 | #include "llimagebmp.h" |
41 | #include "llimagetga.h" | 41 | #include "llimagetga.h" |
42 | #include "llimagej2c.h" | 42 | #include "llimagej2c.h" |
43 | #if JPEG_SUPPORT | ||
44 | #include "llimagejpeg.h" | 43 | #include "llimagejpeg.h" |
45 | #endif | ||
46 | #include "llimagepng.h" | 44 | #include "llimagepng.h" |
47 | #include "llimagedxt.h" | 45 | #include "llimagedxt.h" |
48 | 46 | ||
@@ -97,15 +95,15 @@ void LLImageBase::sanityCheck() | |||
97 | } | 95 | } |
98 | } | 96 | } |
99 | 97 | ||
100 | LLString LLImageBase::sLastErrorMessage; | 98 | std::string LLImageBase::sLastErrorMessage; |
101 | BOOL LLImageBase::sSizeOverride = FALSE; | 99 | BOOL LLImageBase::sSizeOverride = FALSE; |
102 | 100 | ||
103 | BOOL LLImageBase::setLastError(const LLString& message, const LLString& filename) | 101 | BOOL LLImageBase::setLastError(const std::string& message, const std::string& filename) |
104 | { | 102 | { |
105 | sLastErrorMessage = message; | 103 | sLastErrorMessage = message; |
106 | if (filename != "") | 104 | if (!filename.empty()) |
107 | { | 105 | { |
108 | sLastErrorMessage += LLString(" FILE:"); | 106 | sLastErrorMessage += " FILE:"; |
109 | sLastErrorMessage += filename; | 107 | sLastErrorMessage += filename; |
110 | } | 108 | } |
111 | llwarns << sLastErrorMessage << llendl; | 109 | llwarns << sLastErrorMessage << llendl; |
@@ -251,7 +249,7 @@ LLImageRaw::LLImageRaw(U8 *data, U16 width, U16 height, S8 components) | |||
251 | ++sRawImageCount; | 249 | ++sRawImageCount; |
252 | } | 250 | } |
253 | 251 | ||
254 | LLImageRaw::LLImageRaw(const LLString &filename, bool j2c_lowest_mip_only) | 252 | LLImageRaw::LLImageRaw(const std::string& filename, bool j2c_lowest_mip_only) |
255 | : LLImageBase() | 253 | : LLImageBase() |
256 | { | 254 | { |
257 | createFromFile(filename, j2c_lowest_mip_only); | 255 | createFromFile(filename, j2c_lowest_mip_only); |
@@ -1112,25 +1110,25 @@ file_extensions[] = | |||
1112 | }; | 1110 | }; |
1113 | #define NUM_FILE_EXTENSIONS sizeof(file_extensions)/sizeof(file_extensions[0]) | 1111 | #define NUM_FILE_EXTENSIONS sizeof(file_extensions)/sizeof(file_extensions[0]) |
1114 | 1112 | ||
1115 | static LLString find_file(LLString &name, S8 *codec) | 1113 | static std::string find_file(std::string &name, S8 *codec) |
1116 | { | 1114 | { |
1117 | LLString tname; | 1115 | std::string tname; |
1118 | for (int i=0; i<(int)(NUM_FILE_EXTENSIONS); i++) | 1116 | for (int i=0; i<(int)(NUM_FILE_EXTENSIONS); i++) |
1119 | { | 1117 | { |
1120 | tname = name + "." + LLString(file_extensions[i].exten); | 1118 | tname = name + "." + std::string(file_extensions[i].exten); |
1121 | llifstream ifs(tname.c_str(), llifstream::binary); | 1119 | llifstream ifs(tname, llifstream::binary); |
1122 | if (ifs.is_open()) | 1120 | if (ifs.is_open()) |
1123 | { | 1121 | { |
1124 | ifs.close(); | 1122 | ifs.close(); |
1125 | if (codec) | 1123 | if (codec) |
1126 | *codec = file_extensions[i].codec; | 1124 | *codec = file_extensions[i].codec; |
1127 | return LLString(file_extensions[i].exten); | 1125 | return std::string(file_extensions[i].exten); |
1128 | } | 1126 | } |
1129 | } | 1127 | } |
1130 | return LLString(""); | 1128 | return std::string(""); |
1131 | } | 1129 | } |
1132 | 1130 | ||
1133 | EImageCodec LLImageBase::getCodecFromExtension(const LLString& exten) | 1131 | EImageCodec LLImageBase::getCodecFromExtension(const std::string& exten) |
1134 | { | 1132 | { |
1135 | for (int i=0; i<(int)(NUM_FILE_EXTENSIONS); i++) | 1133 | for (int i=0; i<(int)(NUM_FILE_EXTENSIONS); i++) |
1136 | { | 1134 | { |
@@ -1140,19 +1138,19 @@ EImageCodec LLImageBase::getCodecFromExtension(const LLString& exten) | |||
1140 | return IMG_CODEC_INVALID; | 1138 | return IMG_CODEC_INVALID; |
1141 | } | 1139 | } |
1142 | 1140 | ||
1143 | bool LLImageRaw::createFromFile(const LLString &filename, bool j2c_lowest_mip_only) | 1141 | bool LLImageRaw::createFromFile(const std::string &filename, bool j2c_lowest_mip_only) |
1144 | { | 1142 | { |
1145 | LLString name = filename; | 1143 | std::string name = filename; |
1146 | size_t dotidx = name.rfind('.'); | 1144 | size_t dotidx = name.rfind('.'); |
1147 | S8 codec = IMG_CODEC_INVALID; | 1145 | S8 codec = IMG_CODEC_INVALID; |
1148 | LLString exten; | 1146 | std::string exten; |
1149 | 1147 | ||
1150 | deleteData(); // delete any existing data | 1148 | deleteData(); // delete any existing data |
1151 | 1149 | ||
1152 | if (dotidx != LLString::npos) | 1150 | if (dotidx != std::string::npos) |
1153 | { | 1151 | { |
1154 | exten = name.substr(dotidx+1); | 1152 | exten = name.substr(dotidx+1); |
1155 | LLString::toLower(exten); | 1153 | LLStringUtil::toLower(exten); |
1156 | codec = getCodecFromExtension(exten); | 1154 | codec = getCodecFromExtension(exten); |
1157 | } | 1155 | } |
1158 | else | 1156 | else |
@@ -1165,7 +1163,7 @@ bool LLImageRaw::createFromFile(const LLString &filename, bool j2c_lowest_mip_on | |||
1165 | return false; // format not recognized | 1163 | return false; // format not recognized |
1166 | } | 1164 | } |
1167 | 1165 | ||
1168 | llifstream ifs(name.c_str(), llifstream::binary); | 1166 | llifstream ifs(name, llifstream::binary); |
1169 | if (!ifs.is_open()) | 1167 | if (!ifs.is_open()) |
1170 | { | 1168 | { |
1171 | // SJB: changed from llinfos to lldebugs to reduce spam | 1169 | // SJB: changed from llinfos to lldebugs to reduce spam |
@@ -1197,11 +1195,9 @@ bool LLImageRaw::createFromFile(const LLString &filename, bool j2c_lowest_mip_on | |||
1197 | case IMG_CODEC_TGA: | 1195 | case IMG_CODEC_TGA: |
1198 | image = new LLImageTGA(); | 1196 | image = new LLImageTGA(); |
1199 | break; | 1197 | break; |
1200 | #if JPEG_SUPPORT | ||
1201 | case IMG_CODEC_JPEG: | 1198 | case IMG_CODEC_JPEG: |
1202 | image = new LLImageJPEG(); | 1199 | image = new LLImageJPEG(); |
1203 | break; | 1200 | break; |
1204 | #endif | ||
1205 | case IMG_CODEC_J2C: | 1201 | case IMG_CODEC_J2C: |
1206 | image = new LLImageJ2C(); | 1202 | image = new LLImageJ2C(); |
1207 | break; | 1203 | break; |
@@ -1285,20 +1281,18 @@ LLImageFormatted* LLImageFormatted::createFromType(S8 codec) | |||
1285 | case IMG_CODEC_TGA: | 1281 | case IMG_CODEC_TGA: |
1286 | image = new LLImageTGA(); | 1282 | image = new LLImageTGA(); |
1287 | break; | 1283 | break; |
1288 | #if JPEG_SUPPORT | ||
1289 | case IMG_CODEC_JPEG: | 1284 | case IMG_CODEC_JPEG: |
1290 | image = new LLImageJPEG(); | 1285 | image = new LLImageJPEG(); |
1291 | break; | 1286 | break; |
1292 | #endif | 1287 | case IMG_CODEC_PNG: |
1288 | image = new LLImagePNG(); | ||
1289 | break; | ||
1293 | case IMG_CODEC_J2C: | 1290 | case IMG_CODEC_J2C: |
1294 | image = new LLImageJ2C(); | 1291 | image = new LLImageJ2C(); |
1295 | break; | 1292 | break; |
1296 | case IMG_CODEC_DXT: | 1293 | case IMG_CODEC_DXT: |
1297 | image = new LLImageDXT(); | 1294 | image = new LLImageDXT(); |
1298 | break; | 1295 | break; |
1299 | case IMG_CODEC_PNG: | ||
1300 | image = new LLImagePNG(); | ||
1301 | break; | ||
1302 | default: | 1296 | default: |
1303 | image = NULL; | 1297 | image = NULL; |
1304 | break; | 1298 | break; |
@@ -1307,11 +1301,11 @@ LLImageFormatted* LLImageFormatted::createFromType(S8 codec) | |||
1307 | } | 1301 | } |
1308 | 1302 | ||
1309 | // static | 1303 | // static |
1310 | LLImageFormatted* LLImageFormatted::createFromExtension(const LLString& instring) | 1304 | LLImageFormatted* LLImageFormatted::createFromExtension(const std::string& instring) |
1311 | { | 1305 | { |
1312 | LLString exten; | 1306 | std::string exten; |
1313 | size_t dotidx = instring.rfind('.'); | 1307 | size_t dotidx = instring.rfind('.'); |
1314 | if (dotidx != LLString::npos) | 1308 | if (dotidx != std::string::npos) |
1315 | { | 1309 | { |
1316 | exten = instring.substr(dotidx+1); | 1310 | exten = instring.substr(dotidx+1); |
1317 | } | 1311 | } |
@@ -1468,7 +1462,7 @@ void LLImageFormatted::appendData(U8 *data, S32 size) | |||
1468 | 1462 | ||
1469 | //---------------------------------------------------------------------------- | 1463 | //---------------------------------------------------------------------------- |
1470 | 1464 | ||
1471 | BOOL LLImageFormatted::load(const LLString &filename) | 1465 | BOOL LLImageFormatted::load(const std::string &filename) |
1472 | { | 1466 | { |
1473 | resetLastError(); | 1467 | resetLastError(); |
1474 | 1468 | ||
@@ -1505,14 +1499,14 @@ BOOL LLImageFormatted::load(const LLString &filename) | |||
1505 | return res; | 1499 | return res; |
1506 | } | 1500 | } |
1507 | 1501 | ||
1508 | BOOL LLImageFormatted::save(const LLString &filename) | 1502 | BOOL LLImageFormatted::save(const std::string &filename) |
1509 | { | 1503 | { |
1510 | resetLastError(); | 1504 | resetLastError(); |
1511 | 1505 | ||
1512 | apr_file_t* apr_file = ll_apr_file_open(filename, LL_APR_WB); | 1506 | apr_file_t* apr_file = ll_apr_file_open(filename, LL_APR_WB); |
1513 | if (!apr_file) | 1507 | if (!apr_file) |
1514 | { | 1508 | { |
1515 | setLastError("Unable to open file for reading", filename); | 1509 | setLastError("Unable to open file for writing", filename); |
1516 | return FALSE; | 1510 | return FALSE; |
1517 | } | 1511 | } |
1518 | 1512 | ||