pub struct Bitmap {
    pub handle: HANDLE,
    /* private fields */
}
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 using include_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 file
  • source_embed_id: The number identifier of the icon in the embedded file
  • source_embed_str: The string identifier of the icon in the embedded file
  • size: 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: HANDLE

Implementations

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.

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

Returns the “default value” for a type. Read more

Executes the destructor for this type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.