summaryrefslogtreecommitdiff
path: root/indra/newview/llpreviewtexture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llpreviewtexture.cpp')
-rwxr-xr-xindra/newview/llpreviewtexture.cpp22
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;