本文整理汇总了C#中System.Windows.Forms.IDeviceContext.Unmap方法的典型用法代码示例。如果您正苦于以下问题:C# IDeviceContext.Unmap方法的具体用法?C# IDeviceContext.Unmap怎么用?C# IDeviceContext.Unmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.IDeviceContext
的用法示例。
在下文中一共展示了IDeviceContext.Unmap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryGetCaptured
public unsafe bool TryGetCaptured(IDeviceContext context, IntRectangle clientRectangle, FrameType frameType, int colorDiffThreshold, int mostDetailedMip, out GpuRawFrame capturedFrame)
{
stopwatch.Restart();
var result = texturePool.Extract(clientRectangle.Width, clientRectangle.Height);
var resultTexture = result.Item;
d3dDevice.GetFrontBufferData(0, d3dSurface1);
var sdxRectangle = new Rectangle(clientRectangle.X, clientRectangle.Y, clientRectangle.X + clientRectangle.Width, clientRectangle.Y + clientRectangle.Height);
var lockedRectangle = d3dSurface1.LockRectangle(sdxRectangle, LockFlags.ReadOnly);
var mappedSubresource = context.Map(resultTexture, 0, MapType.WriteDiscard, MapFlags.None);
{
int commonRowPitch = Math.Min(mappedSubresource.RowPitch, lockedRectangle.Pitch);
Parallel.For(0, clientRectangle.Height, i =>
Memory.CopyBulk(
(byte*)mappedSubresource.Data + i * mappedSubresource.RowPitch,
(byte*)lockedRectangle.DataPointer + i * lockedRectangle.Pitch,
commonRowPitch));
}
context.Unmap(resultTexture, 0);
d3dSurface1.UnlockRectangle();
var frameInfo = new FrameInfo(frameType, (float)Stopwatch.GetTimestamp() / Stopwatch.Frequency,
mostDetailedMip, colorDiffThreshold, clientRectangle.Width, clientRectangle.Height,
Cursor.Position.X - clientRectangle.X, Cursor.Position.Y - clientRectangle.Y);
capturedFrame = new GpuRawFrame(frameInfo, result);
stopwatch.Stop();
statistics.OnCapture(stopwatch.Elapsed.TotalMilliseconds);
return true;
}