TextureBrush 类

定义

TextureBrush 类的每个属性都是 Brush 对象,这种对象使用图像来填充形状的内部。Each property of the TextureBrush class is a Brush object that uses an image to fill the interior of a shape. 此类不能被继承。This class cannot be inherited.

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方法获取新位图。The following code example demonstrates how to obtain a new bitmap using the FromFile method. 它还演示了TextureBrushIt also demonstrates a TextureBrush.

此示例旨在与 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.

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

构造函数

TextureBrush(Image)

初始化使用指定图像的新 TextureBrush 对象。Initializes a new TextureBrush object that uses the specified image.

TextureBrush(Image, Rectangle)

初始化使用指定图像和边框的新 TextureBrush 对象。Initializes a new TextureBrush object that uses the specified image and bounding rectangle.

TextureBrush(Image, Rectangle, ImageAttributes)

初始化使用指定的图像、边框和图像特性的新 TextureBrush 对象。Initializes a new TextureBrush object that uses the specified image, bounding rectangle, and image attributes.

TextureBrush(Image, RectangleF)

初始化使用指定图像和边框的新 TextureBrush 对象。Initializes a new TextureBrush object that uses the specified image and bounding rectangle.

TextureBrush(Image, RectangleF, ImageAttributes)

初始化使用指定的图像、边框和图像特性的新 TextureBrush 对象。Initializes a new TextureBrush object that uses the specified image, bounding rectangle, and image attributes.

TextureBrush(Image, WrapMode)

初始化使用指定的图像和自动换行模式的新 TextureBrush 对象。Initializes a new TextureBrush object that uses the specified image and wrap mode.

TextureBrush(Image, WrapMode, Rectangle)

初始化使用指定图像、自动换行模式和边框的新 TextureBrush 对象。Initializes a new TextureBrush object that uses the specified image, wrap mode, and bounding rectangle.

TextureBrush(Image, WrapMode, RectangleF)

初始化使用指定图像、自动换行模式和边框的新 TextureBrush 对象。Initializes a new TextureBrush object that uses the specified image, wrap mode, and bounding rectangle.

属性

Image

获取与此 Image 对象关联的 TextureBrush 对象。Gets the Image object associated with this TextureBrush object.

Transform

获取或设置 Matrix 对象的副本,该对象为与此 TextureBrush 对象关联的图像定义局部几何变换。Gets or sets a copy of the Matrix object that defines a local geometric transformation for the image associated with this TextureBrush object.

WrapMode

获取或设置 WrapMode 枚举,它指示此 TextureBrush 对象的换行模式。Gets or sets a WrapMode enumeration that indicates the wrap mode for this TextureBrush object.

方法

Clone()

创建此 TextureBrush 对象的一个精确副本。Creates an exact copy of this TextureBrush object.

CreateObjRef(Type)

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(继承自 MarshalByRefObject)
Dispose()

释放由此 Brush 对象使用的所有资源。Releases all resources used by this Brush object.

(继承自 Brush)
Dispose(Boolean)

释放由 Brush 占用的非托管资源,还可以另外再释放托管资源。Releases the unmanaged resources used by the Brush and optionally releases the managed resources.

(继承自 Brush)
Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetLifetimeService()

检索控制此实例的生存期策略的当前生存期服务对象。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(继承自 MarshalByRefObject)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
InitializeLifetimeService()

获取生存期服务对象来控制此实例的生存期策略。Obtains a lifetime service object to control the lifetime policy for this instance.

(继承自 MarshalByRefObject)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
MemberwiseClone(Boolean)

创建当前 MarshalByRefObject 对象的浅表副本。Creates a shallow copy of the current MarshalByRefObject object.

(继承自 MarshalByRefObject)
MultiplyTransform(Matrix)

通过预先计算指定的 Matrix 对象,将表示此 TextureBrush 对象的局部几何转换的 Matrix 对象与指定 Matrix 对象相乘。Multiplies the Matrix object that represents the local geometric transformation of this TextureBrush object by the specified Matrix object by prepending the specified Matrix object.

MultiplyTransform(Matrix, MatrixOrder)

将表示此 TextureBrush 对象的局部几何转换的 Matrix 对象与指定的 Matrix 对象按指定顺序相乘。Multiplies the Matrix object that represents the local geometric transformation of this TextureBrush object by the specified Matrix object in the specified order.

ResetTransform()

将此 TextureBrush 对象的 Transform 属性重置为标识。Resets the Transform property of this TextureBrush object to identity.

RotateTransform(Single)

TextureBrush 对象的局部几何转换旋转指定量。Rotates the local geometric transformation of this TextureBrush object by the specified amount. 此方法将旋转添加到转换前。This method prepends the rotation to the transformation.

RotateTransform(Single, MatrixOrder)

以指定顺序将 TextureBrush 对象的局部几何转换旋转指定的量。Rotates the local geometric transformation of this TextureBrush object by the specified amount in the specified order.

ScaleTransform(Single, Single)

将此 TextureBrush 对象的局部几何变换缩放指定的倍数。Scales the local geometric transformation of this TextureBrush object by the specified amounts. 此方法将缩放矩阵添加到转换前。This method prepends the scaling matrix to the transformation.

ScaleTransform(Single, Single, MatrixOrder)

以指定顺序将此 TextureBrush 对象的局部几何转换按指定量进行缩放。Scales the local geometric transformation of this TextureBrush object by the specified amounts in the specified order.

SetNativeBrush(IntPtr)

在派生类中,设置对 GDI+GDI+ 画笔对象的引用。In a derived class, sets a reference to a GDI+GDI+ brush object.

(继承自 Brush)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)
TranslateTransform(Single, Single)

根据指定维度,转换此 TextureBrush 对象的局部几何变换。Translates the local geometric transformation of this TextureBrush object by the specified dimensions. 此方法将平移添加到转换前。This method prepends the translation to the transformation.

TranslateTransform(Single, Single, MatrixOrder)

按指定顺序将此 TextureBrush 对象的局部几何转换平移指定的尺寸。Translates the local geometric transformation of this TextureBrush object by the specified dimensions in the specified order.

适用于