diff options
author | Monty Brandenberg <monty@lindenlab.com> | 2013-11-12 14:06:38 -0500 |
---|---|---|
committer | Monty Brandenberg <monty@lindenlab.com> | 2013-11-12 14:06:38 -0500 |
commit | d191585a3eec778e36e5f0c4b620c3d525c86c42 (patch) | |
tree | 2612c0d1947e00d9ceba82b054a7a90113ffa752 /indra/newview/llpreviewtexture.cpp | |
parent | ac1d3a22f2034a5e3aba757bde72825643fa799c (diff) | |
parent | ebc9bcbf69f7a519677a6522979a6bf6cbb04bb8 (diff) |
Merge. Refresh from viewer-release after 3.6.10 release
Diffstat (limited to 'indra/newview/llpreviewtexture.cpp')
-rwxr-xr-x | indra/newview/llpreviewtexture.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/indra/newview/llpreviewtexture.cpp b/indra/newview/llpreviewtexture.cpp index 91a98792eb..1ed48a978f 100755 --- a/indra/newview/llpreviewtexture.cpp +++ b/indra/newview/llpreviewtexture.cpp @@ -36,6 +36,7 @@ #include "llfilepicker.h" #include "llfloaterreg.h" #include "llimagetga.h" +#include "llimagepng.h" #include "llinventory.h" #include "llnotificationsutil.h" #include "llresmgr.h" @@ -261,7 +262,7 @@ void LLPreviewTexture::saveAs() LLFilePicker& file_picker = LLFilePicker::instance(); const LLInventoryItem* item = getItem() ; - if( !file_picker.getSaveFile( LLFilePicker::FFSAVE_TGA, item ? LLDir::getScrubbedFileName(item->getName()) : LLStringUtil::null) ) + if( !file_picker.getSaveFile( LLFilePicker::FFSAVE_TGAPNG, item ? LLDir::getScrubbedFileName(item->getName()) : LLStringUtil::null) ) { // User canceled or we failed to acquire save file. return; @@ -358,14 +359,27 @@ void LLPreviewTexture::onFileLoadedForSave(BOOL success, if( self && final && success ) { - LLPointer<LLImageTGA> image_tga = new LLImageTGA; - if( !image_tga->encode( src ) ) + const U32 ext_length = 3; + std::string extension = self->mSaveFileName.substr( self->mSaveFileName.length() - ext_length); + + // We only support saving in PNG or TGA format + LLPointer<LLImageFormatted> image; + if(extension == "png") + { + image = new LLImagePNG; + } + else if(extension == "tga") + { + image = new LLImageTGA; + } + + if( image && !image->encode( src, 0 ) ) { LLSD args; args["FILE"] = self->mSaveFileName; LLNotificationsUtil::add("CannotEncodeFile", args); } - else if( !image_tga->save( self->mSaveFileName ) ) + else if( image && !image->save( self->mSaveFileName ) ) { LLSD args; args["FILE"] = self->mSaveFileName; |