ImageAttributes.SetWrapMode 方法

定义

设置包装模式。

重载

名称 说明
SetWrapMode(WrapMode)

设置包装模式,该模式用于决定如何跨形状或形状边界平铺纹理。 当纹理小于其填充的形状时,纹理将平铺在形状上以填充它。

SetWrapMode(WrapMode, Color)

设置包装模式和颜色,用于决定如何跨形状或形状边界平铺纹理。 当纹理小于其填充的形状时,纹理将平铺在形状上以填充它。

SetWrapMode(WrapMode, Color, Boolean)

设置包装模式和颜色,用于决定如何跨形状或形状边界平铺纹理。 当纹理小于其填充的形状时,纹理将平铺在形状上以填充它。

SetWrapMode(WrapMode)

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

设置包装模式,该模式用于决定如何跨形状或形状边界平铺纹理。 当纹理小于其填充的形状时,纹理将平铺在形状上以填充它。

public:
 void SetWrapMode(System::Drawing::Drawing2D::WrapMode mode);
public void SetWrapMode(System.Drawing.Drawing2D.WrapMode mode);
member this.SetWrapMode : System.Drawing.Drawing2D.WrapMode -> unit
Public Sub SetWrapMode (mode As WrapMode)

参数

mode
WrapMode

该元素 WrapMode 指定如何使用图像的重复副本来平铺区域。

示例

下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse,这是 Paint 事件处理程序的参数。 该示例执行以下操作:

  1. 从 Circle3.jpg 文件(一个红色的小圆圈)打开一个 Image 文件,并将其绘制到屏幕。

  2. 创建一个 ImageAttributes 对象并将枚举设置为 WrapModeTile.

  3. 从 Circle3.jpg 文件创建使用 TextureBrush 映像。

  4. 向屏幕绘制一个矩形,该矩形填充了小的红色圆圈。

void SetWrapModeExample( PaintEventArgs^ e )
{
   // Create a filled, red circle, and save it to Circle3.jpg.
   Bitmap^ myBitmap = gcnew Bitmap( 50,50 );
   Graphics^ g = Graphics::FromImage( myBitmap );
   g->Clear( Color::White );
   g->FillEllipse( gcnew SolidBrush( Color::Red ), 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 = gcnew ImageAttributes;
   imageAttr->SetWrapMode( WrapMode::Tile );

   // Create a TextureBrush.
   Rectangle brushRect = Rectangle(0,0,25,25);
   TextureBrush^ myTBrush = gcnew TextureBrush( myImage,brushRect,imageAttr );

   // Draw to the screen a rectangle filled with red circles.
   e->Graphics->FillRectangle( myTBrush, 100, 20, 200, 200 );
}
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);
}
Public Sub SetWrapModeExample(ByVal e As PaintEventArgs)

    ' Create a filled, red circle, and save it to Circle3.jpg.
    Dim myBitmap As New Bitmap(50, 50)
    Dim g As Graphics = 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.
    Dim myImage As Image = Image.FromFile("Circle3.jpg")
    e.Graphics.DrawImage(myImage, 20, 20)

    ' Set the wrap mode.
    Dim imageAttr As New ImageAttributes
    imageAttr.SetWrapMode(WrapMode.Tile)

    ' Create a TextureBrush.
    Dim brushRect As New Rectangle(0, 0, 25, 25)
    Dim myTBrush As New TextureBrush(myImage, brushRect, imageAttr)

    ' Draw to the screen a rectangle filled with red circles.
    e.Graphics.FillRectangle(myTBrush, 100, 20, 200, 200)
End Sub

注解

调用该方法SetWrapMode(WrapMode)等效于为SetWrapMode(WrapMode, Color)参数调用Color.Black和传递colorColor.Black 指定呈现的图像之外像素的颜色。 如果模式参数设置为 Clamp ,并且传递给 DrawImage 该方法的源矩形大于图像本身,则此颜色可见。

适用于

SetWrapMode(WrapMode, Color)

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

设置包装模式和颜色,用于决定如何跨形状或形状边界平铺纹理。 当纹理小于其填充的形状时,纹理将平铺在形状上以填充它。

public:
 void SetWrapMode(System::Drawing::Drawing2D::WrapMode mode, System::Drawing::Color color);
public void SetWrapMode(System.Drawing.Drawing2D.WrapMode mode, System.Drawing.Color color);
member this.SetWrapMode : System.Drawing.Drawing2D.WrapMode * System.Drawing.Color -> unit
Public Sub SetWrapMode (mode As WrapMode, color As Color)

参数

mode
WrapMode

该元素 WrapMode 指定如何使用图像的重复副本来平铺区域。

color
Color

一个 ImageAttributes 对象,指定呈现的图像外部像素的颜色。 如果模式参数设置为 Clamp 且传递给 DrawImage 的源矩形大于图像本身,则此颜色可见。

示例

有关代码示例,请参阅该方法 SetWrapMode(WrapMode)

适用于

SetWrapMode(WrapMode, Color, Boolean)

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

设置包装模式和颜色,用于决定如何跨形状或形状边界平铺纹理。 当纹理小于其填充的形状时,纹理将平铺在形状上以填充它。

public:
 void SetWrapMode(System::Drawing::Drawing2D::WrapMode mode, System::Drawing::Color color, bool clamp);
public void SetWrapMode(System.Drawing.Drawing2D.WrapMode mode, System.Drawing.Color color, bool clamp);
member this.SetWrapMode : System.Drawing.Drawing2D.WrapMode * System.Drawing.Color * bool -> unit
Public Sub SetWrapMode (mode As WrapMode, color As Color, clamp As Boolean)

参数

mode
WrapMode

该元素 WrapMode 指定如何使用图像的重复副本来平铺区域。

color
Color

一个颜色对象,指定呈现的图像外部像素的颜色。 如果模式参数设置为 Clamp 且传递给 DrawImage 的源矩形大于图像本身,则此颜色可见。

clamp
Boolean

此参数不起作用。 将其设置为 false

示例

有关代码示例,请参阅该方法 SetWrapMode(WrapMode)

适用于