ImageAttributes.SetWrapMode Method

Definition

Sets the wrap mode.

Overloads

SetWrapMode(WrapMode)

Sets the wrap mode that is used to decide how to tile a texture across a shape, or at shape boundaries. A texture is tiled across a shape to fill it in when the texture is smaller than the shape it is filling.

SetWrapMode(WrapMode, Color)

Sets the wrap mode and color used to decide how to tile a texture across a shape, or at shape boundaries. A texture is tiled across a shape to fill it in when the texture is smaller than the shape it is filling.

SetWrapMode(WrapMode, Color, Boolean)

Sets the wrap mode and color used to decide how to tile a texture across a shape, or at shape boundaries. A texture is tiled across a shape to fill it in when the texture is smaller than the shape it is filling.

SetWrapMode(WrapMode)

Source:
ImageAttributes.cs
Source:
ImageAttributes.cs
Source:
ImageAttributes.cs
Source:
ImageAttributes.cs
Source:
ImageAttributes.cs
Source:
ImageAttributes.cs

Sets the wrap mode that is used to decide how to tile a texture across a shape, or at shape boundaries. A texture is tiled across a shape to fill it in when the texture is smaller than the shape it is filling.

C#
public void SetWrapMode(System.Drawing.Drawing2D.WrapMode mode);

Parameters

mode
WrapMode

An element of WrapMode that specifies how repeated copies of an image are used to tile an area.

Examples

The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following actions:

  1. Opens an Image from the Circle3.jpg file (a small, red-filled circle) and draws it to the screen.

  2. Creates an ImageAttributes object and sets the WrapMode enumeration to Tile.

  3. Creates a TextureBrush using the image from the Circle3.jpg file.

  4. Draws a rectangle to the screen that is filled with the small, red-filled circles.

C#
private void SetWrapModeExample(PaintEventArgs e)
{
             
    // Create a filled, red circle, and save it to Circle3.jpg.
    Bitmap myBitmap = new Bitmap(50, 50);
    Graphics g = Graphics.FromImage(myBitmap);
    g.Clear(Color.White);
    g.FillEllipse(new SolidBrush(Color.Red),
        new Rectangle(0, 0, 25, 25));
    myBitmap.Save("Circle3.jpg");
             
    // Create an Image object from the Circle3.jpg file, and draw it
    // to the screen.
    Image myImage = Image.FromFile("Circle3.jpg");
    e.Graphics.DrawImage(myImage, 20, 20);
             
    // Set the wrap mode.
    ImageAttributes imageAttr = new ImageAttributes();
    imageAttr.SetWrapMode(WrapMode.Tile);
             
    // Create a TextureBrush.
    Rectangle brushRect = new Rectangle(0,0,25,25);
    TextureBrush myTBrush = new TextureBrush(myImage, brushRect, imageAttr);
             
    // Draw to the screen a rectangle filled with red circles.
    e.Graphics.FillRectangle(myTBrush, 100, 20, 200, 200);
}

Remarks

Calling the SetWrapMode(WrapMode) method is equivalent to calling SetWrapMode(WrapMode, Color) and passing Color.Black for the color parameter. Color.Black specifies the color of pixels outside of a rendered image. This color is visible if the mode parameter is set to Clamp and the source rectangle passed to the DrawImage method is larger than the image itself.

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.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

SetWrapMode(WrapMode, Color)

Source:
ImageAttributes.cs
Source:
ImageAttributes.cs
Source:
ImageAttributes.cs
Source:
ImageAttributes.cs
Source:
ImageAttributes.cs
Source:
ImageAttributes.cs

Sets the wrap mode and color used to decide how to tile a texture across a shape, or at shape boundaries. A texture is tiled across a shape to fill it in when the texture is smaller than the shape it is filling.

C#
public void SetWrapMode(System.Drawing.Drawing2D.WrapMode mode, System.Drawing.Color color);

Parameters

mode
WrapMode

An element of WrapMode that specifies how repeated copies of an image are used to tile an area.

color
Color

An ImageAttributes object that specifies the color of pixels outside of a rendered image. This color is visible if the mode parameter is set to Clamp and the source rectangle passed to DrawImage is larger than the image itself.

Examples

For a code example, see the SetWrapMode(WrapMode) method.

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.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

SetWrapMode(WrapMode, Color, Boolean)

Source:
ImageAttributes.cs
Source:
ImageAttributes.cs
Source:
ImageAttributes.cs
Source:
ImageAttributes.cs
Source:
ImageAttributes.cs
Source:
ImageAttributes.cs

Sets the wrap mode and color used to decide how to tile a texture across a shape, or at shape boundaries. A texture is tiled across a shape to fill it in when the texture is smaller than the shape it is filling.

C#
public void SetWrapMode(System.Drawing.Drawing2D.WrapMode mode, System.Drawing.Color color, bool clamp);

Parameters

mode
WrapMode

An element of WrapMode that specifies how repeated copies of an image are used to tile an area.

color
Color

A color object that specifies the color of pixels outside of a rendered image. This color is visible if the mode parameter is set to Clamp and the source rectangle passed to DrawImage is larger than the image itself.

clamp
Boolean

This parameter has no effect. Set it to false.

Examples

For a code example, see the SetWrapMode(WrapMode) method.

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.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