本文整理汇总了C#中System.Windows.Media.Visual.Render方法的典型用法代码示例。如果您正苦于以下问题:C# Visual.Render方法的具体用法?C# Visual.Render怎么用?C# Visual.Render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Visual
的用法示例。
在下文中一共展示了Visual.Render方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
static internal void Render(
IntPtr pRenderTarget,
DUCE.Channel channel,
Visual visual,
int width,
int height,
double dpiX,
double dpiY,
Matrix worldTransform,
Rect windowClip
)
{
DUCE.Resource target =
new DUCE.Resource();
DUCE.Resource root =
new DUCE.Resource();
DUCE.ResourceHandle targetHandle = DUCE.ResourceHandle.Null;
DUCE.ResourceHandle rootHandle = DUCE.ResourceHandle.Null;
Matrix deviceTransform = new Matrix(
dpiX * (1.0 / 96.0), 0,
0, dpiY * (1.0 / 96.0),
0, 0);
deviceTransform = worldTransform * deviceTransform;
MatrixTransform mtDeviceTransform = new MatrixTransform(deviceTransform);
DUCE.ResourceHandle deviceTransformHandle =
((DUCE.IResource)mtDeviceTransform).AddRefOnChannel(channel);
try
{
// ------------------------------------------------------------
// Create the composition target and root visual resources.
target.CreateOrAddRefOnChannel(target, channel, DUCE.ResourceType.TYPE_GENERICRENDERTARGET);
targetHandle = target.Handle;
DUCE.CompositionTarget.PrintInitialize(
targetHandle,
pRenderTarget,
width,
height,
channel);
root.CreateOrAddRefOnChannel(root, channel, DUCE.ResourceType.TYPE_VISUAL);
rootHandle = root.Handle;
DUCE.CompositionNode.SetTransform(
rootHandle,
deviceTransformHandle,
channel);
DUCE.CompositionTarget.SetRoot(
targetHandle,
rootHandle,
channel);
channel.CloseBatch();
channel.Commit();
// ------------------------------------------------------------
// Render the freshly created target.
RenderContext renderContext = new RenderContext();
renderContext.Initialize(channel, rootHandle);
visual.Precompute();
visual.Render(renderContext, 0);
// ------------------------------------------------------------
// Flush the channel and present the composition target.
channel.CloseBatch();
channel.Commit();
channel.Present();
MediaContext mediaContext = MediaContext.CurrentMediaContext;
mediaContext.NotifySyncChannelMessage(channel);
}
finally
{
// ------------------------------------------------------------
// Clean up and release the root visual.
if (!rootHandle.IsNull)
{
DUCE.CompositionNode.RemoveAllChildren(
rootHandle,
channel);
((DUCE.IResource)visual).ReleaseOnChannel(channel);
root.ReleaseOnChannel(channel);
//.........这里部分代码省略.........