summaryrefslogtreecommitdiff
path: root/indra/newview/llviewerwindow.cpp
diff options
context:
space:
mode:
authorandreykproductengine <andreykproductengine@lindenlab.com>2019-06-12 19:12:09 +0300
committerandreykproductengine <andreykproductengine@lindenlab.com>2019-06-12 19:12:09 +0300
commit04e67fa12d1dac368e2f88a04af4cd266b8b2063 (patch)
tree138e49a72de3ee4810f5f4676fc0dc3ccffe095b /indra/newview/llviewerwindow.cpp
parent19221d9ccf38a5b10e7e2ecefb1ad121f1fb51d7 (diff)
SL-11402 Last session image should be saved as png
Diffstat (limited to 'indra/newview/llviewerwindow.cpp')
-rw-r--r--indra/newview/llviewerwindow.cpp60
1 files changed, 37 insertions, 23 deletions
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 8e6df22171..74770dc483 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -122,7 +122,7 @@
#include "llhudmanager.h"
#include "llhudobject.h"
#include "llhudview.h"
-#include "llimagebmp.h"
+#include "llimage.h"
#include "llimagej2c.h"
#include "llimageworker.h"
#include "llkeyboard.h"
@@ -4487,32 +4487,46 @@ void LLViewerWindow::movieSize(S32 new_width, S32 new_height)
}
}
-BOOL LLViewerWindow::saveSnapshot(const std::string& filepath, S32 image_width, S32 image_height, BOOL show_ui, BOOL do_rebuild, LLSnapshotModel::ESnapshotLayerType type)
+BOOL LLViewerWindow::saveSnapshot(const std::string& filepath, S32 image_width, S32 image_height, BOOL show_ui, BOOL do_rebuild, LLSnapshotModel::ESnapshotLayerType type, LLSnapshotModel::ESnapshotFormat format)
{
- LL_INFOS() << "Saving snapshot to: " << filepath << LL_ENDL;
+ LL_INFOS() << "Saving snapshot to: " << filepath << LL_ENDL;
- LLPointer<LLImageRaw> raw = new LLImageRaw;
- BOOL success = rawSnapshot(raw, image_width, image_height, TRUE, FALSE, show_ui, do_rebuild);
+ LLPointer<LLImageRaw> raw = new LLImageRaw;
+ BOOL success = rawSnapshot(raw, image_width, image_height, TRUE, FALSE, show_ui, do_rebuild);
- if (success)
- {
- LLPointer<LLImageBMP> bmp_image = new LLImageBMP;
- success = bmp_image->encode(raw, 0.0f);
- if( success )
- {
- success = bmp_image->save(filepath);
- }
- else
- {
- LL_WARNS() << "Unable to encode bmp snapshot" << LL_ENDL;
- }
- }
- else
- {
- LL_WARNS() << "Unable to capture raw snapshot" << LL_ENDL;
- }
+ if (success)
+ {
+ U8 image_codec = IMG_CODEC_BMP;
+ switch (format)
+ {
+ case LLSnapshotModel::SNAPSHOT_FORMAT_PNG:
+ image_codec = IMG_CODEC_PNG;
+ break;
+ case LLSnapshotModel::SNAPSHOT_FORMAT_JPEG:
+ image_codec = IMG_CODEC_JPEG;
+ break;
+ default:
+ image_codec = IMG_CODEC_BMP;
+ break;
+ }
- return success;
+ LLPointer<LLImageFormatted> formated_image = LLImageFormatted::createFromType(image_codec);
+ success = formated_image->encode(raw, 0.0f);
+ if (success)
+ {
+ success = formated_image->save(filepath);
+ }
+ else
+ {
+ LL_WARNS() << "Unable to encode snapshot of format " << format << LL_ENDL;
+ }
+ }
+ else
+ {
+ LL_WARNS() << "Unable to capture raw snapshot" << LL_ENDL;
+ }
+
+ return success;
}