SL-19108 Only permit 64 to 256 px images for thumbnails
parent
2b56570c68
commit
dd656390c3
|
|
@ -324,9 +324,12 @@ void LLFloaterChangeItemThumbnail::refreshFromObject(LLInventoryObject* obj)
|
|||
LL_INFOS() << "Setting image from outfit as a thumbnail" << LL_ENDL;
|
||||
thumbnail_id = item->getAssetUUID();
|
||||
|
||||
// per SL-19188, set this image as a thumbnail
|
||||
cat->setThumbnailUUID(thumbnail_id);
|
||||
// todo: needs to trigger send/update once server support is done
|
||||
if (validateAsset(thumbnail_id))
|
||||
{
|
||||
// per SL-19188, set this image as a thumbnail
|
||||
cat->setThumbnailUUID(thumbnail_id);
|
||||
// todo: needs to trigger send/update once server support is done
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -430,8 +433,16 @@ void LLFloaterChangeItemThumbnail::onPasteFromClipboard(void *userdata)
|
|||
LLInventoryObject* obj = self->getInventoryObject();
|
||||
if (obj)
|
||||
{
|
||||
obj->setThumbnailUUID(objects[0]);
|
||||
// todo: need to trigger send/update once server support is done
|
||||
LLUUID asset_id = objects[0];
|
||||
if (validateAsset(asset_id))
|
||||
{
|
||||
obj->setThumbnailUUID(asset_id);
|
||||
// todo: need to trigger send/update once server support is done
|
||||
}
|
||||
else
|
||||
{
|
||||
LLNotificationsUtil::add("ThumbnailDimantionsLimit");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -463,6 +474,33 @@ void LLFloaterChangeItemThumbnail::onRemovalConfirmation(const LLSD& notificatio
|
|||
}
|
||||
}
|
||||
|
||||
bool LLFloaterChangeItemThumbnail::validateAsset(const LLUUID &asset_id)
|
||||
{
|
||||
LLPointer<LLViewerFetchedTexture> texturep = LLViewerTextureManager::getFetchedTexture(asset_id);
|
||||
|
||||
if (!texturep)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (texturep->getFullWidth() != texturep->getFullHeight())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (texturep->getFullWidth() > LLFloaterSimpleSnapshot::THUMBNAIL_SNAPSHOT_DIM_MAX
|
||||
|| texturep->getFullHeight() > LLFloaterSimpleSnapshot::THUMBNAIL_SNAPSHOT_DIM_MAX)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (texturep->getFullWidth() < LLFloaterSimpleSnapshot::THUMBNAIL_SNAPSHOT_DIM_MIN
|
||||
|| texturep->getFullHeight() < LLFloaterSimpleSnapshot::THUMBNAIL_SNAPSHOT_DIM_MIN)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void LLFloaterChangeItemThumbnail::showTexturePicker(const LLUUID &thumbnail_id)
|
||||
{
|
||||
// show hourglass cursor when loading inventory window
|
||||
|
|
@ -526,8 +564,16 @@ void LLFloaterChangeItemThumbnail::onTexturePickerCommit(LLUUID id)
|
|||
|
||||
if (obj && floaterp)
|
||||
{
|
||||
obj->setThumbnailUUID(floaterp->getAssetID());
|
||||
// todo: need to trigger send/update once server support is done
|
||||
LLUUID asset_id = floaterp->getAssetID();
|
||||
if (validateAsset(asset_id))
|
||||
{
|
||||
obj->setThumbnailUUID(asset_id);
|
||||
// todo: need to trigger send/update once server support is done
|
||||
}
|
||||
else
|
||||
{
|
||||
LLNotificationsUtil::add("ThumbnailDimantionsLimit");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,8 @@ private:
|
|||
static void onRemove(void*);
|
||||
static void onRemovalConfirmation(const LLSD& notification, const LLSD& response, LLHandle<LLFloater> handle);
|
||||
|
||||
static bool validateAsset(const LLUUID &asset_id);
|
||||
|
||||
void showTexturePicker(const LLUUID &thumbnail_id);
|
||||
void onTexturePickerCommit(LLUUID id);
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,8 @@
|
|||
|
||||
LLSimpleSnapshotFloaterView* gSimpleSnapshotFloaterView = NULL;
|
||||
|
||||
const S32 THUMBNAIL_SNAPSHOT_DIM = 256;
|
||||
const S32 LLFloaterSimpleSnapshot::THUMBNAIL_SNAPSHOT_DIM_MAX = 256;
|
||||
const S32 LLFloaterSimpleSnapshot::THUMBNAIL_SNAPSHOT_DIM_MIN = 64;
|
||||
|
||||
// Thumbnail posting coro
|
||||
|
||||
|
|
@ -176,8 +177,8 @@ void LLFloaterSimpleSnapshot::Impl::updateResolution(void* data)
|
|||
return;
|
||||
}
|
||||
|
||||
S32 width = THUMBNAIL_SNAPSHOT_DIM;
|
||||
S32 height = THUMBNAIL_SNAPSHOT_DIM;
|
||||
S32 width = THUMBNAIL_SNAPSHOT_DIM_MAX;
|
||||
S32 height = THUMBNAIL_SNAPSHOT_DIM_MAX;
|
||||
|
||||
LLSnapshotLivePreview* previewp = getPreviewView();
|
||||
if (previewp)
|
||||
|
|
@ -342,7 +343,7 @@ void LLFloaterSimpleSnapshot::onSend()
|
|||
LLSnapshotLivePreview* previewp = getPreviewView();
|
||||
|
||||
std::string temp_file = gDirUtilp->getTempFilename();
|
||||
if (previewp->createUploadFile(temp_file, THUMBNAIL_SNAPSHOT_DIM))
|
||||
if (previewp->createUploadFile(temp_file, THUMBNAIL_SNAPSHOT_DIM_MAX, THUMBNAIL_SNAPSHOT_DIM_MIN))
|
||||
{
|
||||
uploadImageUploadFile(temp_file, mInventoryId, mTaskId);
|
||||
}
|
||||
|
|
@ -365,7 +366,7 @@ void LLFloaterSimpleSnapshot::uploadThumbnail(const std::string &file_path, cons
|
|||
// generate a temp texture file for coroutine
|
||||
std::string temp_file = gDirUtilp->getTempFilename();
|
||||
U32 codec = LLImageBase::getCodecFromExtension(gDirUtilp->getExtension(file_path));
|
||||
if (!LLViewerTextureList::createUploadFile(file_path, temp_file, codec, THUMBNAIL_SNAPSHOT_DIM))
|
||||
if (!LLViewerTextureList::createUploadFile(file_path, temp_file, codec, THUMBNAIL_SNAPSHOT_DIM_MAX, THUMBNAIL_SNAPSHOT_DIM_MIN))
|
||||
{
|
||||
LLSD notif_args;
|
||||
notif_args["REASON"] = LLImage::getLastError().c_str();
|
||||
|
|
|
|||
|
|
@ -67,6 +67,9 @@ public:
|
|||
class Impl;
|
||||
friend class Impl;
|
||||
|
||||
static const S32 LLFloaterSimpleSnapshot::THUMBNAIL_SNAPSHOT_DIM_MAX = 256;
|
||||
static const S32 LLFloaterSimpleSnapshot::THUMBNAIL_SNAPSHOT_DIM_MIN = 64;
|
||||
|
||||
private:
|
||||
void onSend();
|
||||
void onCancel();
|
||||
|
|
|
|||
|
|
@ -874,7 +874,7 @@ LLPointer<LLImageRaw> 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<LLImageRaw> raw_image = new LLImageRaw(
|
||||
|
|
@ -884,6 +884,16 @@ bool LLSnapshotLivePreview::createUploadFile(const std::string &out_filename, co
|
|||
mPreviewImage->getComponents());
|
||||
|
||||
LLPointer<LLImageJ2C> 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.");
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ public:
|
|||
|
||||
LLPointer<LLImageFormatted> getFormattedImage();
|
||||
LLPointer<LLImageRaw> getEncodedImage();
|
||||
bool createUploadFile(const std::string &out_file, const S32 max_image_dimentions);
|
||||
bool createUploadFile(const std::string &out_file, const S32 max_image_dimentions, const S32 min_image_dimentions);
|
||||
|
||||
/// Sets size of preview thumbnail image and the surrounding rect.
|
||||
void setThumbnailPlaceholderRect(const LLRect& rect) {mThumbnailPlaceholderRect = rect; }
|
||||
|
|
|
|||
|
|
@ -1286,7 +1286,8 @@ void LLViewerTextureList::decodeAllImages(F32 max_time)
|
|||
BOOL LLViewerTextureList::createUploadFile(const std::string& filename,
|
||||
const std::string& out_filename,
|
||||
const U8 codec,
|
||||
const S32 max_image_dimentions)
|
||||
const S32 max_image_dimentions,
|
||||
const S32 min_image_dimentions)
|
||||
{
|
||||
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
|
||||
// Load the image
|
||||
|
|
@ -1314,6 +1315,16 @@ BOOL LLViewerTextureList::createUploadFile(const std::string& filename,
|
|||
image->setLastError("Image files with less than 3 or more than 4 components are not supported.");
|
||||
return FALSE;
|
||||
}
|
||||
if (image->getWidth() < min_image_dimentions || image->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,
|
||||
image->getWidth(),
|
||||
image->getHeight());
|
||||
image->setLastError(reason);
|
||||
return FALSE;
|
||||
}
|
||||
// Convert to j2c (JPEG2000) and save the file locally
|
||||
LLPointer<LLImageJ2C> compressedImage = convertToUploadFile(raw_image, max_image_dimentions);
|
||||
if (compressedImage.isNull())
|
||||
|
|
|
|||
|
|
@ -95,7 +95,8 @@ public:
|
|||
static BOOL createUploadFile(const std::string& filename,
|
||||
const std::string& out_filename,
|
||||
const U8 codec,
|
||||
const S32 max_image_dimentions = LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT);
|
||||
const S32 max_image_dimentions = LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT,
|
||||
const S32 min_image_dimentions = 0);
|
||||
static LLPointer<LLImageJ2C> convertToUploadFile(LLPointer<LLImageRaw> raw_image, const S32 max_image_dimentions = LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT);
|
||||
static void processImageNotInDatabase( LLMessageSystem *msg, void **user_data );
|
||||
|
||||
|
|
|
|||
|
|
@ -44,14 +44,15 @@
|
|||
top="4"
|
||||
width="16" />
|
||||
<text
|
||||
follows="left|top|right"
|
||||
name="item_name"
|
||||
font="SansSerif"
|
||||
height="19"
|
||||
max_length_bytes="127"
|
||||
use_ellipses="true"
|
||||
follows="left|top|right"
|
||||
layout="topleft"
|
||||
height="19"
|
||||
top_delta="1"
|
||||
left_pad="3"
|
||||
max_length_bytes="127"
|
||||
name="item_name"
|
||||
width="286"/>
|
||||
|
||||
<thumbnail
|
||||
|
|
|
|||
|
|
@ -6109,6 +6109,17 @@ Are you sure you want to delete them?
|
|||
yestext="Delete"/>
|
||||
</notification>
|
||||
|
||||
<notification
|
||||
icon="alertmodal.tga"
|
||||
name="ThumbnailDimantionsLimit"
|
||||
type="alertmodal">
|
||||
<unique/>
|
||||
Only square images from 64 to 256 pixels per side are allowed.
|
||||
<usetemplate
|
||||
name="okbutton"
|
||||
yestext="OK"/>
|
||||
</notification>
|
||||
|
||||
<notification
|
||||
icon="alertmodal.tga"
|
||||
name="ConfirmUnlink"
|
||||
|
|
|
|||
Loading…
Reference in New Issue