It is currently May 19th, 2019, 7:38 am

Mask Image

Changes made during the Rainmeter 3.2 beta cycle.
User avatar
Active Colors
Moderator
Posts: 508
Joined: February 16th, 2012, 3:32 am

Re: Image Masking

Active Colors » August 22nd, 2014, 8:59 am

Brilliant! Thanks a bunch!
User avatar
jsmorley
Developer
Posts: 19245
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Image Masking

jsmorley » August 22nd, 2014, 1:21 pm

Dank420 wrote:
Great job Rainmeter team!!!

Code: Select all

[Rainmeter]
Update=75
DynamicWindowSize=1
AccurateText=1

[MeasureAnim]
Measure=Calc
Formula=(MeasureAnim % 16) + 1

[MeterAnim]
Meter=Image
W=200
ImagePath=#@#Images\
MeasureName=MeasureAnim
MaskImagePath=#@#Masks\
MaskImageName=Circle.png
https://dl.dropboxusercontent.com/u/4991063/MaskDance_1.0.rmskin
test.gif
test.gif
:-)
You do not have the required permissions to view the files attached to this post.
User avatar
VasTex
Posts: 408
Joined: September 20th, 2012, 3:17 pm
Location: USA - Montana

Re: Image Masking

VasTex » August 22nd, 2014, 1:24 pm

With great power comes great responsibility.
01010100 01100101 01100011 01101000 01101110 01101111 01101100 01101111 01100111 01101001
01100011 01100001 01101100 00100000 01000010 01100001 01100100 01100001 01110011 01110011
User avatar
jsmorley
Developer
Posts: 19245
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Image Masking

jsmorley » August 22nd, 2014, 2:06 pm

It should be noted that the ImageName is masked onto any "non-transparent" areas of MaskImageName. However, any partial transparency of the either image is preserved in the final result. This can be used to create some nice effects, where you have some partially transparent areas of the mask, and the resulting image will have the same transparency.

In effect what is going on is that the ImageName is masked onto the MaskImageName, replacing pixel for pixel MaskImageName with ImageName. If a pixel in the either the mask or the image has an alpha channel that is not 100%, the resulting masked image will use that alpha channel. That is what results in it being a "shape" when the mask has fully transparent areas, but it can be used to have partially transparent areas as well.

If either the primary image or the mask image has areas of transparency or partial transparency, those "alpha channel" values are applied to the final image. When both images have a shared area with full or partial transparency, the "most transparent" value is applied.

For example, using a solid to transparent gradient:
Gradient.png
2014-08-22_104209.png
In this case, we are using the "mask" to create a transition from solid to transparent, rather than using the mask to define a "shape". The two can be combined of course, to get some nice effects.
2014-08-22_104209.png
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 19245
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Image Masking

jsmorley » August 22nd, 2014, 3:42 pm

It should also be noted that while MaskImageName does not support being bound to a measure with something like:

[MeterOne]
Meter=Image
MeasureName=SomeMeasure
MeasureName2=SomeOtherMeasure
MaskImageName=%2.png

You can still have MaskImageName use the value of a measure in a dynamic way with [SectionVariables], (or even #Variables#) like:

[MeterOne]
Meter=Image
MeasureName=SomeMeasure
MaskImageName=[SomeOtherMeasure].png
DynamicVariables=1
User avatar
iNjUST
Posts: 118
Joined: June 20th, 2012, 12:44 am

Re: Image Masking

iNjUST » August 22nd, 2014, 4:38 pm

Huzzah! Very exciting news. Fantastic work, Rainmeter Team! I look forward to testing this out.

Question: since ScaleMargins is not available, and the scaling is fixed based on W/H, is there a way to use this new feature, or plans for additional development, to produced rounded rectangles of the same proportions as the source image? An image mask would have a fixed size and aspect ratio.

I came up with a novel approach to image masking including dynamic rounded corners, but it has obvious shortcomings.

http://rainmeter.net/forum/viewtopic.php?p=101911#p101911

I'd love to see something like this integrated into the image mask tool in a future update.
User avatar
jsmorley
Developer
Posts: 19245
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Image Masking

jsmorley » August 22nd, 2014, 4:46 pm

iNjUST wrote:Huzzah! Very exciting news. Fantastic work, Rainmeter Team! I look forward to testing this out.

Question: since ScaleMargins is not available, and the scaling is fixed based on W/H, is there a way to use this new feature, or plans for additional development, to produced rounded rectangles of the same proportions as the source image? An image mask would have a fixed size and aspect ratio.

I came up with a novel approach to image masking including dynamic rounded corners, but it has obvious shortcomings.

http://rainmeter.net/forum/viewtopic.php?p=101911#p101911

I'd love to see something like this integrated into the image mask tool in a future update.
Not in the short term. The size of the mask, and thus the meter, is defined by the W an H set on the meter. The size of the resulting image is entirely driven by that, sizing and cropping the primary image to "fill" the meter. There really is no possible way to have the reverse, the mask image be in any way driven by the primary image. That is a dog chasing its own tail.

You certainly can create a rectangular "shape" as a mask image that is some defined size and has rounded corners, that is sorta the entire point of this. However, you can't effect the "aspect" of the corners independent of the rest of the mask image, that would require some kind of MaskScaleMargins which might be possible in a future version, but no promises, and you can't have that mask image be sized in response to the size of the primary image. The primary image will just "fill" the mask image, with the size exactly the same size as the meter created by the mask image.
User avatar
exper1mental
Posts: 282
Joined: January 9th, 2013, 7:52 pm
Location: Southern USA

Re: Image Masking

exper1mental » August 22nd, 2014, 5:02 pm

This is awesome! So glad this was added! :D :thumbup:
Image
User avatar
jsmorley
Developer
Posts: 19245
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Image Masking

jsmorley » August 22nd, 2014, 5:20 pm

Weather.png
30.png
01.png
45.png
02.png

Code: Select all

MeasureName=WebParserIconMeasure
MaskImageName=Weather.png
You do not have the required permissions to view the files attached to this post.
NisseDILLIGAF
Posts: 20
Joined: May 31st, 2011, 7:15 am

Re: Image Masking

NisseDILLIGAF » August 22nd, 2014, 5:25 pm

Cool things will come from this :)
heres something i did from jsmorley's files...
Image
https://www.dropbox.com/s/fnxue8tuvqpulzi/TVDance_.rmskin