SL-11402 Last session image should be saved as png

meow-7.2.2
andreykproductengine 2019-06-12 19:12:09 +03:00
parent 19221d9ccf
commit 04e67fa12d
6 changed files with 54 additions and 40 deletions

View File

@ -4507,7 +4507,7 @@ void LLAppViewer::saveFinalSnapshot()
snap_filename += gDirUtilp->getDirDelimiter();
snap_filename += LLStartUp::getScreenLastFilename();
// use full pixel dimensions of viewer window (not post-scale dimensions)
gViewerWindow->saveSnapshot(snap_filename, gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw(), FALSE, TRUE);
gViewerWindow->saveSnapshot(snap_filename, gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw(), FALSE, TRUE, LLSnapshotModel::SNAPSHOT_TYPE_COLOR, LLSnapshotModel::SNAPSHOT_FORMAT_PNG);
mSavedFinalSnapshot = TRUE;
}
}

View File

@ -113,7 +113,7 @@
#include "llgroupmgr.h"
#include "llhudeffecttrail.h"
#include "llhudmanager.h"
#include "llimagebmp.h"
#include "llimagepng.h"
#include "llinventorybridge.h"
#include "llinventorymodel.h"
#include "llinventorymodelbackgroundfetch.h"
@ -210,8 +210,8 @@
bool gAgentMovementCompleted = false;
S32 gMaxAgentGroups;
const std::string SCREEN_HOME_FILENAME = "screen_home%s.bmp";
const std::string SCREEN_LAST_FILENAME = "screen_last%s.bmp";
const std::string SCREEN_HOME_FILENAME = "screen_home%s.png";
const std::string SCREEN_LAST_FILENAME = "screen_last%s.png";
LLPointer<LLViewerTexture> gStartTexture;
@ -2709,7 +2709,7 @@ void init_start_screen(S32 location_id)
temp_str += LLStartUp::getScreenHomeFilename();
}
LLPointer<LLImageBMP> start_image_bmp = new LLImageBMP;
LLPointer<LLImagePNG> start_image_png = new LLImagePNG;
// Turn off start screen to get around the occasional readback
// driver bug
@ -2718,18 +2718,18 @@ void init_start_screen(S32 location_id)
LL_INFOS("AppInit") << "Bitmap load disabled" << LL_ENDL;
return;
}
else if(!start_image_bmp->load(temp_str) )
else if(!start_image_png->load(temp_str) )
{
LL_WARNS("AppInit") << "Bitmap load failed" << LL_ENDL;
gStartTexture = NULL;
}
else
{
gStartImageWidth = start_image_bmp->getWidth();
gStartImageHeight = start_image_bmp->getHeight();
gStartImageWidth = start_image_png->getWidth();
gStartImageHeight = start_image_png->getHeight();
LLPointer<LLImageRaw> raw = new LLImageRaw;
if (!start_image_bmp->decode(raw, 0.0f))
if (!start_image_png->decode(raw, 0.0f))
{
LL_WARNS("AppInit") << "Bitmap decode failed" << LL_ENDL;
gStartTexture = NULL;

View File

@ -42,7 +42,7 @@
#include "llfeaturemanager.h"
//#include "llfirstuse.h"
#include "llhudmanager.h"
#include "llimagebmp.h"
#include "llimagepng.h"
#include "llmemory.h"
#include "llselectmgr.h"
#include "llsky.h"
@ -1590,15 +1590,15 @@ void render_disconnected_background()
std::string temp_str;
temp_str = gDirUtilp->getLindenUserDir() + gDirUtilp->getDirDelimiter() + LLStartUp::getScreenLastFilename();
LLPointer<LLImageBMP> image_bmp = new LLImageBMP;
if( !image_bmp->load(temp_str) )
LLPointer<LLImagePNG> image_png = new LLImagePNG;
if( !image_png->load(temp_str) )
{
//LL_INFOS() << "Bitmap load failed" << LL_ENDL;
return;
}
LLPointer<LLImageRaw> raw = new LLImageRaw;
if (!image_bmp->decode(raw, 0.0f))
if (!image_png->decode(raw, 0.0f))
{
LL_INFOS() << "Bitmap decode failed" << LL_ENDL;
gDisconnectedImagep = NULL;
@ -1606,7 +1606,7 @@ void render_disconnected_background()
}
U8 *rawp = raw->getData();
S32 npixels = (S32)image_bmp->getWidth()*(S32)image_bmp->getHeight();
S32 npixels = (S32)image_png->getWidth()*(S32)image_png->getHeight();
for (S32 i = 0; i < npixels; i++)
{
S32 sum = 0;

View File

@ -5108,7 +5108,7 @@ bool attempt_standard_notification(LLMessageSystem* msgsystem)
std::string snap_filename = gDirUtilp->getLindenUserDir();
snap_filename += gDirUtilp->getDirDelimiter();
snap_filename += LLStartUp::getScreenHomeFilename();
gViewerWindow->saveSnapshot(snap_filename, gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw(), FALSE, FALSE);
gViewerWindow->saveSnapshot(snap_filename, gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw(), FALSE, FALSE, LLSnapshotModel::SNAPSHOT_TYPE_COLOR, LLSnapshotModel::SNAPSHOT_FORMAT_PNG);
}
if (notificationID == "RegionRestartMinutes" ||
@ -5191,7 +5191,7 @@ static void process_special_alert_messages(const std::string & message)
std::string snap_filename = gDirUtilp->getLindenUserDir();
snap_filename += gDirUtilp->getDirDelimiter();
snap_filename += LLStartUp::getScreenHomeFilename();
gViewerWindow->saveSnapshot(snap_filename, gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw(), FALSE, FALSE);
gViewerWindow->saveSnapshot(snap_filename, gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw(), FALSE, FALSE, LLSnapshotModel::SNAPSHOT_TYPE_COLOR, LLSnapshotModel::SNAPSHOT_FORMAT_PNG);
}
}

View File

@ -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;
}

View File

@ -347,7 +347,7 @@ public:
// snapshot functionality.
// perhaps some of this should move to llfloatershapshot? -MG
BOOL saveSnapshot(const std::string& filename, S32 image_width, S32 image_height, BOOL show_ui = TRUE, BOOL do_rebuild = FALSE, LLSnapshotModel::ESnapshotLayerType type = LLSnapshotModel::SNAPSHOT_TYPE_COLOR);
BOOL saveSnapshot(const std::string& filename, S32 image_width, S32 image_height, BOOL show_ui = TRUE, BOOL do_rebuild = FALSE, LLSnapshotModel::ESnapshotLayerType type = LLSnapshotModel::SNAPSHOT_TYPE_COLOR, LLSnapshotModel::ESnapshotFormat format = LLSnapshotModel::SNAPSHOT_FORMAT_BMP);
BOOL rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_height, BOOL keep_window_aspect = TRUE, BOOL is_texture = FALSE,
BOOL show_ui = TRUE, BOOL do_rebuild = FALSE, LLSnapshotModel::ESnapshotLayerType type = LLSnapshotModel::SNAPSHOT_TYPE_COLOR, S32 max_size = MAX_SNAPSHOT_IMAGE_SIZE);
BOOL thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 preview_height, BOOL show_ui, BOOL do_rebuild, LLSnapshotModel::ESnapshotLayerType type);