libfacade 1.1
A library for manipulating PNG images with payloads.
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
facade::ico::Icon Class Reference

A Windows icon file. More...

#include <ico.hpp>

Inheritance diagram for facade::ico::Icon:
facade::ICOPayload

Public Types

enum  EntryType { ENTRY_BMP = 0 , ENTRY_PNG }
 A simple enumeration to differentiate between PNG sections and bitmap sections. More...
 
using Entry = std::pair< IconDirEntry, std::vector< std::uint8_t > >
 A C++ representation of a bitmap entry within the icon file.
 

Public Member Functions

 Icon ()
 
 Icon (const void *ptr, std::size_t size)
 
 Icon (const std::vector< std::uint8_t > &vec)
 
 Icon (const std::string &filename)
 
 Icon (const Icon &other)
 
Iconoperator= (const Icon &other)
 
Entryoperator[] (std::size_t index)
 Syntactic sugar to get an entry within the icon file.
 
const Entryoperator[] (std::size_t index) const
 Syntactic sugar to get a const entry within the icon file.
 
std::size_t size (void) const
 Return the number of bitmap entries within the icon file.
 
void parse (const void *ptr, std::size_t size)
 Parse the given pointer and size as an icon file.
 
void parse (const std::vector< std::uint8_t > &vec)
 Parse the given byte vector as an icon file.
 
void parse (const std::string &filename)
 Parse the given file as an icon file.
 
Entryget_entry (std::size_t index)
 Get a bitmap entry within the icon file.
 
const Entryget_entry (std::size_t index) const
 Get a const bitmap entry within the icon file.
 
void set_entry (std::size_t index, const Entry &data)
 Set the given entry at the given index in the icon file's bitmap directory.
 
void set_entry (std::size_t index, const IconDirEntry &entry, const std::vector< std::uint8_t > &data)
 Set the given entry object and image data at the given index in the icon file's bitmap directory.
 
EntryType entry_type (std::size_t index) const
 Return the type of bitmap the given directory bitmap is. Possible values are Icon::EntryType::ENTRY_BMP and Icon::EntryType::ENTRY_PNG.
 
std::vector< std::uint8_t > to_file () const
 Convert this icon object to its file representation.
 
void save (const std::string &filename) const
 Convert this icon object to a file and save it to disk.
 
void resize (std::size_t size)
 Resize the number of entries this icon object can hold.
 
Entryinsert_entry (std::size_t index, const Entry &entry)
 Insert and return the given bitmap entry at the given index.
 
Entryinsert_entry (std::size_t index, const IconDirEntry &entry, const std::vector< std::uint8_t > &data)
 Insert and return the given entry header and bitmap data at the given index.
 
Entryappend_entry (const Entry &entry)
 Append a bitmap entry pair to the end of this icon's bitmap directory.
 
Entryappend_entry (const IconDirEntry &entry, const std::vector< std::uint8_t > &data)
 Append an entry header and bitmap data to the end of the icon's bitmap directory.
 
void remove_entry (std::size_t index)
 Remove the bitmap entry at the given index.
 

Detailed Description

A Windows icon file.

Member Typedef Documentation

◆ Entry

using facade::ico::Icon::Entry = std::pair<IconDirEntry, std::vector<std::uint8_t> >

A C++ representation of a bitmap entry within the icon file.

Member Enumeration Documentation

◆ EntryType

A simple enumeration to differentiate between PNG sections and bitmap sections.

Enumerator
ENTRY_BMP 
ENTRY_PNG 

Constructor & Destructor Documentation

◆ Icon() [1/5]

facade::ico::Icon::Icon ( )
inline

◆ Icon() [2/5]

facade::ico::Icon::Icon ( const void *  ptr,
std::size_t  size 
)
inline

◆ Icon() [3/5]

facade::ico::Icon::Icon ( const std::vector< std::uint8_t > &  vec)
inline

◆ Icon() [4/5]

facade::ico::Icon::Icon ( const std::string &  filename)
inline

◆ Icon() [5/5]

facade::ico::Icon::Icon ( const Icon other)
inline

Member Function Documentation

◆ append_entry() [1/2]

Icon::Entry & Icon::append_entry ( const Entry entry)

Append a bitmap entry pair to the end of this icon's bitmap directory.

◆ append_entry() [2/2]

Icon::Entry & Icon::append_entry ( const IconDirEntry entry,
const std::vector< std::uint8_t > &  data 
)

Append an entry header and bitmap data to the end of the icon's bitmap directory.

◆ entry_type()

Icon::EntryType Icon::entry_type ( std::size_t  index) const

Return the type of bitmap the given directory bitmap is. Possible values are Icon::EntryType::ENTRY_BMP and Icon::EntryType::ENTRY_PNG.

Exceptions
exception::OutOfBounds

◆ get_entry() [1/2]

Icon::Entry & Icon::get_entry ( std::size_t  index)

Get a bitmap entry within the icon file.

Returns
An Icon::Entry pair.
Exceptions
exception::OutOfBounds

◆ get_entry() [2/2]

const Icon::Entry & Icon::get_entry ( std::size_t  index) const

Get a const bitmap entry within the icon file.

Returns
A const Icon::Entry pair.
Exceptions
exception::OutOfBounds

◆ insert_entry() [1/2]

Icon::Entry & Icon::insert_entry ( std::size_t  index,
const Entry entry 
)

Insert and return the given bitmap entry at the given index.

Exceptions
exception::OutOfBounds

◆ insert_entry() [2/2]

Icon::Entry & Icon::insert_entry ( std::size_t  index,
const IconDirEntry entry,
const std::vector< std::uint8_t > &  data 
)

Insert and return the given entry header and bitmap data at the given index.

Exceptions
exception::OutOfBounds

◆ operator=()

Icon & facade::ico::Icon::operator= ( const Icon other)
inline

◆ operator[]() [1/2]

Entry & facade::ico::Icon::operator[] ( std::size_t  index)
inline

Syntactic sugar to get an entry within the icon file.

◆ operator[]() [2/2]

const Entry & facade::ico::Icon::operator[] ( std::size_t  index) const
inline

Syntactic sugar to get a const entry within the icon file.

◆ parse() [1/3]

void Icon::parse ( const std::string &  filename)

Parse the given file as an icon file.

See also
parse(const void *, std::size_t)

◆ parse() [2/3]

void Icon::parse ( const std::vector< std::uint8_t > &  vec)

Parse the given byte vector as an icon file.

See also
parse(const void *, std::size_t)

◆ parse() [3/3]

void Icon::parse ( const void *  ptr,
std::size_t  size 
)

Parse the given pointer and size as an icon file.

Exceptions
exception::InsufficientSize
exception::InvalidIconHeader
exception::OutOfBounds

◆ remove_entry()

void Icon::remove_entry ( std::size_t  index)

Remove the bitmap entry at the given index.

Exceptions
exception::OutOfBounds

◆ resize()

void Icon::resize ( std::size_t  size)

Resize the number of entries this icon object can hold.

◆ save()

void Icon::save ( const std::string &  filename) const

Convert this icon object to a file and save it to disk.

See also
Icon::to_file
facade::write_file

◆ set_entry() [1/2]

void Icon::set_entry ( std::size_t  index,
const Entry data 
)

Set the given entry at the given index in the icon file's bitmap directory.

Exceptions
exception::OutOfBounds

◆ set_entry() [2/2]

void Icon::set_entry ( std::size_t  index,
const IconDirEntry entry,
const std::vector< std::uint8_t > &  data 
)

Set the given entry object and image data at the given index in the icon file's bitmap directory.

Exceptions
exception::OutOfBounds

◆ size()

std::size_t Icon::size ( void  ) const

Return the number of bitmap entries within the icon file.

◆ to_file()

std::vector< std::uint8_t > Icon::to_file ( void  ) const

Convert this icon object to its file representation.

Exceptions
exception::NoIconData

The documentation for this class was generated from the following files: