Fix blur behind control
By blurring the source background image first before clipping it rather than the opposite, because blur interpolates alpha as well and it needs the neighboring pixels from the source so that it doesnt interpolate pixels from nothing and mucking up the result with a hazy border.
MODIFY
WalletWasabi.Fluent/Controls/BlurBehind.cs
WalletWasabi.Fluent/Controls/BlurBehind.cs
@@ -53,26 +53,45 @@ public class BlurBehind : Control
}
using var backgroundSnapshot = skia.SkSurface.Snapshot();
- using var backdropShader = SKShader.CreateImage(backgroundSnapshot, SKShaderTileMode.Clamp,
+
+ using (var preBlur =
+ DrawingContextHelper.CreateDrawingContext(
+ new Size(backgroundSnapshot.Width, backgroundSnapshot.Height), new Vector(96, 96),
+ skia.GrContext))
+ {
+ using (var filter =
+ SKImageFilter.CreateBlur((int) _blurRadius.X, (int) _blurRadius.Y, SKShaderTileMode.Clamp))
+ using (var blurPaint = new SKPaint
+ {
+ ImageFilter = filter,
+ })
+ {
+ var canvas = preBlur.SkSurface.Canvas;
+ canvas.DrawSurface(skia.SkSurface, 0f, 0f, blurPaint);
+ canvas.Flush();
+ }
+
+ using var preBlurredSnapshot = preBlur.SkSurface.Snapshot();
+
+ using var backdropShader = SKShader.CreateImage(preBlurredSnapshot, SKShaderTileMode.Clamp,
SKShaderTileMode.Clamp, currentInvertedTransform);
using (var blurred =
DrawingContextHelper.CreateDrawingContext(_bounds.Size, new Vector(96, 96), skia.GrContext))
{
- using (var filter =
- SKImageFilter.CreateBlur((int)_blurRadius.X, (int)_blurRadius.Y, SKShaderTileMode.Clamp))
using (var blurPaint = new SKPaint
{
Shader = backdropShader,
- ImageFilter = filter,
})
{
- blurred.SkSurface.Canvas.DrawRect(0, 0, (float)_bounds.Width, (float)_bounds.Height, blurPaint);
+ blurred.SkSurface.Canvas.DrawRect(0, 0, (float) _bounds.Width, (float) _bounds.Height,
+ blurPaint);
}
blurred.DrawTo(skia);
}
}
+ }
public Rect Bounds => _bounds.Inflate(_blurRadius.X);

Fix blur behind control

By blurring the source background image first before clipping it rather than the opposite, because blur interpolates alpha as well and it needs the neighboring pixels from the source so that it doesnt interpolate pixels from nothing and mucking up the result with a hazy border.