[−][src]Trait iconwriter::Icon
A generic representation of an icon encoder.
Required methods
pub fn new() -> Self
[src]
pub fn add_entry<F: FnMut(&SourceImage, u32) -> DynamicImage>(
&mut self,
filter: F,
source: &SourceImage,
entry: E
) -> Result<(), Error<E>>
[src]
&mut self,
filter: F,
source: &SourceImage,
entry: E
) -> Result<(), Error<E>>
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.entry
Information on the target entry.
Return Value
- Returns
Err(Error::InvalidDimensions(_))
if the dimensions provided in theentry
argument are not supported. - Returns
Err(Error::AlreadyIncluded(_))
if the icon already contains the target entry. - Returns
Err(Error::MismatchedDimensions(_, (_, _)))
if the resampling filter provided in thefilter
argument produces results of dimensions other than the ones specified byentry
. - Otherwise returns
Ok(())
.
Example
ⓘ
use iconwriter::{Ico, SourceImage, Icon}; use iconwriter::Error as IconError; fn example() -> Result<(), IconError> { let icon = Ico::new(); match SourceImage::from_path("image.svg") { Some(img) => icon.add_entry(resample::linear, &img, 32), None => Ok(()) } }
pub fn write<W: Write>(&mut self, w: &mut W) -> Result<()>
[src]
Writes the contents of the icon to w
.
Example
ⓘ
use iconwriter::*; use std::{io, fs::File}; fn example() -> io::Result<()> { let icon = PngSequence::new(); /* Process the icon */ let file = File::create("out.icns")?; icon.write(file) }
Provided methods
pub fn add_entries<F: FnMut(&SourceImage, u32) -> DynamicImage, I: IntoIterator<Item = E>>(
&mut self,
filter: F,
source: &SourceImage,
entries: I
) -> Result<(), Error<E>>
[src]
&mut self,
filter: F,
source: &SourceImage,
entries: I
) -> Result<(), Error<E>>
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.entries
A container for the information on the target entries.
Return Value
- Returns
Err(Error::InvalidDimensions(_))
if any of the items ofentries
provides unsupported dimensions. - Returns
Err(Error::AlreadyIncluded(_))
if the icon already contains any of the target entries. - Returns
Err(Error::MismatchedDimensions(_, (_, _)))
if the resampling filter provided in thefilter
argument produces results of dimensions other than the ones specified byentries
. - Otherwise returns
Ok(())
.
Example
ⓘ
use iconwriter::{Icns, SourceImage, Icon}; use iconwriter::Error as IconError; fn example() -> Result<(), IconError> { let icon = Icns::new(); match SourceImage::from_path("image.svg") { Some(img) => icon.add_entries( resample::linear, &img, vec![32, 64, 128] ), None => Ok(()) } }
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::*; use std::{io, fs::File}; fn example() -> io::Result<()> { let icon = Ico::new(); /* Process the icon */ icon.save("./output/out.ico") }
Implementors
impl Icon<Entry> for Icns
[src]
pub fn new() -> Self
[src]
pub fn add_entry<F: FnMut(&SourceImage, u32) -> DynamicImage>(
&mut self,
filter: F,
source: &SourceImage,
entry: Entry
) -> Result<(), Error<Entry>>
[src]
&mut self,
filter: F,
source: &SourceImage,
entry: Entry
) -> Result<(), Error<Entry>>
pub fn write<W: Write>(&mut self, w: &mut W) -> Result<()>
[src]
impl Icon<Entry> for Ico
[src]
pub fn new() -> Self
[src]
pub fn add_entry<F: FnMut(&SourceImage, u32) -> DynamicImage>(
&mut self,
filter: F,
source: &SourceImage,
entry: Entry
) -> Result<(), Error<Entry>>
[src]
&mut self,
filter: F,
source: &SourceImage,
entry: Entry
) -> Result<(), Error<Entry>>
pub fn write<W: Write>(&mut self, w: &mut W) -> Result<()>
[src]
impl Icon<NamedEntry> for PngSequence
[src]
pub fn new() -> Self
[src]
pub fn add_entry<F: FnMut(&SourceImage, u32) -> DynamicImage>(
&mut self,
filter: F,
source: &SourceImage,
entry: NamedEntry
) -> Result<(), Error<NamedEntry>>
[src]
&mut self,
filter: F,
source: &SourceImage,
entry: NamedEntry
) -> Result<(), Error<NamedEntry>>