Partilhar via


Convert an image to a brush

This page applies to WPF and Silverlight 2

You can create a brush resource from a picture, photograph, or other image file, and then apply that brush resource to another object.

Note

If you want to include other objects in your brush resource, use the procedure in Create or modify a drawing brush resource.

To convert an image to a brush

  1. Add an image file to your project by clicking AddExistingItem on the File menu, browsing to your image file, and then clicking Open.

  2. Under Files in the Project panel, double-click the image file to add it to the artboard.

    The image file is added as an Image object that you can resize and modify on the artboard.

  3. Under Objects and Timeline, select the Image object that you created in the previous step.

  4. On the Tools menu, point to Make Brush Resource, and then click Make ImageBrush Resource. An image brush can paint an area with an image. It is a type of tile brush that defines its content as an image.

    The Create ImageBrush Resource dialog box opens.

  5. Under Name (Key), enter a name for your image brush resource. This is the name by which other elements can reference the resource, thereby applying the resource to themselves.

  6. Under Define in, select the option where you want the image brush resource to be defined:

    • To make the resource available to any document in your application, select Application.

    • To make the resource available only to the current document, select This document (Window: Window).

    • To make the resource available only to the object from which you created the resource or its child objects, select This document (object).

    • To define the resource in a resource dictionary file that you can reuse in other projects, select an existing Resource dictionary, or click the New button to create a new resource dictionary.

  7. Click OK to close the dialog box and create the resource. The original image remains in your document.

  8. You can view the new image brush resource in the Resources tab, from where you can drag it onto another object on the artboard and select the brush property to apply it to. For more methods of applying a resource, see Apply a brush to an object's fill or stroke.

See also

Concepts

Create a brush or color resource

Create an image or drawing brush to apply as a material