WrapMode 枚举


指定当纹理或渐变小于所填充的区域时平铺纹理或渐变的方式。Specifies how a texture or gradient is tiled when it is smaller than the area being filled.

public enum class WrapMode
public enum WrapMode
type WrapMode = 
Public Enum WrapMode


Clamp 4

纹理或渐变没有平铺。The texture or gradient is not tiled.

Tile 0

平铺渐变或纹理。Tiles the gradient or texture.

TileFlipX 1

水平反转纹理或渐变,然后平铺该纹理或渐变。Reverses the texture or gradient horizontally and then tiles the texture or gradient.

TileFlipXY 3

水平和垂直反转纹理或渐变,然后平铺该纹理或渐变。Reverses the texture or gradient horizontally and vertically and then tiles the texture or gradient.

TileFlipY 2

垂直反转纹理或渐变,然后平铺该纹理或渐变。Reverses the texture or gradient vertically and then tiles the texture or gradient.


下面的代码示例演示如何使用 FromFile 方法获取新位图。The following code example demonstrates how to obtain a new bitmap using the FromFile method. 它还演示 TextureBrushWrapMode 枚举。It also demonstrates a TextureBrush and the WrapMode enumeration. 此示例旨在与 Windows 窗体一起使用。This example is designed to be used with Windows Forms. 创建一个包含名为 Button2的按钮的窗体。Create a form containing a button named Button2. 将代码粘贴到窗体中,并将 Button2_Click 方法与按钮的 Click 事件关联。Paste the code into the form and associate the Button2_Click method with the button's Click event.

   void Button2_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
         Bitmap^ image1 = dynamic_cast<Bitmap^>(Image::FromFile( "C:\\Documents and Settings\\"
         "All Users\\Documents\\My Music\\music.bmp", true ));
         TextureBrush^ texture = gcnew TextureBrush( image1 );
         texture->WrapMode = System::Drawing::Drawing2D::WrapMode::Tile;
         Graphics^ formGraphics = this->CreateGraphics();
         formGraphics->FillEllipse( texture, RectangleF(90.0F,110.0F,100,100) );
         delete formGraphics;
      catch ( System::IO::FileNotFoundException^ ) 
         MessageBox::Show( "There was an error opening the bitmap."
         "Please check the path." );
private void Button2_Click(System.Object sender, System.EventArgs e)
        Bitmap image1 = (Bitmap) Image.FromFile(@"C:\Documents and Settings\" +
            @"All Users\Documents\My Music\music.bmp", true);

        TextureBrush texture = new TextureBrush(image1);
        texture.WrapMode = System.Drawing.Drawing2D.WrapMode.Tile;
        Graphics formGraphics = this.CreateGraphics();
            new RectangleF(90.0F, 110.0F, 100, 100));
        MessageBox.Show("There was an error opening the bitmap." +
            "Please check the path.");
Private Sub Button2_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button2.Click
        Dim image1 As Bitmap = _
            CType(Image.FromFile("C:\Documents and Settings\" _
            & "All Users\Documents\My Music\music.bmp", True), Bitmap)

        Dim texture As New TextureBrush(image1)
        texture.WrapMode = Drawing2D.WrapMode.Tile
        Dim formGraphics As Graphics = Me.CreateGraphics()
        formGraphics.FillEllipse(texture, _
            New RectangleF(90.0F, 110.0F, 100, 100))

    Catch ex As System.IO.FileNotFoundException
        MessageBox.Show("There was an error opening the bitmap." _
            & "Please check the path.")
    End Try

End Sub


画笔使用此枚举来确定如何填充形状。Brushes use this enumeration to determine how shapes are filled. 若要查看 WrapMode 枚举值在平铺图像上的效果的示例,请参阅如何:使用图像平铺形状To see examples of the effects the WrapMode enumeration values have on a tiled image, see How to: Tile a Shape with an Image.