1 out of 1 rated this helpful - Rate this topic

TextureBrush Class

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.

System.Object
  System.MarshalByRefObject
    System.Drawing.Brush
      System.Drawing.TextureBrush

Namespace:  System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)
public sealed class TextureBrush : Brush

The TextureBrush type exposes the following members.

  Name Description
Public method TextureBrush(Image) Initializes a new TextureBrush object that uses the specified image.
Public method TextureBrush(Image, WrapMode) Initializes a new TextureBrush object that uses the specified image and wrap mode.
Public method TextureBrush(Image, Rectangle) Initializes a new TextureBrush object that uses the specified image and bounding rectangle.
Public method TextureBrush(Image, RectangleF) Initializes a new TextureBrush object that uses the specified image and bounding rectangle.
Public method TextureBrush(Image, WrapMode, Rectangle) Initializes a new TextureBrush object that uses the specified image, wrap mode, and bounding rectangle.
Public method TextureBrush(Image, WrapMode, RectangleF) Initializes a new TextureBrush object that uses the specified image, wrap mode, and bounding rectangle.
Public method TextureBrush(Image, Rectangle, ImageAttributes) Initializes a new TextureBrush object that uses the specified image, bounding rectangle, and image attributes.
Public method TextureBrush(Image, RectangleF, ImageAttributes) Initializes a new TextureBrush object that uses the specified image, bounding rectangle, and image attributes.
Top
  Name Description
Public property Image Gets the Image object associated with this TextureBrush object.
Public property Transform Gets or sets a copy of the Matrix object that defines a local geometric transformation for the image associated with this TextureBrush object.
Public property WrapMode Gets or sets a WrapMode enumeration that indicates the wrap mode for this TextureBrush object.
Top
  Name Description
Public method Clone Creates an exact copy of this TextureBrush object. (Overrides Brush.Clone().)
Public method CreateObjRef Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public method Dispose() Releases all resources used by this Brush object. (Inherited from Brush.)
Protected method Dispose(Boolean) Releases the unmanaged resources used by the Brush and optionally releases the managed resources. (Inherited from Brush.)
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Brush.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetLifetimeService Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method InitializeLifetimeService Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Protected method MemberwiseClone() Creates a shallow copy of the current Object. (Inherited from Object.)
Protected method MemberwiseClone(Boolean) Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.)
Public method 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.
Public method 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.
Public method ResetTransform Resets the Transform property of this TextureBrush object to identity.
Public method RotateTransform(Single) Rotates the local geometric transformation of this TextureBrush object by the specified amount. This method prepends the rotation to the transformation.
Public method RotateTransform(Single, MatrixOrder) Rotates the local geometric transformation of this TextureBrush object by the specified amount in the specified order.
Public method 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.
Public method ScaleTransform(Single, Single, MatrixOrder) Scales the local geometric transformation of this TextureBrush object by the specified amounts in the specified order.
Protected method SetNativeBrush In a derived class, sets a reference to a GDI+ brush object. (Inherited from Brush.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Public method TranslateTransform(Single, Single) Translates the local geometric transformation of this TextureBrush object by the specified dimensions. This method prepends the translation to the transformation.
Public method TranslateTransform(Single, Single, MatrixOrder) Translates the local geometric transformation of this TextureBrush object by the specified dimensions in the specified order.
Top

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 = (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.");
    }

}


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ