[−][src]Struct native_windows_gui::Bitmap
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
impl Bitmap[src]
pub fn builder<'a>() -> BitmapBuilder<'a>[src]
pub fn from_system(sys_bitmap: OemBitmap) -> Bitmap[src]
Single line helper function over the bitmap builder api.
Use system resources.
pub fn from_file(path: &str, strict: bool) -> Result<Bitmap, NwgError>[src]
Single line helper function over the bitmap builder api.
Use a file resource.
pub fn from_bin(bin: &[u8]) -> Result<Bitmap, NwgError>[src]
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>[src]
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.
pub fn copy_as_icon(&self) -> Icon[src]
Creates a new icon from the bitmap data.
Panics if the bitmap is not initialized
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Bitmap[src]
impl !Send for Bitmap[src]
impl !Sync for Bitmap[src]
impl Unpin for Bitmap[src]
impl UnwindSafe for Bitmap[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,