pub enum ImageSource {
Pixmap(Arc<Pixmap>),
OpaqueId {
id: ImageId,
may_have_transparency: bool,
},
ExternalTexture {
id: TextureId,
source_region: RectU16,
may_have_transparency: bool,
},
}Expand description
Bitmap source used by Image.
Variants§
Pixmap(Arc<Pixmap>)
Pixmap pixels travel with the scene packet.
OpaqueId
Pixmap pixels were registered earlier; this is just a handle.
Fields
ExternalTexture
An externally owned texture supplied to the renderer at render time.
Implementations§
Source§impl ImageSource
impl ImageSource
Sourcepub fn opaque_id(id: ImageId) -> Self
pub fn opaque_id(id: ImageId) -> Self
Create an ImageSource from a pre-registered image handle.
Conservatively assumes the image may have non-opaque pixels.
Use Self::opaque_id_with_transparency_hint when you know the image is fully opaque.
Sourcepub fn opaque_id_with_transparency_hint(
id: ImageId,
may_have_transparency: bool,
) -> Self
pub fn opaque_id_with_transparency_hint( id: ImageId, may_have_transparency: bool, ) -> Self
Create an ImageSource from a pre-registered image handle,
with an explicit hint about whether the image may have non-opaque pixels.
Sourcepub fn external_texture(
texture_id: TextureId,
source_region: RectU16,
may_have_transparency: bool,
) -> Self
pub fn external_texture( texture_id: TextureId, source_region: RectU16, may_have_transparency: bool, ) -> Self
Create an image source backed by a texture supplied to the renderer at render time.
§Panics
Panics if source_region is empty.
Sourcepub fn may_have_transparency(&self) -> bool
pub fn may_have_transparency(&self) -> bool
Returns whether this image source may contain non-opaque pixels.
Sourcepub fn from_peniko_image_data(image: &ImageData) -> Self
pub fn from_peniko_image_data(image: &ImageData) -> Self
Convert a peniko::ImageData to an ImageSource.
This is a somewhat lossy conversion, as the image data data is transformed to premultiplied RGBA8.
§Panics
This panics if image has a width or height greater than u16::MAX.
Trait Implementations§
Source§impl Clone for ImageSource
impl Clone for ImageSource
Source§fn clone(&self) -> ImageSource
fn clone(&self) -> ImageSource
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more