It is currently October 23rd, 2019, 4:15 am

Working with Bitmap

Our most popular Tips and Tricks from the Rainmeter Team and others
User avatar
jsmorley
Developer
Posts: 19618
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Working with Bitmap

jsmorley » April 29th, 2018, 2:50 pm

xames3 wrote:Guys thanks for your help it is working though but the animation doesn't stops on last frame. I want the animation to run once every refresh/loading and the last frame should stay in place.
Also can some please explain the executions of the above code? That would be helpful for me to learn and understand future codes even better.
Thanks in advance!
If you use code like this:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
OnRefreshAction=[!CommandMeasure MeasureAction "Execute 1"]

[MeasureCount]
Measure=Loop
StartValue=1
EndValue=135
UpdateDivider=-1
Paused=1

[MeasureAction]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Start | Wait 10 | Repeat CountUp,16,135 | Wait 10 | Stop
Start=[!UnpauseMeasure MeasureCount]
CountUp=[!UpdateMeasure MeasureCount][!UpdateMeter MeterCount][!Redraw]
Stop=[!PauseMeasure MeasureCount]

[MeterCount]
Meter=String
MeasureName=MeasureCount
FontSize=15
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
And just replace the dummy String meter I have with your Bitmap meter, it should work.

What it is doing is:

1) The skins starts with the Loop measure [MeasureCount] "paused". That means it will have its initial value "1", but won't update any further while it is paused. It also has UpdateDivider=-1, which means that even once it is unpaused, it will only update once and stop.

2) Then when the skin is loaded or refreshed, the OnRefreshAction will fire the ActionTimer measure [MeasureAction].

3) That measure will do the following:

a) Unpause the Loop measure.

b) Force an update to the Loop measure, then update the meter and redraw the skin. That will cause the meter to use the value of the Loop measure as the "frame" of the Bitmap. Repeat that 135 times, with a "wait" of 16ms between each time.

c) Pause the Loop measure again, so it will stay at the "last" value it has.

So when the skin is loaded or refreshed, it will count from 1 to 135 at 16ms intervals, and force the frame of the bitmap to that number. Then it will leave that last bitmap frame in place, and just sorta idle at an Update of 1000. I don't know what if anything else you might have the skin doing, but unless you also need them to update faster than once a second, there is no benefit to using resources to drive this one-time animation.
User avatar
jsmorley
Developer
Posts: 19618
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Working with Bitmap

jsmorley » April 29th, 2018, 2:52 pm

fonpaolo wrote::17what
All the more reason not to set Update to anything other than 1000, or maybe even -1, on this skin.
User avatar
jsmorley
Developer
Posts: 19618
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Working with Bitmap

jsmorley » April 29th, 2018, 3:00 pm

That image is 259200 X 1080. If I divide 259200 by 1920, I get 13.4895, not 135.

If that image is not designed so it has some number of exactly sized and positioned "frames" that are 1920 pixels wide, you are not going to get the effect you want.

And boy, this skin takes a couple of seconds to even "load". That's some image.
xames3
Posts: 10
Joined: April 29th, 2018, 9:10 am

Re: Working with Bitmap

xames3 » April 29th, 2018, 3:05 pm

:confused: I suck at this.
Couldn't make it work. Tried replacing he string meter as suggested but it ends with some other frame but not the last frame.
User avatar
jsmorley
Developer
Posts: 19618
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Working with Bitmap

jsmorley » April 29th, 2018, 3:07 pm

xames3 wrote::confused: I suck at this.
Couldn't make it work. Tried replacing he string meter as suggested but it ends with some other frame but not the last frame.
I think there is something amiss with your image. It can't be divided equally by 1920.
xames3
Posts: 10
Joined: April 29th, 2018, 9:10 am

Re: Working with Bitmap

xames3 » April 29th, 2018, 3:17 pm

tried using this image instead it is 180 frame png. runs smoothly but doesn't stop at last frame. am i missing something big?
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 19618
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Working with Bitmap

jsmorley » April 29th, 2018, 3:22 pm

xames3 wrote:tried using this image instead it is 180 frame png. runs smoothly but doesn't stop at last frame. am i missing something big?
That is 400 pixels wide, that simply can't be divided equally by 180. It's 2.222222222
User avatar
jsmorley
Developer
Posts: 19618
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Working with Bitmap

jsmorley » April 29th, 2018, 3:29 pm

Your problem isn't the measures or the "counting" or any of that, it some fundamental misunderstanding with how a Bitmap meter works, and what kind of BitmapImage is needed.

What the meter does is take the image you provide, and divides it into equal sections based on the value you set in BitmapFrames.

So if you wanted a two-frame bitmap, and wanted it to be 100 pixels in size, you create an image file, .png or whatever, that is exactly 200 pixels wide, and set BitmapFrames to 2.

Then when the value of the measure that is driving the Bitmap meter is "1", it will display the first 1 to 100 pixels of the width of the image. When the value is "2", it will display the width from 101 to 200.
xames3
Posts: 10
Joined: April 29th, 2018, 9:10 am

Re: Working with Bitmap

xames3 » April 29th, 2018, 3:31 pm

each frame is 562 px wide.
Am I stitching them wrong? If yes then please help/guide me to create those sprite. One thing i noticed is that starting frame is empty. is it causing any problem?
User avatar
jsmorley
Developer
Posts: 19618
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Working with Bitmap

jsmorley » April 29th, 2018, 3:34 pm

That image you just posted is 400 pixels wide by 1 pixel tall.. ;-)