Struct native_windows_gui::Bitmap [−][src]
pub struct Bitmap {
pub handle: HANDLE,
// some fields omitted
}Expand description
A wrapper over a bitmap file (*.bmp)
Note that Bitmap object are only used as display resources (ie: it’s impossible to read pixels or resized it).
If those features are needed, see the image-decoder feature.
To display a bitmap in an application, see the ImageFrame control.
By default, bitmap resources do not support transparency BUT if image-decoder is enabled, bitmaps can be loaded
from any file type supported natively by Windows: JPEG, PNG, BMP, ICO, DDS, TIFF.
Bitmaps can be converted to icons using the “copy_as_icon” function.
Builder parameters:
source_file: The source of the bitmap if it is a file.source_bin: The source of the bitmap if it is a binary blob. For example usinginclude_bytes!("my_icon.bmp").source_system: The source of the bitmap if it is a system resource (see OemBitmap)source_embed: The source of the bitmap if it is stored in an embedded filesource_embed_id: The number identifier of the icon in the embedded filesource_embed_str: The string identifier of the icon in the embedded filesize: Optional. Resize the image to this size.strict: Use a system placeholder instead of panicking if the image source do no exists.
Example:
use native_windows_gui as nwg; fn load_bitmap() -> nwg::Bitmap { nwg::Bitmap::from_file("Hello.bmp", true).unwrap() } fn load_bitmap_builder() -> nwg::Bitmap { let mut bitmap = nwg::Bitmap::default(); nwg::Bitmap::builder() .source_file(Some("Hello.bmp")) .strict(true) .build(&mut bitmap) .unwrap(); bitmap }
Fields
handle: HANDLEImplementations
Single line helper function over the bitmap builder api.
Use system resources.
Single line helper function over the bitmap builder api.
Use a file resource.
Single line helper function over the bitmap builder api.
Use a binary resource.
pub fn from_embed(
embed: &EmbedResource,
embed_id: Option<usize>,
embed_str: Option<&str>
) -> Result<Bitmap, NwgError>
pub fn from_embed(
embed: &EmbedResource,
embed_id: Option<usize>,
embed_str: Option<&str>
) -> Result<Bitmap, NwgError>Single line helper function over the bitmap builder api.
Use an embedded resource. Either embed_id or embed_str must be defined, not both.
Requires the embed-resource feature.
Creates a new icon from the bitmap data.
Panics if the bitmap is not initialized
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Bitmapimpl UnwindSafe for Bitmap