I've been trying to look for an examples which related to Color Replacement, here's an example using the Photoshop which can take, for example, a Blue shade and replace it with a Red shade:
Is this possible using the Composition Effects in the latest version of Composition Api?
I've seen examples related to Hue Rotations and Temperature and Tint:
https://xamlbrewer.wordpress.com/2016/04/08/uwp-composition-effects-hue-rotation/
https://xamlbrewer.wordpress.com/2016/04/19/uwp-composition-effects-temperature-and-tint/
But I'm wondering if the api is capable of using Effects to switch a color range in an image ??
I have a solution you may like. The sample looks like this:
To achieve this I used 3 effects in a chain:
PixelShaderEffect
,GaussianBlurEffect
andBlendEffect
from Win2d API.XAML has
CanvasAnimatedControl
to draw the result plus some helpers like source (the color we want to replace) and replace color pickers and threshold slider.Code behind:
And the most exciting thing is a pixel shader:
To compile it you should take a tour here: https://github.com/Microsoft/Win2D-Samples/tree/master/ExampleGallery/Shared/Shaders
There's cmd file that compiles your hlsl shaders. If you need some help - comment it. Have fun!