Page 1 of 1

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

Posted: October 25th, 2017, 8:27 am
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#)

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

Posted: October 25th, 2017, 12:14 pm
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)

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

Posted: October 25th, 2017, 3:05 pm
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.

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

Posted: October 25th, 2017, 9:30 pm
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!

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

Posted: October 26th, 2017, 4:35 pm
by balala
Glad to help.