ImageAttributes.SetWrapMode 方法

定義

設定環繞模式。

多載

SetWrapMode(WrapMode)

設定環繞模式,這個模式是用來決定如何橫越形狀或在形狀界限並排紋理。 當紋理小於它正在填滿的形狀時,紋理會橫越形狀來並排,以便將它填滿。

SetWrapMode(WrapMode, Color)

指定用來決定如何橫越形狀或在形狀界限並排紋理的環繞模式和色彩。 當紋理小於它正在填滿的形狀時,紋理會橫越形狀來並排,以便將它填滿。

SetWrapMode(WrapMode, Color, Boolean)

指定用來決定如何橫越形狀或在形狀界限並排紋理的環繞模式和色彩。 當紋理小於它正在填滿的形狀時,紋理會橫越形狀來並排,以便將它填滿。

SetWrapMode(WrapMode)

來源:
ImageAttributes.cs
來源:
ImageAttributes.cs
來源:
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 Forms 使用,而且需要 PaintEventArgse,這是事件處理程序的參數Paint。 此程式碼會執行下列動作:

  1. Image從 Circle3.jpg 檔案開啟 , (小型、紅色填滿的圓形) ,並將其繪製到畫面。

  2. ImageAttributes建立物件,並將 WrapMode 列舉設定為 Tile

  3. TextureBrush使用 Circle3.jpg 檔案中的映像建立 。

  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 會指定轉譯影像外圖元的色彩。 如果mode參數設定為 Clamp ,且傳遞至 DrawImage 方法的來源矩形大於影像本身,則會顯示這個色彩。

適用於

SetWrapMode(WrapMode, Color)

來源:
ImageAttributes.cs
來源:
ImageAttributes.cs
來源:
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)

來源:
ImageAttributes.cs
來源:
ImageAttributes.cs
來源:
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) 方法。

適用於