加阴影
var bitmap = new CanvasRenderTarget(Control, (float)Width,
(float)Height, 96);
var effect = new Transform2DEffect() {
Source = new ShadowEffect()
{
Source = bitmap,
BlurAmount = 2,
},
TransformMatrix = Matrix3x2.CreateTranslation(3, 3)
};
private void DrawerCanvas_Draw(Microsoft.Graphics.Canvas.UI.Xaml.CanvasControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasDrawEventArgs args)
{
args.DrawingSession.DrawImage(effect);
}
无论内容是什么输出的时一个黑色的框框带阴影效果,
应该加代码输出原版的图像,即可
private void DrawerCanvas_Draw(Microsoft.Graphics.Canvas.UI.Xaml.CanvasControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasDrawEventArgs args)
{
args.DrawingSession.DrawImage(effect);
args.DrawingSession.DrawImage(bitmap);
}
转载请保留原文链接: https://zodream.cn/blog/id/223.html