本文整理汇总了C#中PaintDotNet.PdnRegion.GetBoundsInt方法的典型用法代码示例。如果您正苦于以下问题:C# PdnRegion.GetBoundsInt方法的具体用法?C# PdnRegion.GetBoundsInt怎么用?C# PdnRegion.GetBoundsInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PaintDotNet.PdnRegion
的用法示例。
在下文中一共展示了PdnRegion.GetBoundsInt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
}
示例2: MaskedSurface
public MaskedSurface(Surface source, PdnGraphicsPath path)
{
RectangleF boundsF = path.GetBounds();
Rectangle bounds = Utility.RoundRectangle(boundsF);
Rectangle boundsClipped = Rectangle.Intersect(bounds, source.Bounds);
Rectangle boundsRead;
if (bounds != boundsClipped)
{
PdnRegion region = new PdnRegion(path);
region.Intersect(source.Bounds);
SetPathField(PdnGraphicsPath.FromRegion(region));
this.region = region;
boundsRead = region.GetBoundsInt();
}
else
{
SetPathField(path.Clone());
this.region = new PdnRegion(this.path);
boundsRead = boundsClipped;
}
if (boundsRead.Width > 0 && boundsRead.Height > 0)
{
this.surface = new Surface(boundsRead.Size);
this.surface.CopySurface(source, boundsRead);
}
else
{
this.surface = null;
}
}
示例3: FromRegion
public static PdnGraphicsPath FromRegion(PdnRegion region)
{
Rectangle[] scans = region.GetRegionScansReadOnlyInt();
if (scans.Length == 1)
{
PdnGraphicsPath path = new PdnGraphicsPath();
path.AddRectangle(scans[0]);
path.CloseFigure();
return path;
}
else
{
Rectangle bounds = region.GetBoundsInt();
BitVector2D stencil = new BitVector2D(bounds.Width, bounds.Height);
for (int i = 0; i < scans.Length; ++i)
{
Rectangle rect = scans[i];
rect.X -= bounds.X;
rect.Y -= bounds.Y;
stencil.SetUnchecked(rect, true);
}
PdnGraphicsPath path = PathFromStencil(stencil, new Rectangle(0, 0, stencil.Width, stencil.Height));
using (Matrix matrix = new Matrix())
{
matrix.Reset();
matrix.Translate(bounds.X, bounds.Y);
path.Transform(matrix);
}
return path;
}
}
示例4: FromRegions
public static PdnGraphicsPath FromRegions(PdnRegion lhs, CombineMode combineMode, PdnRegion rhs)
{
Rectangle lhsBounds = lhs.GetBoundsInt();
Rectangle rhsBounds = rhs.GetBoundsInt();
int left = Math.Min(lhsBounds.Left, rhsBounds.Left);
int top = Math.Min(lhsBounds.Top, rhsBounds.Top);
int right = Math.Max(lhsBounds.Right, rhsBounds.Right);
int bottom = Math.Max(lhsBounds.Bottom, rhsBounds.Bottom);
Rectangle bounds = Rectangle.FromLTRB(left, top, right, bottom);
BitVector2D stencil = new BitVector2D(bounds.Width, bounds.Height);
Rectangle[] lhsScans = lhs.GetRegionScansReadOnlyInt();
Rectangle[] rhsScans = rhs.GetRegionScansReadOnlyInt();
switch (combineMode)
{
case CombineMode.Complement:
case CombineMode.Intersect:
case CombineMode.Replace:
throw new ArgumentException("combineMode can't be Complement, Intersect, or Replace");
default:
break;
}
for (int i = 0; i < lhsScans.Length; ++i)
{
Rectangle rect = lhsScans[i];
rect.X -= bounds.X;
rect.Y -= bounds.Y;
stencil.SetUnchecked(rect, true);
}
for (int i = 0; i < rhsScans.Length; ++i)
{
Rectangle rect = rhsScans[i];
rect.X -= bounds.X;
rect.Y -= bounds.Y;
switch (combineMode)
{
case CombineMode.Xor:
stencil.InvertUnchecked(rect);
break;
case CombineMode.Union:
stencil.SetUnchecked(rect, true);
break;
case CombineMode.Exclude:
stencil.SetUnchecked(rect, false);
break;
}
}
PdnGraphicsPath path = PathFromStencil(stencil, new Rectangle(0, 0, stencil.Width, stencil.Height));
using (Matrix matrix = new Matrix())
{
matrix.Reset();
matrix.Translate(bounds.X, bounds.Y);
path.Transform(matrix);
}
return path;
}
示例5: Render
/// <summary>
/// Causes the layer to render a given region of interest (roi) to the given destination surface.
/// </summary>
/// <param name="args">Contains information about which objects to use for rendering</param>
/// <param name="roi">The region to be rendered.</param>
public void Render(RenderArgs args, PdnRegion roi)
{
Rectangle roiBounds = roi.GetBoundsInt();
if (!IsInBounds(roiBounds))
{
throw new ArgumentOutOfRangeException("roi");
}
Rectangle[] rects = roi.GetRegionScansReadOnlyInt();
RenderImpl(args, rects);
}