From 2d68a7c33622aa28c49989e959c2a9be1f053d03 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 21 Feb 2023 23:03:00 +0200 Subject: SL-19108 Update Simple snapshot floater --- indra/newview/llsnapshotlivepreview.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'indra/newview/llsnapshotlivepreview.cpp') diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp index ed7e18fadc..273e3a403d 100644 --- a/indra/newview/llsnapshotlivepreview.cpp +++ b/indra/newview/llsnapshotlivepreview.cpp @@ -51,6 +51,7 @@ #include "llviewercontrol.h" #include "llviewermenufile.h" // upload_new_resource() #include "llviewerstats.h" +#include "llviewertexturelist.h" #include "llwindow.h" #include "llworld.h" #include @@ -873,6 +874,31 @@ LLPointer LLSnapshotLivePreview::getEncodedImage() return mPreviewImageEncoded; } +bool LLSnapshotLivePreview::createUploadFile(const std::string &out_filename, const S32 max_image_dimentions) +{ + // make a copy, since convertToUploadFile modifies raw image + LLPointer raw_image = new LLImageRaw( + mPreviewImage->getData(), + mPreviewImage->getWidth(), + mPreviewImage->getHeight(), + mPreviewImage->getComponents()); + + LLPointer compressedImage = LLViewerTextureList::convertToUploadFile(raw_image, max_image_dimentions); + if (compressedImage.isNull()) + { + compressedImage->setLastError("Couldn't convert the image to jpeg2000."); + LL_INFOS() << "Couldn't convert to j2c, file : " << out_filename << LL_ENDL; + return false; + } + if (!compressedImage->save(out_filename)) + { + compressedImage->setLastError("Couldn't create the jpeg2000 image for upload."); + LL_INFOS() << "Couldn't create output file : " << out_filename << LL_ENDL; + return false; + } + return true; +} + // We actually estimate the data size so that we do not require actual compression when showing the preview // Note : whenever formatted image is computed, mDataSize will be updated to reflect the true size void LLSnapshotLivePreview::estimateDataSize() -- cgit v1.2.3 From dd656390c3b6cbdfc6e88c8ff3e6a011238b6f6e Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Sat, 25 Feb 2023 23:08:38 +0200 Subject: SL-19108 Only permit 64 to 256 px images for thumbnails --- indra/newview/llsnapshotlivepreview.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'indra/newview/llsnapshotlivepreview.cpp') diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp index 273e3a403d..37ebcd1266 100644 --- a/indra/newview/llsnapshotlivepreview.cpp +++ b/indra/newview/llsnapshotlivepreview.cpp @@ -874,7 +874,7 @@ LLPointer LLSnapshotLivePreview::getEncodedImage() return mPreviewImageEncoded; } -bool LLSnapshotLivePreview::createUploadFile(const std::string &out_filename, const S32 max_image_dimentions) +bool LLSnapshotLivePreview::createUploadFile(const std::string &out_filename, const S32 max_image_dimentions, const S32 min_image_dimentions) { // make a copy, since convertToUploadFile modifies raw image LLPointer raw_image = new LLImageRaw( @@ -884,6 +884,16 @@ bool LLSnapshotLivePreview::createUploadFile(const std::string &out_filename, co mPreviewImage->getComponents()); LLPointer compressedImage = LLViewerTextureList::convertToUploadFile(raw_image, max_image_dimentions); + if (compressedImage->getWidth() < min_image_dimentions || compressedImage->getHeight() < min_image_dimentions) + { + std::string reason = llformat("Images below %d x %d pixels are not allowed. Actual size: %d x %dpx", + min_image_dimentions, + min_image_dimentions, + compressedImage->getWidth(), + compressedImage->getHeight()); + compressedImage->setLastError(reason); + return FALSE; + } if (compressedImage.isNull()) { compressedImage->setLastError("Couldn't convert the image to jpeg2000."); -- cgit v1.2.3 From cfb69846f1e8309ed86d4a18eb26a889f6dbaccc Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Sat, 9 Sep 2023 00:00:22 +0300 Subject: SL-20261 Allow and resize existing textures as necessary for thumbnails --- indra/newview/llsnapshotlivepreview.cpp | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) (limited to 'indra/newview/llsnapshotlivepreview.cpp') diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp index 37ebcd1266..b7a1832b17 100644 --- a/indra/newview/llsnapshotlivepreview.cpp +++ b/indra/newview/llsnapshotlivepreview.cpp @@ -876,37 +876,7 @@ LLPointer LLSnapshotLivePreview::getEncodedImage() bool LLSnapshotLivePreview::createUploadFile(const std::string &out_filename, const S32 max_image_dimentions, const S32 min_image_dimentions) { - // make a copy, since convertToUploadFile modifies raw image - LLPointer raw_image = new LLImageRaw( - mPreviewImage->getData(), - mPreviewImage->getWidth(), - mPreviewImage->getHeight(), - mPreviewImage->getComponents()); - - LLPointer compressedImage = LLViewerTextureList::convertToUploadFile(raw_image, max_image_dimentions); - if (compressedImage->getWidth() < min_image_dimentions || compressedImage->getHeight() < min_image_dimentions) - { - std::string reason = llformat("Images below %d x %d pixels are not allowed. Actual size: %d x %dpx", - min_image_dimentions, - min_image_dimentions, - compressedImage->getWidth(), - compressedImage->getHeight()); - compressedImage->setLastError(reason); - return FALSE; - } - if (compressedImage.isNull()) - { - compressedImage->setLastError("Couldn't convert the image to jpeg2000."); - LL_INFOS() << "Couldn't convert to j2c, file : " << out_filename << LL_ENDL; - return false; - } - if (!compressedImage->save(out_filename)) - { - compressedImage->setLastError("Couldn't create the jpeg2000 image for upload."); - LL_INFOS() << "Couldn't create output file : " << out_filename << LL_ENDL; - return false; - } - return true; + return LLViewerTextureList::createUploadFile(mPreviewImage, out_filename, max_image_dimentions, min_image_dimentions); } // We actually estimate the data size so that we do not require actual compression when showing the preview -- cgit v1.2.3