[−][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, Size) -> Result<RgbaImage>>(
&mut self,
filter: F,
source: &SourceImage,
size: Size
) -> Result<()>
[src]
&mut self,
filter: F,
source: &SourceImage,
size: Size
) -> Result<()>
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.size
The target size of the entry in pixels.
Return Value
- Returns
Err(Error::InvalidSize(_))
if the dimensions provided in thesize
argument are not supported. - Returns
Err(Error::Image(ImageError::DimensionError))
if the resampling filter provided in thefilter
argument produces results of dimensions other than the ones specified bysize
. - Otherwise return
Ok(())
.
Example
use iconwriter::*; fn main() -> iconwriter::Result<()> { let icon = Ico::new(); match SourceImage::from_path("image.svg") { Some(img) => icon.add_entry(resample::linear, &img, 32), None => Ok(()) } }
pub fn add_entries<F: FnMut(&SourceImage, Size) -> Result<RgbaImage>, I: IntoIterator<Item = Size>>(
&mut self,
filter: F,
source: &SourceImage,
sizes: I
) -> Result<()>
[src]
&mut self,
filter: F,
source: &SourceImage,
sizes: I
) -> Result<()>
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.size
A container for the target sizes of the entries in pixels.
Return Value
- Returns
Err(Error::InvalidSize(_))
if the dimensions provided in thesize
argument are not supported. - Returns
Err(Error::Image(ImageError::DimensionError))
if the resampling filter provided in thefilter
argument produces results of dimensions other than the ones specified bysize
. - Otherwise return
Ok(())
.
Example
use iconwriter::*; fn main() -> iconwriter::Result<()> { 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 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 main() -> io::Result<()> { let icon = PngSequence::new(); /* Process the icon */ let file = File::create("out.icns")?; icon.write(file) }
Implementors
impl Icon for Icns
[src]
pub fn new() -> Self
[src]
pub fn add_entry<F: FnMut(&SourceImage, Size) -> Result<RgbaImage>>(
&mut self,
filter: F,
source: &SourceImage,
size: Size
) -> Result<()>
[src]
&mut self,
filter: F,
source: &SourceImage,
size: Size
) -> Result<()>
pub fn add_entries<F: FnMut(&SourceImage, Size) -> Result<RgbaImage>, I: IntoIterator<Item = Size>>(
&mut self,
filter: F,
source: &SourceImage,
sizes: I
) -> Result<()>
[src]
&mut self,
filter: F,
source: &SourceImage,
sizes: I
) -> Result<()>
pub fn write<W: Write>(&mut self, w: &mut W) -> Result<()>
[src]
impl Icon for Ico
[src]
pub fn new() -> Self
[src]
pub fn add_entry<F: FnMut(&SourceImage, Size) -> Result<RgbaImage>>(
&mut self,
filter: F,
source: &SourceImage,
size: Size
) -> Result<()>
[src]
&mut self,
filter: F,
source: &SourceImage,
size: Size
) -> Result<()>
pub fn add_entries<F: FnMut(&SourceImage, Size) -> Result<RgbaImage>, I: IntoIterator<Item = Size>>(
&mut self,
filter: F,
source: &SourceImage,
sizes: I
) -> Result<()>
[src]
&mut self,
filter: F,
source: &SourceImage,
sizes: I
) -> Result<()>
pub fn write<W: Write>(&mut self, w: &mut W) -> Result<()>
[src]
impl Icon for PngSequence
[src]
pub fn new() -> Self
[src]
pub fn add_entry<F: FnMut(&SourceImage, Size) -> Result<RgbaImage>>(
&mut self,
filter: F,
source: &SourceImage,
size: Size
) -> Result<()>
[src]
&mut self,
filter: F,
source: &SourceImage,
size: Size
) -> Result<()>
pub fn add_entries<F: FnMut(&SourceImage, Size) -> Result<RgbaImage>, I: IntoIterator<Item = Size>>(
&mut self,
filter: F,
source: &SourceImage,
sizes: I
) -> Result<()>
[src]
&mut self,
filter: F,
source: &SourceImage,
sizes: I
) -> Result<()>