ImageAttributes.SetWrapMode 方法

定義

設定環繞模式。Sets the wrap mode.

多載

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)

設定環繞模式 (Wrap Mode),這個模式是用來決定如何橫越形狀或在形狀界限並排紋理。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, 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, 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.

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

參數

mode
WrapMode

WrapMode 的元素,指定如何使用重複的影像複本來並排填滿區域。An element of WrapMode that specifies how repeated copies of an image are used to tile an area.

color
Color

ImageAttributes 物件,指定所呈現影像外部的像素色彩。An ImageAttributes object that specifies the color of pixels outside of a rendered image. 如果模式參數設定為 Clamp,而且傳遞至 DrawImage 的來源矩形大於影像本身,就會顯示這個色彩。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.

範例

如需程式碼範例, 請SetWrapMode(WrapMode)參閱方法。For a code example, see the SetWrapMode(WrapMode) method.

SetWrapMode(WrapMode)

設定環繞模式 (Wrap Mode),這個模式是用來決定如何橫越形狀或在形狀界限並排紋理。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.

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 的元素,指定如何使用重複的影像複本來並排填滿區域。An element of WrapMode that specifies how repeated copies of an image are used to tile an area.

範例

下列程式碼範例是針對與 Windows Forms 搭配使用所設計, 而且PaintEventArgs它需要e, 這Paint是事件處理常式的參數。The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. 該程式碼執行下列動作:The code performs the following actions:

  1. Image從 [Circle3] 檔案 (一個小型的紅色實心圓形) 開啟, 並將它繪製到螢幕上。Opens an Image from the Circle3.jpg file (a small, red-filled circle) and draws it to the screen.

  2. 建立物件, 並WrapMode將列舉設定為TileImageAttributesCreates an ImageAttributes object and sets the WrapMode enumeration to Tile.

  3. TextureBrush使用來自 Circle3 的影像建立。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.

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, Color) , 並針對color參數Color.Black傳遞。 SetWrapMode(WrapMode)Calling the SetWrapMode(WrapMode) method is equivalent to calling SetWrapMode(WrapMode, Color) and passing Color.Black for the color parameter. Color.Black指定呈現影像外的圖元色彩。Color.Black specifies the color of pixels outside of a rendered image. 如果模式參數設定為Clamp , 而且傳遞DrawImage至方法的來源矩形大於影像本身, 就會顯示此色彩。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.

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.

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

參數

mode
WrapMode

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. 如果模式參數設定為 Clamp,而且傳遞至 DrawImage 的來源矩形大於影像本身,就會顯示這個色彩。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. 請將它設定為 falseSet it to false.

範例

如需程式碼範例, 請SetWrapMode(WrapMode)參閱方法。For a code example, see the SetWrapMode(WrapMode) method.

適用於