本文介绍了如何从canvas控件获取绘图会话(win2d)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在win8应用程序中,如何从canvascontrol(win2d)获取绘图会话,或者如何从canvasControl_Draw函数中在canvascontrol上绘制图像.

In a win8 app,how to get a drawingsession from a canvascontrol (win2d),or ,how to draw image on canvascontrol out of the function:canvasControl_Draw.

推荐答案

您不能-这是CanvasControl提供的策略的关键部分.

You cannot - this is a key part of policy provided by CanvasControl.

这可确保:

  • 在适当的时间创建并关闭绘图会话

  • the drawingsession is created and closed at the appropriate time

绘制

处理设备丢失的错误

如果要强制重绘,可以使用 CanvasControl.Invalidate().

If you want to force a redraw you can use CanvasControl.Invalidate().

或者,您可能会发现要渲染到屏幕外的CanvasRenderTarget(可以调用CreateDrawingSession).然后在CanvasControl_Draw中使用DrawImage将渲染目标绘制到控件上.

Alternatively, you may find that you want to render to an offscreen CanvasRenderTarget (that you can call CreateDrawingSession). Then use DrawImage in your CanvasControl_Draw to draw the render target to the control.

这篇关于如何从canvas控件获取绘图会话(win2d)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 23:49