TextureBrush 類別

定義

TextureBrush 類別的每一個屬性都是 Brush 物件,這個物件會使用影像來填滿形狀的內部。 此類別無法獲得繼承。

public ref class TextureBrush sealed : System::Drawing::Brush
public sealed class TextureBrush : System.Drawing.Brush
type TextureBrush = class
    inherit Brush
Public NotInheritable Class TextureBrush
Inherits Brush
繼承

範例

下列程式代碼範例示範如何使用 方法來取得新的點陣圖 FromFile 。 它也會示範 TextureBrush

此範例的設計目的是要與 Windows Forms 搭配使用。 Create 表單,其中包含名為 Button2 的按鈕。 將程式代碼貼到表單中,並將Button2_Click方法與按鈕的事件 Click 產生關聯。

private:
   void Button2_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      try
      {
         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)
{
    try
    {
        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();
        formGraphics.FillEllipse(texture, 
            new RectangleF(90.0F, 110.0F, 100, 100));
        formGraphics.Dispose();
    }
    catch(System.IO.FileNotFoundException)
    {
        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
    Try
        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))
        formGraphics.Dispose()

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

End Sub

備註

注意

在 .NET 6 和更新版本中,只有 Windows 作業系統才支援包含此類型的 System.Drawing.Common 套件。 在跨平臺應用程式中使用此類型會導致編譯時間警告和運行時間例外狀況。 如需詳細資訊,請參閱 僅限 Windows 上支援的 System.Drawing.Common

建構函式

TextureBrush(Image)

初始化使用指定影像的 TextureBrush 物件。

TextureBrush(Image, Rectangle)

初始化新的 TextureBrush 物件,這個物件會使用指定的影像和週框。

TextureBrush(Image, Rectangle, ImageAttributes)

初始化新的 TextureBrush 物件,這個物件會使用指定的影像、週框和影像屬性。

TextureBrush(Image, RectangleF)

初始化新的 TextureBrush 物件,這個物件會使用指定的影像和週框。

TextureBrush(Image, RectangleF, ImageAttributes)

初始化新的 TextureBrush 物件,這個物件會使用指定的影像、週框和影像屬性。

TextureBrush(Image, WrapMode)

初始化新的 TextureBrush 物件,這個物件會使用指定的影像和環繞模式。

TextureBrush(Image, WrapMode, Rectangle)

初始化新的 TextureBrush 物件,這個物件會使用指定的影像、環繞模式和週框。

TextureBrush(Image, WrapMode, RectangleF)

初始化新的 TextureBrush 物件,這個物件會使用指定的影像、環繞模式和週框。

屬性

Image

取得與這個 Image 物件關聯的 TextureBrush 物件。

Transform

取得或設定 Matrix 物件的複本,這個複本會為與這個 TextureBrush 物件相關聯的影像定義局部幾何轉換。

WrapMode

取得或設定 WrapMode 列舉型別 (Enumeration),表示這個 TextureBrush 物件的環繞模式。

方法

Clone()

建立這個 TextureBrush 物件的完全相同複本。

CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。

(繼承來源 MarshalByRefObject)
Dispose()

釋放這個 Brush 物件使用的所有資源。

(繼承來源 Brush)
Dispose(Boolean)

釋放 Brush 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。

(繼承來源 Brush)
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetLifetimeService()
已淘汰.

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。

(繼承來源 MarshalByRefObject)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
InitializeLifetimeService()
已淘汰.

取得存留期服務物件,以控制這個執行個體的存留期原則。

(繼承來源 MarshalByRefObject)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。

(繼承來源 MarshalByRefObject)
MultiplyTransform(Matrix)

藉由將指定的 Matrix 物件附加在前面,根據指定的 Matrix 物件來乘以代表這個 TextureBrush 物件之局部幾何轉換的 Matrix 物件。

MultiplyTransform(Matrix, MatrixOrder)

依照指定的順序,根據指定的 Matrix 物件來乘以代表這個 TextureBrush 物件之局部幾何轉換的 Matrix 物件。

ResetTransform()

將此 TextureBrush 物件的 Transform 屬性重設為單位矩陣。

RotateTransform(Single)

根據指定的角度來旋轉此 TextureBrush 物件的局部幾何轉換。 這個方法會將旋轉附加到轉換之前。

RotateTransform(Single, MatrixOrder)

依照指定的順序,根據指定的量來旋轉此 TextureBrush 物件的局部幾何轉換。

ScaleTransform(Single, Single)

以指定的數量來縮放這個 TextureBrush 物件的局部幾何轉換。 這個方法會將縮放矩陣附加到轉換之前。

ScaleTransform(Single, Single, MatrixOrder)

依照指定的順序,根據指定的量來縮放此 TextureBrush 物件的局部幾何轉換。

SetNativeBrush(IntPtr)

在衍生類別中,設定 GDI+ 筆刷對象的參考。

(繼承來源 Brush)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)
TranslateTransform(Single, Single)

根據指定的維度來轉譯此 TextureBrush 物件的局部幾何轉換。 這個方法會將轉譯附加到轉換之前。

TranslateTransform(Single, Single, MatrixOrder)

依照指定的順序,根據指定的維度來轉換此 TextureBrush物件的局部幾何轉換。

適用於