本文整理汇总了C#中Surface.IsContiguousMemoryRegion方法的典型用法代码示例。如果您正苦于以下问题:C# Surface.IsContiguousMemoryRegion方法的具体用法?C# Surface.IsContiguousMemoryRegion怎么用?C# Surface.IsContiguousMemoryRegion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Surface
的用法示例。
在下文中一共展示了Surface.IsContiguousMemoryRegion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadOrSaveSurfaceRegion
private static unsafe void LoadOrSaveSurfaceRegion(FileStream fileHandle, Surface surface, PdnRegion region, bool trueForSave)
{
Rectangle[] scans = region.GetRegionScansReadOnlyInt();
Rectangle regionBounds = region.GetBoundsInt();
Rectangle surfaceBounds = surface.Bounds;
int scanCount = 0;
void*[] ppvBuffers;
uint[] lengths;
regionBounds.Intersect(surfaceBounds);
long length = (long)regionBounds.Width * (long)regionBounds.Height * (long)ColorBgra.SizeOf;
if (scans.Length == 1 &&
length <= uint.MaxValue &&
surface.IsContiguousMemoryRegion(regionBounds))
{
ppvBuffers = new void*[1];
lengths = new uint[1];
ppvBuffers[0] = surface.GetPointAddressUnchecked(regionBounds.Location);
lengths[0] = (uint)length;
}
else
{
for (int i = 0; i < scans.Length; ++i)
{
Rectangle rect = scans[i];
rect.Intersect(surfaceBounds);
if (rect.Width != 0 && rect.Height != 0)
{
scanCount += rect.Height;
}
}
int scanIndex = 0;
ppvBuffers = new void*[scanCount];
lengths = new uint[scanCount];
for (int i = 0; i < scans.Length; ++i)
{
Rectangle rect = scans[i];
rect.Intersect(surfaceBounds);
if (rect.Width != 0 && rect.Height != 0)
{
for (int y = rect.Top; y < rect.Bottom; ++y)
{
ppvBuffers[scanIndex] = surface.GetPointAddressUnchecked(rect.Left, y);
lengths[scanIndex] = (uint)(rect.Width * ColorBgra.SizeOf);
++scanIndex;
}
}
}
}
if (trueForSave)
{
FileSystem.WriteToStreamingFileGather(fileHandle, ppvBuffers, lengths);
}
else
{
FileSystem.ReadFromStreamScatter(fileHandle, ppvBuffers, lengths);
}
}