Struct IcoBuilder

Source
pub struct IcoBuilder { /* private fields */ }
Expand description

Builds an ICO file from individual files. For each size, the closest source image is scaled down to the appropriate size.

Implementations§

Source§

impl IcoBuilder

Source

pub fn sizes(&mut self, sizes: impl Into<IconSizes>) -> &mut IcoBuilder

Customizes the sizes included in the ICO file. Defaults to IconSizes::MINIMAL.

Source

pub fn add_source_file( &mut self, source_file: impl AsRef<Path>, ) -> &mut IcoBuilder

Adds a source file. These file can be PNG, BMP or any other format supported by the image crate. The icons are assumed to be a square.

Note that you’ll have to enable the necessary features on the image crate if you want to use formats other than PNG or BMP:

# ...

[dependencies]
ico-builder = { version = "...", features = ["jpeg"] }
Examples found in repository?
examples/default-sizes.rs (line 6)
4fn main() -> Result<(), Box<dyn Error>> {
5    IcoBuilder::default()
6        .add_source_file("examples/icons/icon-32x32.png")
7        .add_source_file("examples/icons/icon-256x256.png")
8        .build_file("examples/icons/icon.ico")?;
9    Ok(())
10}
Source

pub fn add_source_files( &mut self, source_files: impl IntoIterator<Item = impl AsRef<Path>>, ) -> &mut IcoBuilder

Adds sources files. See: IcoBuilder::add_source_file.

Source

pub fn filter_type(&mut self, filter_type: FilterType) -> &mut IcoBuilder

Customizes the filter type used when downscaling the images. Defaults to FilterType::Lanczos3.

Source

pub fn build_file(&self, output_file_path: impl AsRef<Path>) -> Result<()>

Builds the ICO file and writes it to the specified output_file_path.

Examples found in repository?
examples/default-sizes.rs (line 8)
4fn main() -> Result<(), Box<dyn Error>> {
5    IcoBuilder::default()
6        .add_source_file("examples/icons/icon-32x32.png")
7        .add_source_file("examples/icons/icon-256x256.png")
8        .build_file("examples/icons/icon.ico")?;
9    Ok(())
10}
Source

pub fn build_file_cargo(&self, file_name: impl AsRef<OsStr>) -> Result<PathBuf>

Builds the ICO file and writes it to OUT_DIR. Tells Cargo to re-build when one of the specified sources changes.

§Panics

This function panics if the path of one of the source files is not valid UTF-8.

Trait Implementations§

Source§

impl Debug for IcoBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for IcoBuilder

Source§

fn default() -> Self

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

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.