Skip to content

[Sample+Feature] Image BlendingΒ #3737

@michael-hawker

Description

@michael-hawker

Discussed in Discord: https://discord.com/channels/372137812037730304/774042795530649600/807292130007318570

Describe the problem this feature would solve

Ability to blend two images dynamically with XAML Pipeline Brush Effects? Example of desired effect:

image

Images from Unsplash Glasses on Beach and Creek

Describe the solution

From @Sergio0694:

Ok so, I haven't tried this, but there's at least a couple possible ways to do this, depending on the approach you prefer. Each has its pros and cons.

  1. "Live": create a pipeline with a canvas geometry that splits the image in two along the center. Apply a gaussian blur to it to fade it at the center. Load one of the two images, apply that mask to it. Load the other image, then place the first one on top of it with a blend effect and overlay mode.
  2. "Offline": use a library like ImageSharp to just load the first image, then draw the second one on top of that with that blurred masking, then display that. This has the advantage of being less computationally intensive, as you only create it once and then display it, rather than using pixel shaders at runtime to render it.
    I'm thinking some of Ratish's APIs could be useful for this masking too, though I think the ones specifically for gaussian masking have not been integrated into the Toolkit just yet

From @ratishphilip:

Yes the GaussianMaskSurface would suit this purpose. I am currently working on porting the various RenderSurfaces from CompositionProToolkit to Microsoft.Toolkit.Uwp.UI.Media. Hope to submit a PR soon. πŸ˜ƒ

Additional context & Screenshots

Should probably file supporting issues for the underlying features, but wanted to have a tracking issue for a supporting sample to demonstrate them.

  • May be also more useful for this type of effect to blend to transparency with the image which could help with nice background effects for applications?

Would be nice to know if others need this type of effect too.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions