本文整理汇总了C#中PaintDotNet.PdnRegion类的典型用法代码示例。如果您正苦于以下问题:C# PdnRegion类的具体用法?C# PdnRegion怎么用?C# PdnRegion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PdnRegion类属于PaintDotNet命名空间,在下文中一共展示了PdnRegion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EffectConfigDialog
public EffectConfigDialog()
{
InitializeComponent();
InitialInitToken();
effectSelection = new PdnRegion();
effectSelection.MakeInfinite();
}
示例2: GetRegionCache
internal PdnRegion GetRegionCache()
{
if (regionCache == null)
{
regionCache = new PdnRegion(this.gdiPath);
}
return regionCache;
}
示例3: 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;
}
示例4: DrawGradient
//.........这里部分代码省略.........
int rd = ((rp * ap) + (src.R * (255 - ap))) / 255;
int gd = ((gp * ap) + (src.G * (255 - ap))) / 255;
int bd = ((bp * ap) + (src.B * (255 - ap))) / 255;
// TODO: proper alpha blending!
gradientSurface[x, y] = ColorBgra.FromBgra((byte)bd, (byte)gd, (byte)rd, 255);
}
}
g.DrawImage(ra.Bitmap, gradientRect, ra.Bounds, GraphicsUnit.Pixel);
}
else if (Orientation == Orientation.Vertical)
{
// TODO
}
else
{
throw new InvalidEnumArgumentException();
}
}
gradientSurface.Dispose();
}
else
{
using (LinearGradientBrush lgb = new LinearGradientBrush(this.ClientRectangle,
maxColor, minColor, gradientAngle, false))
{
g.FillRectangle(lgb, gradientRect);
}
}
// fill background
using (PdnRegion nonGradientRegion = new PdnRegion())
{
nonGradientRegion.MakeInfinite();
nonGradientRegion.Exclude(gradientRect);
using (SolidBrush sb = new SolidBrush(this.BackColor))
{
g.FillRegion(sb, nonGradientRegion.GetRegionReadOnly());
}
}
// draw value triangles
for (int i = 0; i < this.vals.Length; i++)
{
int pos = ValueToPosition(vals[i]);
Brush brush;
Pen pen;
if (i == highlight)
{
brush = Brushes.Blue;
pen = (Pen)Pens.White.Clone();
}
else
{
brush = Brushes.Black;
pen = (Pen)Pens.Gray.Clone();
}
g.SmoothingMode = SmoothingMode.AntiAlias;
Point a1;
Point b1;
示例5: OnDeserialization
public void OnDeserialization(object sender)
{
region = PdnRegion.CreateEmpty();
Rectangle[] rects = new Rectangle[placedSurfaces.Count];
for (int i = 0; i < placedSurfaces.Count; ++i)
{
rects[i] = ((PlacedSurface)placedSurfaces[i]).Bounds;
}
region = Utility.RectanglesToRegion(rects);
}
示例6: UpdateHistogram
public void UpdateHistogram(Surface surface, PdnRegion roi)
{
Clear();
foreach (Rectangle rect in roi.GetRegionScansReadOnlyInt())
{
AddSurfaceRectangleToHistogram(surface, rect);
}
OnHistogramUpdated();
}
示例7: Invert
public void Invert(PdnRegion region)
{
foreach (Rectangle rect in region.GetRegionScansReadOnlyInt())
{
Invert(rect);
}
}
示例8: 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));
}
示例9: GetRegion
private PdnRegion GetRegion()
{
if (this.region == null)
{
this.region = new PdnRegion(this.shadowPath);
}
return this.region;
}
示例10: Draw
public unsafe void Draw(Surface dst, Matrix transform, ResamplingAlgorithm sampling)
{
if (this.disposed)
{
throw new ObjectDisposedException("MaskedSurface");
}
if (this.surface == null || !transform.IsInvertible)
{
return;
}
PdnRegion theRegion;
Rectangle regionBounds;
if (this.path == null)
{
theRegion = this.region.Clone();
regionBounds = this.region.GetBoundsInt();
theRegion.Transform(transform);
}
else
{
using (PdnGraphicsPath mPath = this.shadowPath.Clone())
{
regionBounds = Rectangle.Truncate(mPath.GetBounds());
mPath.Transform(transform);
theRegion = new PdnRegion(mPath);
}
}
DrawContext dc = new DrawContext();
dc.boundsX = regionBounds.X;
dc.boundsY = regionBounds.Y;
Matrix inverse = transform.Clone();
inverse.Invert();
dc.inverses = new Matrix[Processor.LogicalCpuCount];
for (int i = 0; i < dc.inverses.Length; ++i)
{
dc.inverses[i] = inverse.Clone();
}
// change in source-[X|Y] w.r.t. destination-[X|Y]
PointF[] pts = new PointF[] {
new PointF(1, 0),
new PointF(0, 1)
};
inverse.TransformVectors(pts);
inverse.Dispose();
inverse = null;
dc.dsxddx = pts[0].X;
if (Math.Abs(dc.dsxddx) > fp_MaxValue)
{
dc.dsxddx = 0.0f;
}
dc.dsyddx = pts[0].Y;
if (Math.Abs(dc.dsyddx) > fp_MaxValue)
{
dc.dsyddx = 0.0f;
}
dc.dsxddy = pts[1].X;
if (Math.Abs(dc.dsxddy) > fp_MaxValue)
{
dc.dsxddy = 0.0f;
}
dc.dsyddy = pts[1].Y;
if (Math.Abs(dc.dsyddy) > fp_MaxValue)
{
dc.dsyddy = 0.0f;
}
dc.fp_dsxddx = (int)(dc.dsxddx * fp_MultFactor);
dc.fp_dsyddx = (int)(dc.dsyddx * fp_MultFactor);
dc.fp_dsxddy = (int)(dc.dsxddy * fp_MultFactor);
dc.fp_dsyddy = (int)(dc.dsyddy * fp_MultFactor);
dc.dst = dst;
dc.src = this.surface;
Rectangle[] scans = theRegion.GetRegionScansReadOnlyInt();
if (scans.Length == 1)
{
dc.dstScans = new Rectangle[Processor.LogicalCpuCount];
Utility.SplitRectangle(scans[0], dc.dstScans);
}
else
{
dc.dstScans = scans;
//.........这里部分代码省略.........
示例11: Main
//.........这里部分代码省略.........
benchmarks.Add(new CompositionBenchmark("Compositing three layers, Normal+Multiply+Overlay blending, 150+255+170 opacity (" + CompositionBenchmark.Iterations + "x)", doc1, surface,
delegate(int layerIndex, Layer layer)
{
if (layerIndex == 0)
{
layer.Visible = true;
layer.Opacity = 150;
((BitmapLayer)layer).SetBlendOp(new UserBlendOps.NormalBlendOp());
}
else if (layerIndex == 1)
{
layer.Visible = true;
layer.Opacity = 255;
((BitmapLayer)layer).SetBlendOp(new UserBlendOps.MultiplyBlendOp());
}
else if (layerIndex == 2)
{
layer.Visible = true;
layer.Opacity = 170;
((BitmapLayer)layer).SetBlendOp(new UserBlendOps.OverlayBlendOp());
}
else
{
layer.Visible = false;
}
}));
#endif
#if TRANSFORM
// Transform benchmarks
Matrix m = new Matrix();
m.Reset();
MaskedSurface msSimple = new MaskedSurface(surface, new PdnRegion(surface.Bounds)); // simple masked surface
PdnRegion complexRegion = new PdnRegion(surface.Bounds);
// cut 4 holes in region 1 to form a complex clipping surface
for (int x = -1; x < 3; ++x)
{
for (int y = -1; y < 3; ++y)
{
int left = (1 + (x * 3)) * (surface.Width / 6);
int top = (1 + (x * 3)) * (surface.Height / 6);
int right = (2 + (x * 3)) * (surface.Width / 6);
int bottom = (2 + (x * 3)) * (surface.Height / 6);
Rectangle rect = Rectangle.FromLTRB(left, top, right, bottom);
PdnGraphicsPath path = new PdnGraphicsPath();
path.AddEllipse(rect);
complexRegion.Exclude(path);
}
}
MaskedSurface msComplex = new MaskedSurface(surface, complexRegion);
benchmarks.Add(new TransformBenchmark("Transform simple surface, no transform, nearest neighbor resampling (" + TransformBenchmark.Iterations + "x)",
surface,
msSimple,
m,
false));
benchmarks.Add(new TransformBenchmark("Transform complex surface, no transform, nearest neighbor resampling (" + TransformBenchmark.Iterations + "x)",
surface,
msSimple,
m,
示例12: CreatePixelatedPath
public PdnGraphicsPath CreatePixelatedPath()
{
using (PdnGraphicsPath path = CreatePath())
//PdnGraphicsPath path = GetPathReadOnly();
{
using (PdnRegion region = new PdnRegion(path))
{
PdnGraphicsPath pixellatedPath = PdnGraphicsPath.FromRegion(region);
return pixellatedPath;
}
}
}
示例13: Set
public void Set(PdnRegion region, bool newValue)
{
foreach (Rectangle rect in region.GetRegionScansReadOnlyInt())
{
Set(rect, newValue);
}
}
示例14: RenderedTileEventArgs
public RenderedTileEventArgs(PdnRegion renderedRegion, int tileCount, int tileNumber)
{
this.renderedRegion = renderedRegion;
this.tileCount = tileCount;
this.tileNumber = tileNumber;
}
示例15: Changed
private void Changed()
{
if (regionCache != null)
{
lock (regionCache.SyncRoot)
{
regionCache.Dispose();
regionCache = null;
}
}
}