# ImageShape

**RadImageShape** implements the so called "Segmented Image" semantic, which in general allows a small image (pattern) to be stretched to larger bounds without quality loss. This effect is achieved by dividing the image into 9 logical parts (segments) and providing advanced paint logic for each part.

![Telerik UI for WinForms RadImageShape segmented image example](https://www.telerik.com/products/winforms/documentation/assets/92a7e53b63213706b2a6dac88607161d/tpf-primitives-imageshape001.png)

**RadImageShape.Margins**

**RadImageShape**

![Telerik UI for WinForms RadImageShape nine-segment margin diagram](https://www.telerik.com/products/winforms/documentation/assets/767f9b18b72f6df6aa757b3660d260ac/tpf-primitives-imageshape002.png)

Using the **Margins** property, an image is divided into 9 segments. Following is a brief overview of each segment and how it is stretched:

1. TopLeft – not stretched

2. Top – stretched horizontally

3. TopRight – not stretched

4. Right – stretched vertically

5. BottomRight – not stretched

6. Bottom – stretched horizontally

7. BottomLeft – not stretched

8. Left – stretched vertically

9. Inner – stretched horizontally and vertically

**Advanced Settings**

RadImageShape exposes some advanced settings that allow any complex rendering logic to be easily described. Such settings are:

* **PaintMode** – available are 14 different modes, where each one defines custom paint logic of the 9 segments.

  ![Telerik UI for WinForms RadImageShape StretchYTileX paint mode example](https://www.telerik.com/products/winforms/documentation/assets/2b9a04e09f72ae07cadaf18411976bee/tpf-primitives-imageshape003.png)

*PaintMode.StretchYTileX*

* **InterpolationMode** – defines the interpolation passed to the underlying GDI+ Graphics used to paint the each image part.

* **RotateFlip** – additional option, which allows the source image to be rotated/flipped before segmentation.

* **BackgroundShapePaintMode** - determines when the BackgroundShape will be painted. The following options are available:

  * **PrePaint**: The BackgroundShape will be painted in the PrePaintElement method(before fill, border, text, image etc.). Suitable when you use the BackgroundShape instead of Fill and/or Border.

  * **PostPaint**: The BackgroundShape will be painted on top of all other elements(fill, border, text, image). Here it is not suitable to use a big BackgroundShape, because it will cover everything else painted before. But it is suitable to add some minor indications, for example, the little selection indicator in Windows 10:

  ![Telerik UI for WinForms RadImageShape PostPaint background shape example](https://www.telerik.com/products/winforms/documentation/assets/e3a4cb369d52f20564d43680784a4fa4/tpf-primitives-imageshape005.png)

**Editing RadImageShape in Visual Style Builder**

Each RadElement exposes a property named **BackgroundShape** which is of type **RadImageShape**. Complete **Visual Style Builder** support is provided and you can either create a **RadImageShape** repository item or edit the **BackgroundShape** property directly in the advanced view of each element.

![Telerik UI for WinForms RadImageShape edited in Visual Style Builder](https://www.telerik.com/products/winforms/documentation/assets/d1602d28da1b0faadb032dc11137ca83/tpf-primitives-imageshape004.png)

## See Also

* [ArrowPrimitive](https://www.telerik.com/products/winforms/documentation/telerik-presentation-framework/primitives/arrowprimitive)

* [BorderPrimitive](https://www.telerik.com/products/winforms/documentation/telerik-presentation-framework/primitives/borderprimitive)

* [CheckPrimitive](https://www.telerik.com/products/winforms/documentation/telerik-presentation-framework/primitives/checkprimitive)

* [FillPrimitive](https://www.telerik.com/products/winforms/documentation/telerik-presentation-framework/primitives/fillprimitive)

* [FocusPrimitive](https://www.telerik.com/products/winforms/documentation/telerik-presentation-framework/primitives/focusprimitive)

* [GripPrimitive](https://www.telerik.com/products/winforms/documentation/telerik-presentation-framework/primitives/gripprimitive)

* [ImagePrimitive](https://www.telerik.com/products/winforms/documentation/telerik-presentation-framework/primitives/imageprimitive)

* [LightVisualElement](https://www.telerik.com/products/winforms/documentation/telerik-presentation-framework/primitives/lightvisualelement)
