[−][src]Trait iconwriter::Icon
A generic representation of an icon encoder.
Associated Types
Loading content...Required methods
pub fn with_capacity(capacity: usize) -> Self
[src]
Constructs a new, empty Icon
with the specified capacity.
The capacity
argument designates the number of entries
that will be allocated.
Example
ⓘ
let icon = Ico::with_capacity(5);
pub fn len(&self) -> usize
[src]
Returns the number of entries contained in the icon.
pub fn add_entry<F: FnMut(&DynamicImage, u32) -> Result<DynamicImage>>(
&mut self,
filter: F,
source: &Image,
key: Self::Key
) -> Result<(), IconError<Self::Key>>
[src]
&mut self,
filter: F,
source: &Image,
key: Self::Key
) -> Result<(), IconError<Self::Key>>
Adds an individual entry to the icon.
Arguments
filter
The resampling filter that will be used to re-scalesource
.source
A reference to the source image this entry will be based on.key
Information on the target entry.
Return Value
- Returns
Err(IconError::AlreadyIncluded(_))
if the icon already contains an entry associated withkey
. - Returns
Err(IconError::Resample(_))
if the resampling filter provided in thefilter
argument fails produces results of dimensions other than the ones specified bykey
. - Otherwise returns
Ok(())
.
Example
ⓘ
use iconwriter::{Ico, Image, Icon, IconError}; fn example() -> Result<(), IconError> { let icon = Ico::new(); let src = Image::open("image.svg")?; icon.add_entry(resample::linear, &img, 32) }
pub fn write<W: Write>(&mut self, w: &mut W) -> Result<()>
[src]
Writes the contents of the icon to w
.
Example
ⓘ
use iconwriter::favicon::Favicon; use std::{io, fs::File}; fn example() -> io::Result<()> { let icon = Favicon::new(); /* Process the icon */ let file = File::create("out.icns")?; icon.write(file) }
Provided methods
pub fn new() -> Self
[src]
pub fn add_entries<F: FnMut(&DynamicImage, u32) -> Result<DynamicImage>, I: IntoIterator<Item = Self::Key>>(
&mut self,
filter: F,
source: &Image,
keys: I
) -> Result<(), IconError<Self::Key>>
[src]
&mut self,
filter: F,
source: &Image,
keys: I
) -> Result<(), IconError<Self::Key>>
Adds a series of entries to the icon.
Arguments
filter
The resampling filter that will be used to re-scalesource
.source
A reference to the source image this entry will be based on.keys
A container for the information on the target entries.
Return Value
- Returns
Err(IconError::AlreadyIncluded(_))
if the icon already contains an entry associated with any of the items ofkeys
. - Returns
Err(IconError::Resample(_))
if the resampling filter provided in thefilter
argument fails or produces results of dimensions other than the ones specified by the items ofkeys
. - Otherwise returns
Ok(())
.
Example
ⓘ
use iconwriter::{Icns, Image, Icon, IconError}; fn example() -> Result<(), IconError> { let icon = Icns::new(); let src = Image::open("image.svg")?; icon.add_entries( resample::linear, &src, vec![32, 64, 128] ) }
pub fn save<P: AsRef<Path>>(&mut self, path: &P) -> Result<()>
[src]
Writes the contents of the icon to a file on disk.
Example
ⓘ
use iconwriter::favicon::Favicon; use std::{io, fs::File}; fn example() -> io::Result<()> { let icon = Favicon::new(); /* Process the icon */ icon.save("./output/") }
Implementors
impl Icon for Favicon
[src]
type Key = Key
pub fn with_capacity(capacity: usize) -> Self
[src]
pub fn len(&self) -> usize
[src]
pub fn add_entry<F: FnMut(&DynamicImage, u32) -> Result<DynamicImage>>(
&mut self,
filter: F,
source: &Image,
key: Self::Key
) -> Result<(), IconError<Self::Key>>
[src]
&mut self,
filter: F,
source: &Image,
key: Self::Key
) -> Result<(), IconError<Self::Key>>
pub fn write<W: Write>(&mut self, w: &mut W) -> Result<()>
[src]
pub fn save<P: AsRef<Path>>(&mut self, base_path: &P) -> Result<()>
[src]
impl Icon for Icns
[src]
type Key = Key
pub fn with_capacity(capacity: usize) -> Self
[src]
pub fn len(&self) -> usize
[src]
pub fn add_entry<'a, F: FnMut(&DynamicImage, u32) -> Result<DynamicImage>>(
&mut self,
filter: F,
source: &Image,
key: Self::Key
) -> Result<(), IconError<Self::Key>>
[src]
&mut self,
filter: F,
source: &Image,
key: Self::Key
) -> Result<(), IconError<Self::Key>>
pub fn write<W: Write>(&mut self, w: &mut W) -> Result<()>
[src]
impl Icon for Ico
[src]
type Key = Key
pub fn with_capacity(capacity: usize) -> Self
[src]
pub fn len(&self) -> usize
[src]
pub fn add_entry<F: FnMut(&DynamicImage, u32) -> Result<DynamicImage>>(
&mut self,
filter: F,
source: &Image,
key: Self::Key
) -> Result<(), IconError<Self::Key>>
[src]
&mut self,
filter: F,
source: &Image,
key: Self::Key
) -> Result<(), IconError<Self::Key>>