diff options
| author | MNikolenko ProductEngine <mnikolenko@productengine.com> | 2014-05-07 11:46:47 +0300 | 
|---|---|---|
| committer | MNikolenko ProductEngine <mnikolenko@productengine.com> | 2014-05-07 11:46:47 +0300 | 
| commit | c8e4f2b10e508507a2c68f2f8eb63baf008a9eba (patch) | |
| tree | 6e5a32ce5b979307e33904b61d29fd2b04fbb6c6 | |
| parent | 849ce1e30c080d71e4af8dc8f24720274a126f4c (diff) | |
MAINT-4004 FIXED Check image's dimensions and show notification if it's larger than allowed.
| -rwxr-xr-x | indra/newview/lllocalbitmaps.cpp | 41 | ||||
| -rwxr-xr-x | indra/newview/lllocalbitmaps.h | 1 | ||||
| -rwxr-xr-x | indra/newview/skins/default/xui/en/notifications.xml | 11 | 
3 files changed, 51 insertions, 2 deletions
| diff --git a/indra/newview/lllocalbitmaps.cpp b/indra/newview/lllocalbitmaps.cpp index 2d9385390b..941ae06b78 100755 --- a/indra/newview/lllocalbitmaps.cpp +++ b/indra/newview/lllocalbitmaps.cpp @@ -60,7 +60,9 @@  #include "llnotificationsutil.h"  #include "pipeline.h"  #include "llmaterialmgr.h" - +#include "llimagedimensionsinfo.h" +#include "llviewercontrol.h" +#include "lltrans.h"  /*=======================================*/  /*  Formal declarations, constants, etc. */  /*=======================================*/  @@ -835,6 +837,12 @@ bool LLLocalBitmapMgr::addUnit()  		std::string filename = picker.getFirstFile();  		while(!filename.empty())  		{ +			if(!checkTextureDimensions(filename)) +			{ +				filename = picker.getNextFile(); +				continue; +			} +  			LLLocalBitmap* unit = new LLLocalBitmap(filename);  			if (unit->getValid()) @@ -864,6 +872,37 @@ bool LLLocalBitmapMgr::addUnit()  	return add_successful;  } +bool LLLocalBitmapMgr::checkTextureDimensions(std::string filename) +{ +	std::string exten = gDirUtilp->getExtension(filename); +	U32 codec = LLImageBase::getCodecFromExtension(exten); +	std::string mImageLoadError; +	LLImageDimensionsInfo image_info; +	if (!image_info.load(filename,codec)) +	{ +		return false; +	} + +	S32 max_width = gSavedSettings.getS32("max_texture_dimension_X"); +	S32 max_height = gSavedSettings.getS32("max_texture_dimension_Y"); + +	if ((image_info.getWidth() > max_width) || (image_info.getHeight() > max_height)) +	{ +		LLStringUtil::format_map_t args; +		args["WIDTH"] = llformat("%d", max_width); +		args["HEIGHT"] = llformat("%d", max_height); +		mImageLoadError = LLTrans::getString("texture_load_dimensions_error", args); + +		LLSD notif_args; +		notif_args["REASON"] = mImageLoadError; +		LLNotificationsUtil::add("CannotUploadTexture", notif_args); + +		return false; +	} + +	return true; +} +  void LLLocalBitmapMgr::delUnit(LLUUID tracking_id)  {  	if (!sBitmapList.empty()) diff --git a/indra/newview/lllocalbitmaps.h b/indra/newview/lllocalbitmaps.h index 2ee84bf46e..820157000c 100755 --- a/indra/newview/lllocalbitmaps.h +++ b/indra/newview/lllocalbitmaps.h @@ -119,6 +119,7 @@ class LLLocalBitmapMgr  	public:  		static bool         addUnit();  		static void         delUnit(LLUUID tracking_id); +		static bool 		checkTextureDimensions(std::string filename);  		static LLUUID       getWorldID(LLUUID tracking_id);  		static std::string  getFilename(LLUUID tracking_id); diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 7297ba4fc0..e1194b2025 100755 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -7836,7 +7836,16 @@ You uploaded a [RESOLUTION] baked texture for '[BODYREGION]' after [TIME] second  ( [EXISTENCE] seconds alive )  You locally updated a [RESOLUTION] baked texture for '[BODYREGION]' after [TIME] seconds.    </notification> - +	 +  <notification +   icon="alertmodal.tga" +   name="CannotUploadTexture" +   type="alertmodal"> +Unable to upload texture. +[REASON]    +  <tag>fail</tag>   +  </notification> +      <notification     icon="alertmodal.tga"     name="LivePreviewUnavailable" | 
