# IImage

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/media/trait-iimage/

**trait** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
trait IImage: 'static
```

Represents a bitmap or drawing which can be drawn.

Implemented by the bitmap types and, through an adapter, by the image
classes (cropped bitmaps and drawing images): a handle of such a class
converts to `Rc<dyn IImage>` with `into()`. The `as_*` members replace
interface casts (`image as IBitmap`).

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/i_image.rs#L12)

## Members

- [`size`](#function-size)
- [`draw`](#function-draw)
- [`as_any`](#function-as_any)
- [`as_object`](#function-as_object)
- [`as_bitmap`](#function-as_bitmap)
- [`as_affects_render`](#function-as_affects_render)

<a id="function-size"></a>

### size

```rust
fn size(self: &Self) -> Size
```

The size of the image, in device independent pixels.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/i_image.rs#L14)

<a id="function-draw"></a>

### draw

```rust
fn draw(self: &Self, context: &mut DrawingContext<'_>, source_rect: Rect, dest_rect: Rect)
```

Draws the image to a drawing context: the part of the image inside
`source_rect` is drawn into `dest_rect`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/i_image.rs#L18)

<a id="function-as_any"></a>

### as_any

```rust
fn as_any(self: &Self) -> &dyn Any
```

The implementing value, for downcasts to concrete image types. For
image classes use `as_object`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/i_image.rs#L22)

<a id="function-as_object"></a>

### as_object

```rust
fn as_object(self: &Self) -> Option<&FerroObject>
```

The object behind the image when it is an image class.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/i_image.rs#L25)

<a id="function-as_bitmap"></a>

### as_bitmap

```rust
fn as_bitmap(self: &Self) -> Option<&dyn IBitmap>
```

The image viewed as a bitmap, when it is one.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/i_image.rs#L30)

<a id="function-as_affects_render"></a>

### as_affects_render

```rust
fn as_affects_render(self: &Self) -> Option<&dyn IAffectsRender>
```

The image viewed as `IAffectsRender`, when it can change.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/i_image.rs#L35)

## Trait implementations

- [`IImage`](/docs/0.5.0/api/ferroui-base/media/trait-iimage/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
