# LoadedImageSurface

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/rendering/composition/struct-loadedimagesurface/

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

```rust
struct LoadedImageSurface
```

A composition surface whose content is an image (WinUI
`Microsoft.UI.Xaml.Media.LoadedImageSurface`), here backed by a
[`Bitmap`](/docs/0.5.0/api/ferroui-base/media/imaging/struct-bitmap/).

The surface holds a reference to the platform bitmap; the server-side
surface holds another one until it is disposed.

Deviation (winui-composition.md): WinUI loads the image asynchronously
from a URI or a stream and raises `LoadCompleted`; here a surface is made
from a bitmap, or loaded from a stream at once, and the outcome is
`load_status`. There is no `LoadCompleted` event and
no decode size.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/loaded_image_surface.rs#L36)

## Members

- [`from_bitmap`](#function-from_bitmap)
- [`start_load_from_stream`](#function-start_load_from_stream)
- [`compositor`](#function-compositor)
- [`object`](#function-object)
- [`load_status`](#function-load_status)
- [`bitmap`](#function-bitmap)
- [`natural_size`](#function-natural_size)
- [`decoded_size`](#function-decoded_size)
- [`decoded_physical_size`](#function-decoded_physical_size)
- [`is_disposed`](#function-is_disposed)
- [`dispose`](#function-dispose)

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

### from_bitmap

```rust
fn from_bitmap(compositor: &Rc<Compositor>, bitmap: &Bitmap) -> Rc<LoadedImageSurface>
```

A surface that shows `bitmap`. The surface takes another reference to
the platform bitmap: disposing `bitmap` afterwards does not affect it.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/loaded_image_surface.rs#L55)

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

### start_load_from_stream

```rust
fn start_load_from_stream(compositor: &Rc<Compositor>, stream: &mut dyn Read) -> Rc<LoadedImageSurface>
```

`StartLoadFromStream`: a surface with the image decoded from
`stream`. The image is decoded at once; a stream that cannot be read
or decoded gives an empty surface whose
`load_status` says why.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/loaded_image_surface.rs#L63)

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

### compositor

```rust
fn compositor(self: &Self) -> &Rc<Compositor>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/loaded_image_surface.rs#L83)

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

### object

```rust
fn object(self: &Self) -> &CompositionObject
```

The embedded `CompositionObject`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/loaded_image_surface.rs#L88)

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

### load_status

```rust
fn load_status(self: &Self) -> LoadedImageSourceLoadStatus
```

The outcome of the load.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/loaded_image_surface.rs#L98)

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

### bitmap

```rust
fn bitmap(self: &Self) -> Option<&Bitmap>
```

The bitmap the surface shows, `None` when the image did not load or
the surface is disposed.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/loaded_image_surface.rs#L104)

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

### natural_size

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

The size of the image in device independent pixels (`NaturalSize`):
what a surface brush lays out. Empty when the image did not load.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/loaded_image_surface.rs#L110)

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

### decoded_size

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

The size of the decoded image in device independent pixels
(`DecodedSize`): the natural size, as the image is decoded at its
full size.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/loaded_image_surface.rs#L117)

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

### decoded_physical_size

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

The size of the decoded image in pixels (`DecodedPhysicalSize`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/loaded_image_surface.rs#L122)

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

### is_disposed

```rust
fn is_disposed(self: &Self) -> bool
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/loaded_image_surface.rs#L131)

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

### dispose

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

Releases the surface: its server side releases the bitmap with the
next batch.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/rendering/composition/loaded_image_surface.rs#L137)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ErasedDestructor`
- `IntoEither`
- `ICompositionObject`
- [`ICompositionSurface`](/docs/0.5.0/api/ferroui-base/rendering/composition/trait-icompositionsurface/)

## Availability

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