It is currently March 28th, 2024, 4:09 pm

Dynamic preference over screenheight or width when using an image as backdrop?

Get help with creating, editing & fixing problems with skins
Post Reply
User avatar
Krainz
Posts: 186
Joined: May 27th, 2012, 5:16 am
Contact:

Dynamic preference over screenheight or width when using an image as backdrop?

Post by Krainz »

Hello fellas,

I have this meter:

Code: Select all

[Background1]
Meter=Image
ImageName=#bgbackground1#
X=0
Y=0
PreserveAspectRatio=1
LeftMouseDoubleClickAction=["#@#RainFile\RainFile.exe" "File" "Variables" "bgbackground1" "#@#Variables\GeneralSettings.inc" "#PROGRAMDRIVE#Image.jpg" "DPNE"]
LeftMouseUpAction=[!DeactivateConfig "AsperiaSuite\Gamehall\Tiles" "GameScreen1-Tiles.ini"][!ActivateConfig "AsperiaSuite\Gamehall\Tiles" "GameScreen1-Tiles.ini"]
RightMouseUpAction=[!DeactivateConfig "AsperiaSuite\Gamehall\Tiles" "GameScreen1-Tiles.ini"][!ActivateConfig "AsperiaSuite\Gamehall\Tiles" "GameScreen1-Tiles.ini"]
H=#screenareaheight#
UpdateDivider=864000
Which is supposed to make the image fit if its height is bigger than the user's screen size.

However, due to some aspect ratio stuff, sometimes it would be best to choose W=#screenareawidth# instead of H=#screenareaheight#

Is there a way we can make a code so it detects the image won't fit and automatically chooses the best option? (i.e W=#screenareawidth# or H=#screenareaheight#)
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Dynamic preference over screenheight or width when using an image as backdrop?

Post by kyriakos876 »

Generally, what you can do is check the W and H of the image you want. You can do this like this:

Code: Select all


[MeasureBackground1]
Measure=Calc
Formula=1
IfCondition=([Background1:W] > #SCREENAREAWIDTH#)
IfTrueAction=[!SetOption Background1 W #SCREENAREAWIDTH#][!Update]
IfCondition2=([Background1:H] > #SCREENAREAHEIGHT#)
IfTrueAction=[!SetOption Background1 H #SCREENAREAHEIGHT#][!Update]
DynamicVariables=1
 
[Background1]
Meter=Image
ImageName=#bgbackground1#
DynamicVariables=1

What this does, is make make the picture smaller if, either the height or the width of the image is greater than the W/H of the screen.
(This is what I imagine you mean when you say "However, due to some aspect ratio stuff, sometimes it would be best to choose W=#screenareawidth# instead of H=#screenareaheight#" so if you mean other cases than the image being larger than the screen, let me know and I'll try to help you)
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Dynamic preference over screenheight or width when using an image as backdrop?

Post by balala »

Krainz wrote:Is there a way we can make a code so it detects the image won't fit and automatically chooses the best option? (i.e W=#screenareawidth# or H=#screenareaheight#)
Add both options: W=#screenareawidth# and H=#screenareaheight# to the [Background1] image meter.
Also you can try to modify the PreserveAspectRatio option, to 2: PreserveAspectRatio=2. The difference between these two values is that for: PreserveAspectRatio=1
1: The image is scaled to fit within the bounds specified by W and/or H while preserving the aspect ratio.
while for PreserveAspectRatio=2:
2: The image is scaled and cropped to fill the bounds specified by W and/or H while preserving the aspect ratio.
https://docs.rainmeter.net/manual-beta/meters/image/#PreserveAspectRatio

And one more:
PLEASE, PLEASE guys, try to understand that the !DeactivateConfig bang doesn't need a file parameter, as !ActivateConfig does. Eg in the [!DeactivateConfig "AsperiaSuite\Gamehall\Tiles" [color=#FF0000]"GameScreen1-Tiles.ini"[/color]] bang, the red colored file name is not needed, because at once just one single file of certain config can be activated and Rainmeter knows what file to deactivate when the !DeactivateConfig bang is executed. !ActivateConfig on the other hand requires the File parameter, because in the specified config can be more then one .ini files and Rainmeter can't know which one would you like to load.
User avatar
Krainz
Posts: 186
Joined: May 27th, 2012, 5:16 am
Contact:

Re: Dynamic preference over screenheight or width when using an image as backdrop?

Post by Krainz »

balala wrote:Add both options: W=#screenareawidth# and H=#screenareaheight# to the [Background1] image meter.
Also you can try to modify the PreserveAspectRatio option, to 2: PreserveAspectRatio=2. The difference between these two values is that for: PreserveAspectRatio=1

while for PreserveAspectRatio=2:

https://docs.rainmeter.net/manual-beta/meters/image/#PreserveAspectRatio
That works wonderfully. Thanks!
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Dynamic preference over screenheight or width when using an image as backdrop?

Post by balala »

Glad to help.
Post Reply