Struct ico::IconDirEntry
source · pub struct IconDirEntry { /* private fields */ }
Expand description
One entry in an ICO or CUR file; a single icon or cursor.
Implementations§
source§impl IconDirEntry
impl IconDirEntry
sourcepub fn resource_type(&self) -> ResourceType
pub fn resource_type(&self) -> ResourceType
Returns the type of resource stored in this entry, either an icon or a cursor.
sourcepub fn bits_per_pixel(&self) -> u16
pub fn bits_per_pixel(&self) -> u16
Returns the bits-per-pixel (color depth) of the image. Returns zero if
self.resource_type() == ResourceType::Cursor
(since CUR files store
hotspot coordinates in place of this field).
sourcepub fn cursor_hotspot(&self) -> Option<(u16, u16)>
pub fn cursor_hotspot(&self) -> Option<(u16, u16)>
Returns the coordinates of the cursor hotspot (pixels right from the
left edge of the image, and pixels down from the top edge), or None
if self.resource_type() != ResourceType::Cursor
.
sourcepub fn is_png(&self) -> bool
pub fn is_png(&self) -> bool
Returns true if the image is encoded as a PNG, or false if it is encoded as a BMP.
sourcepub fn decode(&self) -> Result<IconImage>
pub fn decode(&self) -> Result<IconImage>
Decodes this entry into an image. Returns an error if the data is malformed or can’t be decoded.
sourcepub fn encode(image: &IconImage) -> Result<IconDirEntry>
pub fn encode(image: &IconImage) -> Result<IconDirEntry>
Encodes an image in a new entry. The encoding method is chosen automatically based on the image. Returns an error if the encoding fails.
sourcepub fn encode_as_bmp(image: &IconImage) -> Result<IconDirEntry>
pub fn encode_as_bmp(image: &IconImage) -> Result<IconDirEntry>
Encodes an image as a BMP in a new entry. The color depth is determined automatically based on the image. Returns an error if the encoding fails.
sourcepub fn encode_as_png(image: &IconImage) -> Result<IconDirEntry>
pub fn encode_as_png(image: &IconImage) -> Result<IconDirEntry>
Encodes an image as a PNG in a new entry. The color depth is determined automatically based on the image. Returns an error if the encoding fails.
Trait Implementations§
source§impl Clone for IconDirEntry
impl Clone for IconDirEntry
source§fn clone(&self) -> IconDirEntry
fn clone(&self) -> IconDirEntry
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more