我正在画到屏幕外CanvasRenderTarget
。然后我把它画到我的CanvasAnimatedControl
.
复制的位图“模糊”;第一行是离屏位图,第二行是直接绘制到会话CanvasAnimatedControl
:
它不是太明显,但在应用缩放时更加明显:
这是代码:
public sealed partial class MainPage
{
const string Text = "WHY AM I BLURRY!? MMmm///AaBbCcDdEeFf!!££$$%%ZZAA";
Matrix3x2 _scale = Matrix3x2.CreateScale(3,3);
CanvasRenderTarget _offscreenCanvas;
readonly CanvasTextFormat _ctf = new CanvasTextFormat
{
FontFamily = "Century Gothic",
FontSize = 20
};
public MainPage() => InitializeComponent();
void onCanvasDraw(ICanvasAnimatedControl sender, CanvasAnimatedDrawEventArgs args)
{
args.DrawingSession.Transform = _scale;
args.DrawingSession.Clear(Colors.Aquamarine);
using (var offscreenSession = _offscreenCanvas.CreateDrawingSession())
{
offscreenSession.Clear(Colors.Aquamarine);
offscreenSession.DrawText(Text, 0, 0, Colors.Red, _ctf);
offscreenSession.DrawLine(new Vector2(0,0), new Vector2(100,10), Colors.Black);
}
//args.DrawingSession.DrawImage(_offscreenCanvas, Vector2.Zero, _offscreenCanvas.Bounds, 1f, CanvasImageInterpolation.Linear);
args.DrawingSession.DrawImage(_offscreenCanvas,0,0);
args.DrawingSession.DrawText(Text, 0, 20, Colors.Red, _ctf);
args.DrawingSession.DrawLine(new Vector2(0, 20), new Vector2(100, 30), Colors.Black);
}
void onCanvasCreateResources(CanvasAnimatedControl sender, CanvasCreateResourcesEventArgs args) =>
_offscreenCanvas = new CanvasRenderTarget(sender.Device, 800, 20, 96);
}
这是 XAML:
<Grid Background="Black">
<xaml:CanvasAnimatedControl Draw="onCanvasDraw" CreateResources="onCanvasCreateResources" BorderThickness="5" BorderBrush="Blue"/>
</Grid>
怎么了?
更新 我想通了,但认为这可能是一个有用的参考问题