public static Surface CreateThumbnail(Surface sourceSurface, GeometryList maskGeometry, RectInt32 maskBounds, int thumbSideLength) { Surface dst = new Surface(ThumbnailHelpers.ComputeThumbnailSize(sourceSurface.Size <ColorBgra>(), thumbSideLength)); dst.Clear(ColorBgra.Transparent); sourceSurface.ResizeFant(dst.Size <ColorBgra>()).Parallelize <ColorBgra>(TilingStrategy.HorizontalSlices, 5, WorkItemQueuePriority.Normal).Render <ColorBgra>(dst); Surface surface = new Surface(dst.Size <ColorBgra>()); surface.Clear(ColorBgra.Black); using (PdnGraphicsPath path = new PdnGraphicsPath()) { path.AddGeometryList(maskGeometry); double scaleX = (maskBounds.Width == 0) ? 0.0 : (((double)dst.Width) / ((double)maskBounds.Width)); double scaleY = (maskBounds.Height == 0) ? 0.0 : (((double)dst.Height) / ((double)maskBounds.Height)); Matrix3x2Double m = Matrix3x2Double.Translation((double)-maskBounds.X, (double)-maskBounds.Y) * Matrix3x2Double.Scaling(scaleX, scaleY); using (RenderArgs args = new RenderArgs(surface)) { args.Graphics.SmoothingMode = SmoothingMode.AntiAlias; using (Matrix matrix = m.ToGdipMatrix()) { args.Graphics.Transform = matrix; } args.Graphics.FillPath(Brushes.White, (GraphicsPath)path); args.Graphics.DrawPath(Pens.White, (GraphicsPath)path); } } new IntensityMaskOp().Apply(surface, dst, surface); RendererBgra.Checkers(dst.Size <ColorBgra>()).Render <ColorBgra>(dst); CompositionOps.Normal.Static.Apply(dst, dst, surface); surface.Dispose(); surface = null; int recommendedExtent = DropShadow.GetRecommendedExtent(dst.Size <ColorBgra>()); ShadowDecorationRenderer renderer = new ShadowDecorationRenderer(dst, recommendedExtent); Surface surface3 = new Surface(renderer.Size <ColorBgra>()); renderer.Render <ColorBgra>(surface3); return(surface3); }