VintaSoft Imaging .NET SDK 14.0: Документация для .NET разработчика
Vintasoft.Imaging.Drawing.SkiaSharp Namespace / SkiaSharpDrawingEngine Class
Члены типа Объект Синтаксис Example Иерархия Требования Смотрите также
В этом разделе
    Класс SkiaSharpDrawingEngine
    В этом разделе
    Предоставляет движок 2D-растровой отрисовки, основанный на движке SkiaSharp.
    Объектная модель
    AffineMatrix IRegion DrawingFactory VintasoftImage PixelManipulator Resolution SkiaSharpDrawingEngine
    Синтаксис
    'Declaration
    
    Public NotInheritable Class SkiaSharpDrawingEngine
       Inherits Vintasoft.Imaging.Drawing.RasterDrawingEngine
    
    
    public sealed class SkiaSharpDrawingEngine : Vintasoft.Imaging.Drawing.RasterDrawingEngine
    
    
    public __gc __sealed class SkiaSharpDrawingEngine : public Vintasoft.Imaging.Drawing.RasterDrawingEngine*
    
    
    public ref class SkiaSharpDrawingEngine sealed : public Vintasoft.Imaging.Drawing.RasterDrawingEngine^
    
    
    Пример

    Вот C#/VB.NET код, который демонстрирует, как создать и использовать движок рисования SkiaSharp для рисования различных графических объектов, таких как фигуры и текст.

    
    Imports System.Drawing
    
    Imports Vintasoft.Imaging
    Imports Vintasoft.Imaging.Drawing
    Imports Vintasoft.Imaging.Drawing.SkiaSharp
    
    Class SkiaSharpDrawingEngineExample
        ''' <summary>
        ''' Creates SkiaSharp drawing engine on specified image and performs drawing.
        ''' </summary>
        Public Shared Sub DrawWithSkiaSharpDrawingEngine(image As VintasoftImage)
            ' create drawing engine for image
            Using drawingEngine As New SkiaSharpDrawingEngine(image)
                ' create drawing area
                Dim drawingArea As New RectangleF(0, 0, image.Width, image.Height)
                ' draw objects in area
                DrawingExample(drawingEngine, drawingArea)
            End Using
        End Sub
    
        ''' <summary>
        ''' Draws graphic objects using specified drawing engine.
        ''' </summary>
        ''' <param name="drawingEngine">Drawing engine.</param>
        ''' <param name="drawingArea">Image area to draw objects in.</param>
        Public Shared Sub DrawingExample(drawingEngine As DrawingEngine, drawingArea As RectangleF)
            ' create bounding rectangle for ellipse
            Dim ellipseRect As New RectangleF(drawingArea.X + drawingArea.Width * 0.3F, drawingArea.Y + drawingArea.Height * 0.3F, drawingArea.Width * 0.4F, drawingArea.Height * 0.4F)
    
            ' create brush and pen to draw ellipse
            Using brush As IDrawingSolidBrush = drawingEngine.DrawingFactory.CreateSolidBrush(Color.Blue)
                Using pen As IDrawingPen = drawingEngine.DrawingFactory.CreatePen(Color.Red, 4F)
                    ' fill ellipse
                    drawingEngine.FillEllipse(brush, ellipseRect)
                    ' stroke ellipse
                    drawingEngine.DrawEllipse(pen, ellipseRect)
                End Using
            End Using
    
            ' create brush and font to draw text
            Using textBrush As IDrawingSolidBrush = drawingEngine.DrawingFactory.CreateSolidBrush(Color.Yellow)
                Using font As IDrawingFont = drawingEngine.DrawingFactory.CreateFont("Arial", 30, True, False)
                    ' create properties to layout text
                    Dim layoutProperties As New TextLayoutProperties(AnchorType.Center)
                    ' draw text
                    drawingEngine.DrawText("Text", font, textBrush, ellipseRect, layoutProperties)
                End Using
            End Using
        End Sub
    End Class
    
    
    
    using System.Drawing;
    
    using Vintasoft.Imaging;
    using Vintasoft.Imaging.Drawing;
    using Vintasoft.Imaging.Drawing.SkiaSharp;
    
    namespace CSHARP
    {
        class SkiaSharpDrawingEngineExample
        {
            /// <summary>
            /// Creates SkiaSharp drawing engine on specified image and performs drawing.
            /// </summary>
            public static void DrawWithSkiaSharpDrawingEngine(VintasoftImage image)
            {
                // create drawing engine for image
                using (SkiaSharpDrawingEngine drawingEngine = new SkiaSharpDrawingEngine(image))
                {
                    // create drawing area
                    RectangleF drawingArea = new RectangleF(0, 0, image.Width, image.Height);
                    // draw objects in area
                    DrawingExample(drawingEngine, drawingArea);
                }
            }
    
            /// <summary>
            /// Draws graphic objects using specified drawing engine.
            /// </summary>
            /// <param name="drawingEngine">Drawing engine.</param>
            /// <param name="drawingArea">Image area to draw objects in.</param>
            public static void DrawingExample(DrawingEngine drawingEngine, RectangleF drawingArea)
            {
                // create bounding rectangle for ellipse
                RectangleF ellipseRect = new RectangleF(
                    drawingArea.X + drawingArea.Width * 0.3f,
                    drawingArea.Y + drawingArea.Height * 0.3f,
                    drawingArea.Width * 0.4f,
                    drawingArea.Height * 0.4f);
    
                // create brush and pen to draw ellipse
                using (IDrawingSolidBrush brush = drawingEngine.DrawingFactory.CreateSolidBrush(Color.Blue))
                {
                    using (IDrawingPen pen = drawingEngine.DrawingFactory.CreatePen(Color.Red, 4f))
                    {
                        // fill ellipse
                        drawingEngine.FillEllipse(brush, ellipseRect);
                        // stroke ellipse
                        drawingEngine.DrawEllipse(pen, ellipseRect);
                    }
                }
    
                // create brush and font to draw text
                using (IDrawingSolidBrush textBrush = drawingEngine.DrawingFactory.CreateSolidBrush(Color.Yellow))
                {
                    using (IDrawingFont font = drawingEngine.DrawingFactory.CreateFont("Arial", 30, true, false))
                    {
                        // create properties to layout text
                        TextLayoutProperties layoutProperties = new TextLayoutProperties(AnchorType.Center);
                        // draw text
                        drawingEngine.DrawText("Text", font, textBrush, ellipseRect, layoutProperties);
                    }
                }
            }
        }
    }
    
    

    Иерархия наследования

    System.Object
       Vintasoft.Imaging.Drawing.DrawingEngine
          Vintasoft.Imaging.Drawing.RasterDrawingEngine
             Vintasoft.Imaging.Drawing.SkiaSharp.SkiaSharpDrawingEngine

    Требования

    Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    Смотрите также