本文整理汇总了C#中Surface.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# Surface.Clear方法的具体用法?C# Surface.Clear怎么用?C# Surface.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Surface
的用法示例。
在下文中一共展示了Surface.Clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateThumbnail
public static Surface CreateThumbnail(Surface sourceSurface, PdnGraphicsPath maskPath, Rectangle bounds, int thumbSideLength)
{
Size thumbSize = Utility.ComputeThumbnailSize(bounds.Size, thumbSideLength);
Surface thumb = new Surface(Math.Max(5, thumbSize.Width + 4), Math.Max(5, thumbSize.Height + 4));
thumb.Clear(ColorBgra.Transparent);
thumb.Clear(new Rectangle(1, 1, thumb.Width - 2, thumb.Height - 2), ColorBgra.Black);
Rectangle insetRect = new Rectangle(2, 2, thumb.Width - 4, thumb.Height - 4);
Surface thumbInset = thumb.CreateWindow(insetRect);
thumbInset.Clear(ColorBgra.Transparent);
float scaleX = (float)thumbInset.Width / (float)bounds.Width;
float scaleY = (float)thumbInset.Height / (float)bounds.Height;
Matrix scaleMatrix = new Matrix();
scaleMatrix.Translate(-bounds.X, -bounds.Y, System.Drawing.Drawing2D.MatrixOrder.Append);
scaleMatrix.Scale(scaleX, scaleY, System.Drawing.Drawing2D.MatrixOrder.Append);
thumbInset.SuperSamplingFitSurface(sourceSurface);
Surface maskInset = new Surface(thumbInset.Size);
maskInset.Clear(ColorBgra.Black);
using (RenderArgs maskInsetRA = new RenderArgs(maskInset))
{
maskInsetRA.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
maskInsetRA.Graphics.Transform = scaleMatrix;
maskInsetRA.Graphics.FillPath(Brushes.White, maskPath);
maskInsetRA.Graphics.DrawPath(Pens.White, maskPath);
}
scaleMatrix.Dispose();
scaleMatrix = null;
IntensityMaskOp maskOp = new IntensityMaskOp();
maskOp.Apply(maskInset, thumbInset, maskInset);
UserBlendOps.NormalBlendOp normalOp = new UserBlendOps.NormalBlendOp();
thumbInset.ClearWithCheckboardPattern();
normalOp.Apply(thumbInset, thumbInset, maskInset);
maskInset.Dispose();
maskInset = null;
thumbInset.Dispose();
thumbInset = null;
using (RenderArgs thumbRA = new RenderArgs(thumb))
{
Utility.DrawDropShadow1px(thumbRA.Graphics, thumb.Bounds);
}
return thumb;
}
示例2: RenderCircleBrush
private RenderArgs RenderCircleBrush()
{
// create pen mask surface
Surface brushSurface = new Surface(ceilingPenWidth, ceilingPenWidth);
brushSurface.Clear((ColorBgra)0);
RenderArgs brush = new RenderArgs(brushSurface);
if (AppEnvironment.AntiAliasing)
{
brush.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
}
else
{
brush.Graphics.SmoothingMode = SmoothingMode.None;
}
if (AppEnvironment.AntiAliasing)
{
if (penWidth > 2)
{
penWidth = penWidth - 1.0f;
}
else
{
penWidth = penWidth / 2;
}
}
else
{
if (penWidth <= 1.0f)
{
brush.Surface[1, 1] = ColorBgra.Black;
}
else
{
penWidth = (float)Math.Round(penWidth + 1.0f);
}
}
using (Brush testBrush = new SolidBrush(System.Drawing.Color.Black))
{
brush.Graphics.FillEllipse(testBrush, 0.0f, 0.0f, penWidth, penWidth);
}
return brush;
}
示例3: ResizeLayer
private static BitmapLayer ResizeLayer(BitmapLayer layer, int width, int height, ResamplingAlgorithm algorithm,
int tileCount, Procedure progressCallback, ref bool pleaseStopMonitor)
{
Surface surface = new Surface(width, height);
surface.Clear(ColorBgra.FromBgra(255, 255, 255, 0));
PaintDotNet.Threading.ThreadPool threadPool = new PaintDotNet.Threading.ThreadPool();
int rectCount;
if (tileCount == 0)
{
rectCount = Processor.LogicalCpuCount;
}
else
{
rectCount = tileCount;
}
Rectangle[] rects = new Rectangle[rectCount];
Utility.SplitRectangle(surface.Bounds, rects);
FitSurfaceContext fsc = new FitSurfaceContext(surface, layer.Surface, rects, algorithm);
if (progressCallback != null)
{
fsc.RenderedRect += progressCallback;
}
WaitCallback callback = new WaitCallback(fsc.FitSurface);
for (int i = 0; i < rects.Length; ++i)
{
if (pleaseStopMonitor)
{
break;
}
else
{
threadPool.QueueUserWorkItem(callback, BoxedConstants.GetInt32(i));
}
}
threadPool.Drain();
threadPool.DrainExceptions();
if (pleaseStopMonitor)
{
surface.Dispose();
surface = null;
}
BitmapLayer newLayer;
if (surface == null)
{
newLayer = null;
}
else
{
newLayer = new BitmapLayer(surface, true);
newLayer.LoadProperties(layer.SaveProperties());
}
if (progressCallback != null)
{
fsc.RenderedRect -= progressCallback;
}
return newLayer;
}