TextureBrush TextureBrush TextureBrush TextureBrush Class

Definition

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
Inheritance

Examples

The following code example demonstrates how to obtain a new bitmap using the FromFile method. It also demonstrates a TextureBrush.

This example is designed to be used with Windows Forms. Create a form containing a button named Button2. 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

Constructors

TextureBrush(Image) TextureBrush(Image) TextureBrush(Image) TextureBrush(Image)

Initializes a new TextureBrush object that uses the specified image.

TextureBrush(Image, Rectangle) TextureBrush(Image, Rectangle) TextureBrush(Image, Rectangle) TextureBrush(Image, Rectangle)

Initializes a new TextureBrush object that uses the specified image and bounding rectangle.

TextureBrush(Image, Rectangle, ImageAttributes) TextureBrush(Image, Rectangle, ImageAttributes) TextureBrush(Image, Rectangle, ImageAttributes) TextureBrush(Image, Rectangle, ImageAttributes)

Initializes a new TextureBrush object that uses the specified image, bounding rectangle, and image attributes.

TextureBrush(Image, RectangleF) TextureBrush(Image, RectangleF) TextureBrush(Image, RectangleF) TextureBrush(Image, RectangleF)

Initializes a new TextureBrush object that uses the specified image and bounding rectangle.

TextureBrush(Image, RectangleF, ImageAttributes) TextureBrush(Image, RectangleF, ImageAttributes) TextureBrush(Image, RectangleF, ImageAttributes) TextureBrush(Image, RectangleF, ImageAttributes)

Initializes a new TextureBrush object that uses the specified image, bounding rectangle, and image attributes.

TextureBrush(Image, WrapMode) TextureBrush(Image, WrapMode) TextureBrush(Image, WrapMode) TextureBrush(Image, WrapMode)

Initializes a new TextureBrush object that uses the specified image and wrap mode.

TextureBrush(Image, WrapMode, Rectangle) TextureBrush(Image, WrapMode, Rectangle) TextureBrush(Image, WrapMode, Rectangle) TextureBrush(Image, WrapMode, Rectangle)

Initializes a new TextureBrush object that uses the specified image, wrap mode, and bounding rectangle.

TextureBrush(Image, WrapMode, RectangleF) TextureBrush(Image, WrapMode, RectangleF) TextureBrush(Image, WrapMode, RectangleF) TextureBrush(Image, WrapMode, RectangleF)

Initializes a new TextureBrush object that uses the specified image, wrap mode, and bounding rectangle.

Properties

Image Image Image Image

Gets the Image object associated with this TextureBrush object.

Transform Transform Transform Transform

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 WrapMode WrapMode

Gets or sets a WrapMode enumeration that indicates the wrap mode for this TextureBrush object.

Methods

Clone() Clone() Clone() Clone()

Creates an exact copy of this TextureBrush object.

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Dispose() Dispose() Dispose() Dispose()

Releases all resources used by this Brush object.

(Inherited from Brush)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

Releases the unmanaged resources used by the Brush and optionally releases the managed resources.

(Inherited from Brush)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
MultiplyTransform(Matrix) MultiplyTransform(Matrix) MultiplyTransform(Matrix) MultiplyTransform(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) MultiplyTransform(Matrix, MatrixOrder) MultiplyTransform(Matrix, MatrixOrder) MultiplyTransform(Matrix, MatrixOrder)

Multiplies the Matrix object that represents the local geometric transformation of this TextureBrush object by the specified Matrix object in the specified order.

ResetTransform() ResetTransform() ResetTransform() ResetTransform()

Resets the Transform property of this TextureBrush object to identity.

RotateTransform(Single) RotateTransform(Single) RotateTransform(Single) RotateTransform(Single)

Rotates the local geometric transformation of this TextureBrush object by the specified amount. This method prepends the rotation to the transformation.

RotateTransform(Single, MatrixOrder) RotateTransform(Single, MatrixOrder) RotateTransform(Single, MatrixOrder) RotateTransform(Single, MatrixOrder)

Rotates the local geometric transformation of this TextureBrush object by the specified amount in the specified order.

ScaleTransform(Single, Single) ScaleTransform(Single, Single) ScaleTransform(Single, Single) ScaleTransform(Single, Single)

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) ScaleTransform(Single, Single, MatrixOrder) ScaleTransform(Single, Single, MatrixOrder) ScaleTransform(Single, Single, MatrixOrder)

Scales the local geometric transformation of this TextureBrush object by the specified amounts in the specified order.

SetNativeBrush(IntPtr) SetNativeBrush(IntPtr) SetNativeBrush(IntPtr) SetNativeBrush(IntPtr)

In a derived class, sets a reference to a GDI+ brush object.

(Inherited from Brush)
ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)
TranslateTransform(Single, Single) TranslateTransform(Single, Single) TranslateTransform(Single, Single) TranslateTransform(Single, Single)

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) TranslateTransform(Single, Single, MatrixOrder) TranslateTransform(Single, Single, MatrixOrder) TranslateTransform(Single, Single, MatrixOrder)

Translates the local geometric transformation of this TextureBrush object by the specified dimensions in the specified order.

Applies to