GraphicsPath.Warp Method

Definition

Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath.

Overloads

Warp(PointF[], RectangleF)

Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath.

Warp(PointF[], RectangleF, Matrix)

Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath.

Warp(PointF[], RectangleF, Matrix, WarpMode)

Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath.

Warp(PointF[], RectangleF, Matrix, WarpMode, Single)

Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath.

Warp(ReadOnlySpan<PointF>, RectangleF, Matrix, WarpMode, Single)

Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath.

Warp(PointF[], RectangleF)

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs

Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath.

C#
public void Warp(System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect);

Parameters

destPoints
PointF[]

An array of PointF structures that define a parallelogram to which the rectangle defined by srcRect is transformed. The array can contain either three or four elements. If the array contains three elements, the lower-right corner of the parallelogram is implied by the first three points.

srcRect
RectangleF

A RectangleF that represents the rectangle that is transformed to the parallelogram defined by destPoints.

Examples

For an example, see Warp(PointF[], RectangleF, Matrix, WarpMode, Single).

Applies to

.NET 10 (package-provided) i druge verzije
Proizvod Verzije
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Warp(PointF[], RectangleF, Matrix)

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs

Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath.

C#
public void Warp(System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix? matrix);
C#
public void Warp(System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix matrix);

Parameters

destPoints
PointF[]

An array of PointF structures that define a parallelogram to which the rectangle defined by srcRect is transformed. The array can contain either three or four elements. If the array contains three elements, the lower-right corner of the parallelogram is implied by the first three points.

srcRect
RectangleF

A RectangleF that represents the rectangle that is transformed to the parallelogram defined by destPoints.

matrix
Matrix

A Matrix that specifies a geometric transform to apply to the path.

Examples

For an example, see Warp(PointF[], RectangleF, Matrix, WarpMode, Single).

Applies to

.NET 10 (package-provided) i druge verzije
Proizvod Verzije
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Warp(PointF[], RectangleF, Matrix, WarpMode)

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs

Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath.

C#
public void Warp(System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix? matrix, System.Drawing.Drawing2D.WarpMode warpMode);
C#
public void Warp(System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix matrix, System.Drawing.Drawing2D.WarpMode warpMode);

Parameters

destPoints
PointF[]

An array of PointF structures that defines a parallelogram to which the rectangle defined by srcRect is transformed. The array can contain either three or four elements. If the array contains three elements, the lower-right corner of the parallelogram is implied by the first three points.

srcRect
RectangleF

A RectangleF that represents the rectangle that is transformed to the parallelogram defined by destPoints.

matrix
Matrix

A Matrix that specifies a geometric transform to apply to the path.

warpMode
WarpMode

A WarpMode enumeration that specifies whether this warp operation uses perspective or bilinear mode.

Examples

For an example, see Warp(PointF[], RectangleF, Matrix, WarpMode, Single).

Applies to

.NET 10 (package-provided) i druge verzije
Proizvod Verzije
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Warp(PointF[], RectangleF, Matrix, WarpMode, Single)

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs

Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath.

C#
public void Warp(System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix? matrix, System.Drawing.Drawing2D.WarpMode warpMode, float flatness);
C#
public void Warp(System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix matrix, System.Drawing.Drawing2D.WarpMode warpMode, float flatness);

Parameters

destPoints
PointF[]

An array of PointF structures that define a parallelogram to which the rectangle defined by srcRect is transformed. The array can contain either three or four elements. If the array contains three elements, the lower-right corner of the parallelogram is implied by the first three points.

srcRect
RectangleF

A RectangleF that represents the rectangle that is transformed to the parallelogram defined by destPoints.

matrix
Matrix

A Matrix that specifies a geometric transform to apply to the path.

warpMode
WarpMode

A WarpMode enumeration that specifies whether this warp operation uses perspective or bilinear mode.

flatness
Single

A value from 0 through 1 that specifies how flat the resulting path is. For more information, see the Flatten() methods.

Examples

The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, an OnPaint event object. The code performs the following actions:

  • Creates a path and adds a rectangle to the path.

  • Draws that rectangle to the screen in black.

  • Warps the path with a perspective warp.

  • Draws the warped rectangle (path) to the screen in red.

C#
private void WarpExample(PaintEventArgs e)
{
             
    // Create a path and add a rectangle.
    GraphicsPath myPath = new GraphicsPath();
    RectangleF srcRect = new RectangleF(0, 0, 100, 200);
    myPath.AddRectangle(srcRect);
             
    // Draw the source path (rectangle)to the screen.
    e.Graphics.DrawPath(Pens.Black, myPath);
             
    // Create a destination for the warped rectangle.
    PointF point1 = new PointF(200, 200);
    PointF point2 = new PointF(400, 250);
    PointF point3 = new PointF(220, 400);
    PointF[] destPoints = {point1, point2, point3};
             
    // Create a translation matrix.
    Matrix translateMatrix = new Matrix();
    translateMatrix.Translate(100, 0);
             
    // Warp the source path (rectangle).
    myPath.Warp(destPoints, srcRect, translateMatrix,
        WarpMode.Perspective, 0.5f);
             
    // Draw the warped path (rectangle) to the screen.
    e.Graphics.DrawPath(new Pen(Color.Red), myPath);
}

Applies to

.NET 10 (package-provided) i druge verzije
Proizvod Verzije
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Warp(ReadOnlySpan<PointF>, RectangleF, Matrix, WarpMode, Single)

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs

Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath.

C#
public void Warp(ReadOnlySpan<System.Drawing.PointF> destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix? matrix = default, System.Drawing.Drawing2D.WarpMode warpMode = System.Drawing.Drawing2D.WarpMode.Perspective, float flatness = 0.25);

Parameters

destPoints
ReadOnlySpan<PointF>

An array of points that define a parallelogram to which the rectangle defined by srcRect is transformed.

srcRect
RectangleF

A rectangle that represents the rectangle that is transformed to the parallelogram defined by destPoints.

matrix
Matrix

A matrix that specifies a geometric transform to apply to the path.

warpMode
WarpMode

Specifies whether this warp operation uses perspective or bilinear mode.

flatness
Single

A value from 0 through 1 that specifies how flat the resulting path is. For more information, see the Flatten(Matrix, Single) methods.

Remarks

For destPoints, the array can contain either three or four elements. If the array contains three elements, the lower-right corner of the parallelogram is implied by the first three points.

Applies to

.NET 10 (package-provided) i druge verzije
Proizvod Verzije
.NET 9 (package-provided), 10 (package-provided)
Windows Desktop 9, 10