# EffectImage

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

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

```rust
struct EffectImage
```

A handle of an image that a shader effect samples: the value of an image
parameter of a custom effect
(`EffectParameterValue::Image`).

It is cheap to clone (an `Arc`), `Send` and `Sync`, and compares by
identity: two handles are equal when they are clones of one handle (or
both empty), whatever the pixels. The default is the empty handle, an
image of no pixels, which a program samples as transparent.

The handle holds a counted reference to the framework's bitmap (the
platform bitmap of a `Bitmap`, a
`RenderTargetBitmap` capture of a page), so the bitmap lives while a
handle does. The bitmap is treated as immutable: a backend uploads it once
and draws the upload until the handle is released (a bitmap whose
version changes is uploaded
again).

```ignore
let page = Bitmap::from_stream(&mut stream)?;
let effect = MaskTransitionEffect { to_page: EffectImage::new(&page), progress: 0.5, ..Default::default() };
visual.set_effect(Some(ImmutableCustomEffect::new(effect).into()));
```

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

## Members

- [`empty`](#function-empty)
- [`new`](#function-new)
- [`is_empty`](#function-is_empty)
- [`id`](#function-id)
- [`pixel_size`](#function-pixel_size)
- [`version`](#function-version)
- [`downgrade`](#function-downgrade)
- [`pixels`](#function-pixels)
- [`release_generation`](#function-release_generation)

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

### empty

```rust
const fn empty() -> Self
```

The empty handle: no image; sampled as transparent.

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

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

### new

```rust
fn new(bitmap: &dyn IBitmap) -> Self
```

A handle of `bitmap`: another counted reference to its platform
bitmap, so the bitmap lives while the handle does.
## Panics
Panics when the bitmap has been disposed.

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

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

### is_empty

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

Whether the handle is the empty one.

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

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

### id

```rust
fn id(self: &Self) -> u64
```

The identity of the handle: the same for its clones, never given to
another image; 0 for the empty handle. What the backends key their
uploads by.

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

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

### pixel_size

```rust
fn pixel_size(self: &Self) -> PixelSize
```

The size of the image in device pixels (zero for the empty handle).

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

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

### version

```rust
fn version(self: &Self) -> i32
```

The version of the pixels of the bitmap
(`IBitmapImpl::version`); 0 for the empty handle.

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

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

### downgrade

```rust
fn downgrade(self: &Self) -> EffectImageWeak
```

A weak handle, which does not keep the image: what a backend keeps
with what it made of the image, to know when to release it.

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

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

### pixels

```rust
fn pixels(self: &Self) -> Option<EffectImagePixels>
```

The pixels of the image as premultiplied RGBA, read once per version
of the bitmap: what the CPU references sample and a backend that
uploads pixels uploads. `None` for the empty handle and for a bitmap
whose pixels cannot be read on the processor (a texture of a device).

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

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

### release_generation

```rust
fn release_generation() -> u64
```

How many image handles were released so far (the last clone of each
dropped). A backend that keeps uploads by identity looks for the dead
weak handles of its entries when this changes, on
the thread that owns the uploads.

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

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ResourceKeyObject`](/docs/0.5.0/api/ferroui-base/controls/trait-resourcekeyobject/)
- [`PropertyValue`](/docs/0.5.0/api/ferroui-base/trait-propertyvalue/)
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `ErasedDestructor`
- `IntoEither`
- `From<EffectImage>`
- `From<&EffectImage>`
- `Clone`
- `Default`
- `PartialEq`
- `Eq`
- `Hash`
- `Debug`

## Availability

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