diff options
author | Merov Linden <merov@lindenlab.com> | 2013-12-12 09:03:21 -0800 |
---|---|---|
committer | Merov Linden <merov@lindenlab.com> | 2013-12-12 09:03:21 -0800 |
commit | a4f121f065c580ac34e8caa666855c95eb29138b (patch) | |
tree | 2e9d9766c99cb7bd81aa4ad7e4af1149cfa03de6 /indra/newview/llpreviewtexture.cpp | |
parent | 88f139594bb819bc31b438edcceaf9cd661b3f82 (diff) | |
parent | 1a9b9f1bd1b5f64b35b9ce6eff458cdb7a79fe6e (diff) |
Pull merge from lindenlab/viewer-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; |