BlendPath(DrawingSurface,GraphicsPathColorBlending[]) Метод (DrawingEngine)
В этом разделе
Смешивает путь, используя свойства смешивания цветов для графического пути.
Синтаксис
Parameters
- drawingSurface
- Поверхность рисования.
- pathColorBlendings
- Свойства смешивания цветов для графического контура.
Пример
Вот пример, показывающий, как смешать контур с помощью механизма рисования.
''' <summary>
''' Draws an image, overlayed with path, using color blending on specified drawing engine.
''' </summary>
''' <param name="drawingEngine">Drawing engine.</param>
''' <param name="area">Area to draw objects in.</param>
Public Shared Sub ColorBlendingExample(drawingEngine As DrawingEngine, area As RectangleF)
' create graphics path
Using path As IGraphicsPath = drawingEngine.DrawingFactory.CreateGraphicsPath()
Dim pathPoints As PointF() = New PointF() {New PointF(area.X, area.Y + area.Height * 0.6F), New PointF(area.X + area.Width * 0.6F, area.Y), New PointF(area.X + area.Width, area.Y + area.Height * 0.8F)}
' add path elements
path.AddLines(pathPoints)
path.CloseFigure()
' path to image file for drawing
' this image is located in <install path>/VintaSoft/Imaging .NET/Images/
Dim imagePath As String = "AutoContrast.jpg"
' set image destination rectangle
Dim imageRect As New RectangleF(area.X + area.Width * 0.2F, area.Y + area.Height * 0.2F, area.Width * 0.6F, area.Height * 0.6F)
' create VintaSoft image and draw it
Using image As New VintasoftImage(imagePath)
drawingEngine.DrawImage(image, imageRect)
End Using
Dim drawingSurface As DrawingSurface = Nothing
' if drawing engine is raster engine
If TypeOf drawingEngine Is RasterDrawingEngine Then
' get drawing surface from canvas
drawingSurface = New ImageDrawingSurface(DirectCast(drawingEngine, RasterDrawingEngine).Canvas)
End If
' if drawing surface created
If drawingSurface IsNot Nothing Then
' create path blending
Using blending As New GraphicsPathColorBlending(path, BlendingMode.Difference, Color.White)
' execute blending
drawingEngine.BlendPath(drawingSurface, blending)
End Using
End If
End Using
End Sub
/// <summary>
/// Draws an image, overlayed with path, using color blending on specified drawing engine.
/// </summary>
/// <param name="drawingEngine">Drawing engine.</param>
/// <param name="area">Area to draw objects in.</param>
public static void ColorBlendingExample(DrawingEngine drawingEngine, RectangleF area)
{
// create graphics path
using (IGraphicsPath path = drawingEngine.DrawingFactory.CreateGraphicsPath())
{
PointF[] pathPoints = new PointF[]
{
new PointF(area.X, area.Y + area.Height * 0.6f),
new PointF(area.X + area.Width * 0.6f, area.Y),
new PointF(area.X + area.Width, area.Y + area.Height * 0.8f),
};
// add path elements
path.AddLines(pathPoints);
path.CloseFigure();
// path to image file for drawing
// this image is located in <install path>/VintaSoft/Imaging .NET/Images/
string imagePath = "AutoContrast.jpg";
// set image destination rectangle
RectangleF imageRect = new RectangleF(area.X + area.Width * 0.2f, area.Y + area.Height * 0.2f, area.Width * 0.6f, area.Height * 0.6f);
// create VintaSoft image and draw it
using (VintasoftImage image = new VintasoftImage(imagePath))
drawingEngine.DrawImage(image, imageRect);
DrawingSurface drawingSurface = null;
// if drawing engine is raster engine
if (drawingEngine is RasterDrawingEngine)
{
// get drawing surface from canvas
drawingSurface = new ImageDrawingSurface(((RasterDrawingEngine)drawingEngine).Canvas);
}
// if drawing surface created
if (drawingSurface != null)
{
// create path blending
using (GraphicsPathColorBlending blending = new GraphicsPathColorBlending(path, BlendingMode.Difference, Color.White))
{
// execute blending
drawingEngine.BlendPath(drawingSurface, blending);
}
}
}
}
Требования
Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5
Смотрите также