本文整理汇总了C#中Surface.CreateWindow方法的典型用法代码示例。如果您正苦于以下问题:C# Surface.CreateWindow方法的具体用法?C# Surface.CreateWindow怎么用?C# Surface.CreateWindow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Surface
的用法示例。
在下文中一共展示了Surface.CreateWindow方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}