# CroppedBitmap

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/media/imaging/struct-croppedbitmap/

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

```rust
struct CroppedBitmap
```

Crops a bitmap.

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

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`dispose`](#function-dispose)
- [`source_property`](#function-source_property)
- [`source_rect_property`](#function-source_rect_property)
- [`construct`](#function-construct)
- [`new`](#function-new)
- [`with_source`](#function-with_source)
- [`invalidated`](#function-invalidated)
- [`source`](#function-source)
- [`set_source`](#function-set_source)
- [`source_rect`](#function-source_rect)
- [`set_source_rect`](#function-set_source_rect)
- [`size`](#function-size)
- [`draw`](#function-draw)

<a id="assoc_const-type"></a>

### TYPE

```rust
const TYPE: &'static $crate::TypeInfo
```

The runtime type of this class.

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

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

### to_ref

```rust
fn to_ref(self: &Self) -> $crate::Ref<CroppedBitmap>
```

Returns a strong reference to this object.

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

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

### dispose

```rust
fn dispose(self: &Self)
```

Releases the source bitmap.

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

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

### source_property

```rust
fn source_property() -> &'static StyledProperty<Option<Rc<dyn IImage>>>
```

Defines the `Source` property.

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

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

### source_rect_property

```rust
fn source_rect_property() -> &'static StyledProperty<PixelRect>
```

Defines the `SourceRect` property.

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

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

### construct

```rust
fn construct() -> Self
```

Creates the class data.

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

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

### new

```rust
fn new() -> Ref<Self>
```



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

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

### with_source

```rust
fn with_source(source: Rc<dyn IImage>, source_rect: PixelRect) -> Ref<Self>
```

Creates a cropped bitmap showing `source_rect` of `source`.

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

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

### invalidated

```rust
fn invalidated(self: &Self, handler: impl Fn() -> () + 'static) -> Subscription
```

Raised when the image changes. Dropping the returned guard removes the
handler; `Subscription::detach` keeps it for the life of the image.

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

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

### source

```rust
fn source(self: &Self) -> Option<Rc<dyn IImage>>
```

The source for the bitmap.

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

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

### set_source

```rust
fn set_source(self: &Self, value: Option<Rc<dyn IImage>>)
```



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

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

### source_rect

```rust
fn source_rect(self: &Self) -> PixelRect
```

The rectangular area that the bitmap is cropped to.

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

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

### set_source_rect

```rust
fn set_source_rect(self: &Self, value: PixelRect)
```



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

<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/imaging/cropped_bitmap.rs#L130)

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

### draw

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

Draws the cropped part of the source bitmap: `source_rect` is
relative to the top left corner of the crop rectangle.

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

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`CroppedBitmapImplExt`](/docs/0.5.0/api/ferroui-base/media/imaging/trait-croppedbitmapimplext/)
- [`FerroObjectImplExt`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimplext/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- [`Receiver`](/docs/0.5.0/api/ferroui-system/task/oneshot/struct-receiver/)
- `Any`
- `ErasedDestructor`
- `IntoEither`
- `Deref`
- [`Upcast<T>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`Upcast<CroppedBitmap>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`StaticType`](/docs/0.5.0/api/ferroui-base/trait-statictype/)
- [`ObjectType`](/docs/0.5.0/api/ferroui-base/trait-objecttype/)
- [`Subclassable<T>`](/docs/0.5.0/api/ferroui-base/trait-subclassable/)
- [`DefaultConstructible`](/docs/0.5.0/api/ferroui-base/trait-defaultconstructible/)
- [`FerroObjectImpl`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimpl/)
- [`CroppedBitmapImpl`](/docs/0.5.0/api/ferroui-base/media/imaging/trait-croppedbitmapimpl/)
- [`IAffectsRender`](/docs/0.5.0/api/ferroui-base/media/trait-iaffectsrender/)

## Availability

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