本文整理汇总了C#中PaintDotNet.PdnRegion.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# PdnRegion.Clone方法的具体用法?C# PdnRegion.Clone怎么用?C# PdnRegion.Clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PaintDotNet.PdnRegion
的用法示例。
在下文中一共展示了PdnRegion.Clone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IrregularSurface
/// <summary>
/// Constructs an IrregularSurface by copying the given region-of-interest from an Image.
/// </summary>
/// <param name="source">The Surface to copy pixels from.</param>
/// <param name="roi">Defines the Region from which to copy pixels from the Image.</param>
public IrregularSurface(Surface source, PdnRegion roi)
{
PdnRegion roiClipped = (PdnRegion)roi.Clone();
roiClipped.Intersect(source.Bounds);
Rectangle[] rects = roiClipped.GetRegionScansReadOnlyInt();
this.placedSurfaces = new ArrayList(rects.Length);
foreach (Rectangle rect in rects)
{
this.placedSurfaces.Add(new PlacedSurface(source, rect));
}
this.region = roiClipped;
}
示例2: SaveRegion
public void SaveRegion(PdnRegion saveMeRegion, Rectangle saveMeBounds)
{
BitmapLayer activeLayer = (BitmapLayer)ActiveLayer;
if (savedTiles == null)
{
savedTiles = new BitVector2D(
(activeLayer.Width + saveTileGranularity - 1) / saveTileGranularity,
(activeLayer.Height + saveTileGranularity - 1) / saveTileGranularity);
savedTiles.Clear(false);
}
Rectangle regionBounds;
if (saveMeRegion == null)
{
regionBounds = saveMeBounds;
}
else
{
regionBounds = saveMeRegion.GetBoundsInt();
}
Rectangle bounds = Rectangle.Union(regionBounds, saveMeBounds);
bounds.Intersect(activeLayer.Bounds);
int leftTile = bounds.Left / saveTileGranularity;
int topTile = bounds.Top / saveTileGranularity;
int rightTile = (bounds.Right - 1) / saveTileGranularity;
int bottomTile = (bounds.Bottom - 1) / saveTileGranularity;
for (int tileY = topTile; tileY <= bottomTile; ++tileY)
{
Rectangle rowAccumBounds = Rectangle.Empty;
for (int tileX = leftTile; tileX <= rightTile; ++tileX)
{
if (!savedTiles.Get(tileX, tileY))
{
Rectangle tileBounds = new Rectangle(tileX * saveTileGranularity, tileY * saveTileGranularity,
saveTileGranularity, saveTileGranularity);
tileBounds.Intersect(activeLayer.Bounds);
if (rowAccumBounds == Rectangle.Empty)
{
rowAccumBounds = tileBounds;
}
else
{
rowAccumBounds = Rectangle.Union(rowAccumBounds, tileBounds);
}
savedTiles.Set(tileX, tileY, true);
}
else
{
if (rowAccumBounds != Rectangle.Empty)
{
using (Surface dst = ScratchSurface.CreateWindow(rowAccumBounds),
src = activeLayer.Surface.CreateWindow(rowAccumBounds))
{
dst.CopySurface(src);
}
rowAccumBounds = Rectangle.Empty;
}
}
}
if (rowAccumBounds != Rectangle.Empty)
{
using (Surface dst = ScratchSurface.CreateWindow(rowAccumBounds),
src = activeLayer.Surface.CreateWindow(rowAccumBounds))
{
dst.CopySurface(src);
}
rowAccumBounds = Rectangle.Empty;
}
}
if (this.saveRegion != null)
{
this.saveRegion.Dispose();
this.saveRegion = null;
}
if (saveMeRegion != null)
{
this.saveRegion = saveMeRegion.Clone();
}
}
示例3: MaskedSurface
/// <summary>
/// Constructs a MaskSurface by copying the given region-of-interest from an Image.
/// </summary>
/// <param name="source">The Surface to copy pixels from.</param>
/// <param name="roi">Defines the Region from which to copy pixels from the Image.</param>
public MaskedSurface(Surface source, PdnRegion roi)
{
PdnRegion roiClipped = (PdnRegion)roi.Clone();
roiClipped.Intersect(source.Bounds);
Rectangle boundsClipped = roiClipped.GetBoundsInt();
this.surface = new Surface(boundsClipped.Size);
this.surface.Clear(ColorBgra.FromUInt32(0x00ffffff));
Rectangle rect = boundsClipped;
Point dstOffset = new Point(rect.X - boundsClipped.X, rect.Y - boundsClipped.Y);
this.surface.CopySurface(source, dstOffset, rect);
this.region = roiClipped;
SetPathField(PdnGraphicsPath.FromRegion(this.region));
}