It is currently March 29th, 2024, 11:02 am

MaskImage based on GDI+

General topics related to Rainmeter.
cfixd
Posts: 31
Joined: September 1st, 2014, 1:38 am

MaskImage based on GDI+

Post by cfixd »

I' ve written some codes to realize the MaskImage with GDI+.
It' s less efficient but it seems some computer can't use the D2D engine even running on win7.

I've resize the Image into MaskImage W&H in the code, is it possible to add a option like this?

Forgive my poor coding..it's just a test.

It's based on rainmeter-3.2.1.2386, here is the file I've changed:
rainmeter-3.2.1.2386_GDIP_MaskImage.rar
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: MaskImage based on GDI+

Post by jsmorley »

I don't think we are going to be interested in taking this route. There are a lot of spiffy new things in D2D 1.1, and we have plans to take advantage of them in Rainmeter. While some of them can be pretty well replicated in GDI+, many can't, and in any case we really don't want to get in the business of "double coding" new stuff as we go forward.

The way we are using D2D should be supported on virtually all hardware, as we are not using the "hardware acceleration" features of D2D. All we will require is Window 7 with Service Pack 1 or later. We just don't intend to limit what we do or create a ton of extra work to support Windows XP. It's just time to get over that.
cfixd
Posts: 31
Joined: September 1st, 2014, 1:38 am

Re: MaskImage based on GDI+

Post by cfixd »

jsmorley wrote:There are a lot of spiffy new things in D2D 1.1, and we have plans to take advantage of them in Rainmeter. While some of them can be pretty well replicated in GDI+, many can't, and in any case we really don't want to get in the business of "double coding" new stuff as we go forward.
I can understand it,what I really care is that whether it is possible to resize the Image into MaskImage W&H before show in the skin, with a option added?
e.g. I have singer image of 60*60,I want to apply mask image on it,now the mask image can only be 60*60,but it's not the size I want in the skin.
In a 15 inch screen,1920*1080 or 1366*768 make a big difference, I use a variable like "#w#*#size#" to support both of them,but they can't apply to mask image or bar image.

I know there is little use... just a advice.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: MaskImage based on GDI+

Post by jsmorley »

I'm sorry, I misunderstood your original post. I thought you were just re-creating the MaskImage functionality it GDI+, as a way to support folks who can't use D2D, which in all honesty is virtually nobody on Windows 7 or better. I'm entirely done worrying about XP, and if folks don't keep their Windows 7 updated with at least the important service packs, I have little sympathy. People who don't keep their Windows updated are the same people who never back up. Just a failure waiting for the right opportunity to cause the maximum pain possible.

As you your real question, I'm not sure I follow...
Sizing

When MaskImageName is defined, then W and H define the size of the mask image, and the resulting size of the meter. If you define both W and H, then the mask image will be sized to those specific dimensions. If you define only W or H, then the mask image will be sized to the dimension you define, while automatically preserving the aspect ratio. If neither W or H is defined, the size of the mask will be the original image size.

The ImageName defined, either specifically or by binding the meter to a measure with MeasureName, will be sized to fit in the mask image. It will "fill" the image by sizing and cropping as needed, similar to the PreserveAspectRatio=2 setting on a normal image meter.

The result is that if only one of W or H is specified, the code automatically "fits" the mask image while preserving the aspect ratio. It always automatically "fills" the primary image while preserving the aspect ratio. Any PreserveAspectRatio set on the meter is ignored.

While just like with PreserveApectRatio=2 there is no control over the "origin" when the ImageName image is cropped to fit in the MaskImageName image, some control over what part of the image is used when masked can be had by creating a mask image with transparent areas of any size on the left, right, top or bottom as desired. This in effect will allow for some control over what part of the image is "displayed" when the image is sized and cropped to fit the mask. The size of the meter itself will be the full size of the mask image of course, as defined by W and / or H.

So in a sense W and H are used to size both images. Then the ImageName image is masked onto the MaskImageName image, only displaying in non-transparent areas of MaskImageName.
You set the W and H of the meter, and thus the MaskImageName image, to anything you want. Then the actual ImageName image that you mask "into it" is automatically sized and cropped so it exactly fits the dimensions of MaskImageName. It has to be that way, since the image MUST not be any larger or smaller than the mask. You still have as much control as you want over how big or small the result is in your skin however, as that is driven by the W and H you set on the meter. The W and H will size MaskImageName, and ImageName will automatically be the same.
cfixd
Posts: 31
Joined: September 1st, 2014, 1:38 am

Re: MaskImage based on GDI+

Post by cfixd »

Sorry for taking you so much time, I've misunderstood the manual and think it's the same as the bar image ,even without more test..... :-(