1

I have a canvas in which I add a child image element.

<Canvas SnapsToDevicePixels="True" Width="56160" Height="37440">
    <Image Width="56160" Height="37440" x:Name="OverlayImage"/>
</Canvas>

On this canvas, I need to draw ordinary lines that will blur the background. An example of this brush is available in Photoshop (Blur brush). I know how to blur the entire canvas using the BlurEffect class (from the System.Windows.Media.Effects namespace).

But I need blurring where the user draws the line.

I guess that maybe I need to implement a shader for this task, but I don’t have the practice of writing code HLSL (High Level Shader Language). Tell me, what approach should I use to solve this problem?

Maxim_A
  • 183
  • 2
  • 13

1 Answers1

1

Blur the whole image, store the result, use a regular brush and paint the mask and alphablend the blurred image with the original using the mask.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Bacon
  • 473
  • 3
  • 9
  • Yes, I was thinking about this option. but I wanted to hear more about the possibility of implementation with the help of shaders, which at the input will accept the locations of the pixels necessary for blurring. – Maxim_A Sep 30 '19 at 00:12
  • 1
    you could visit shadertoy.com, those are glsl shaders but glsl, but glsl and hlsl are very similar, and you could use a glsl to hlsl converter like http://diligentgraphics.com/diligent-engine/shader-converter/standalone-converter/ – Bacon Sep 30 '19 at 19:15
  • https://www.shadertoy.com/view/XdfGDH is a blur shader, https://www.shadertoy.com/view/llS3WW is a mouse draw shader, combining those with alpha blend could work – Bacon Sep 30 '19 at 19:27
  • even if something comes of it. on site shadertoy.com there are GLSL shaders, Converter from HLSL to GLSL. some kind of inconsistency) – Maxim_A Sep 30 '19 at 19:50
  • sorry, i misread, here is a guide to port glsl to hlsl: https://alastaira.wordpress.com/2015/08/07/unity-shadertoys-a-k-a-converting-glsl-shaders-to-cghlsl/ – Bacon Sep 30 '19 at 20:16