xtd 1.0.0
Loading...
Searching...
No Matches
xtd::drawing::icon Class Reference
Inheritance diagram for xtd::drawing::icon:
xtd::object xtd::iequatable< icon > xtd::interface xtd::extensions::equality_operators< icon, iequatable< icon > >

Definition

Represents a Windows icon, which is a small bitmap image that is used to represent an object. Icons can be thought of as transparent bitmaps, although their size is determined by the system.

icon(const xtd::string &filename)
Initializes a new instance of the xtd::drawing::icon class from the specified file name.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
#define drawing_export_
Define shared library export.
Definition drawing_export.hpp:13
Inheritance
xtd::objectxtd::drawing::icon
Namespace
xtd::drawing
Library
xtd.drawing

Fileds

static icon empty

Public Constructors

 icon (const xtd::string &filename)
 Initializes a new instance of the xtd::drawing::icon class from the specified file name.
 icon (const xtd::string &filename, const xtd::drawing::size &size)
 Initializes a new instance of the xtd::drawing::icon class of the specified size from the specified file.
 icon (const xtd::string &filename, int32 width, int32 height)
 Initializes a new instance of the xtd::drawing::icon class with the specified width and height from the specified file.
 icon (std::istream &stream)
 Initializes a new instance of the xtd::drawing::icon class from the specified data stream.
 icon (std::istream &stream, const xtd::drawing::size &size)
 Initializes a new instance of the xtd::drawing::icon class of the specified size from the specified stream.
 icon (std::istream &stream, int32 width, int32 height)
 Initializes a new instance of the xtd::drawing::icon class from the specified data stream and with the specified width and height.
 icon (const char *const *bits)
 Initializes a new instance of the xtd::drawing::icon class from the specified data.
 icon (const char *const *bits, const xtd::drawing::size &size)
 Initializes a new instance of the xtd::drawing::icon class of the specified size from the specified data.
 icon (const char *const *bits, int32 width, int32 height)
 Initializes a new instance of the xtd::drawing::icon class from the specified data and with the specified width and height.
 icon (const icon &original, const xtd::drawing::size &size)
 Initializes a new instance of the xtd::drawing::icon class and attempts to find a version of the icon that matches the requested size.
 icon (const icon &original, int32 width, int32 height)
 Initializes a new instance of the xtd::drawing::icon class and attempts to find a version of the icon that matches the requested size.

Public Properties

auto handle () const noexcept -> xtd::intptr
 Gets the handle of this icon. This is not a copy of the handle; do not free it.
auto height () const noexcept -> xtd::int32
 Gets the height of this xtd::drawing::icon.
auto size () const noexcept -> const xtd::drawing::size &
 Gets the size of this xtd::drawing::icon.
auto width () const noexcept -> xtd::int32
 Gets the width of this xtd::drawing::icon.

Public Methods

auto equals (const object &obj) const noexcept -> bool override
 Determines whether the specified object is equal to the current object.
auto equals (const icon &other) const noexcept -> bool override
 Indicates whether the current object is equal to another object of the same type.
auto get_hash_code () const noexcept -> xtd::usize override
 Serves as a hash function for a particular type.
auto save (const xtd::string &filename) const -> void
 Saves this xtd::drawing::icon to the specified output filename.
auto save (std::ostream &stream) const -> void
 Saves this xtd::drawing::icon to the specified output std::ostream.
auto to_bitmap () const -> xtd::drawing::bitmap
 Converts this xtd::drawing::icon to a GDI+ xtd::drawing::bitmap.
auto to_string () const noexcept -> xtd::string override
 Gets a human-readable string that describes the xtd::drawing::icon.

Public Static Methods

static auto from_bitmap (const xtd::drawing::bitmap &bitmap) -> icon
 Creates a GDI+ xtd::drawing::icon from the specified bitmap.
static auto from_handle (intptr handle) -> icon
 Creates a GDI+ xtd::drawing::icon from the specified Windows handle to an icon (HICON).

Additional Inherited Members

 object ()=default
 Create a new instance of the ultimate base class object.
virtual auto get_type () const noexcept -> type_object
 Gets the type of the current instance.
template<typename object_t>
auto memberwise_clone () const -> xtd::unique_ptr_object< object_t >
 Creates a shallow copy of the current object.
virtual auto equals (const icon &) const noexcept -> bool=0
 Indicates whether the current object is equal to another object of the same type.
template<typename object_a_t, typename object_b_t>
static auto equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool
 Determines whether the specified object instances are considered equal.
template<typename object_a_t, typename object_b_t>
static auto reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool
 Determines whether the specified object instances are the same instance.

Constructor & Destructor Documentation

◆ icon() [1/11]

xtd::drawing::icon::icon ( const xtd::string & filename)
explicit

Initializes a new instance of the xtd::drawing::icon class from the specified file name.

Parameters
filenameThe file to load the xtd::drawing::icon from.
Remarks
An icon resource can contain multiple icon images. One icon file may contain images in several sizes and color depths. The image that is used in an application depends on the operating system and settings. The following list details the typical sizes for an icon:
  • 16 pixels x 16 pixels
  • 32 pixels x 32 pixels
  • 48 pixels x 48 pixels
This constructor returns the smallest image that is contained in the specified file.

◆ icon() [2/11]

xtd::drawing::icon::icon ( const xtd::string & filename,
const xtd::drawing::size & size )

Initializes a new instance of the xtd::drawing::icon class of the specified size from the specified file.

Parameters
filenameThe file to load the xtd::drawing::icon from.
sizeThe desired size of the icon.
Remarks
If the specified file does not contain an image that matches the desired size, the icon that has the closest size is returned.
The filename should include the complete path if it is not in the current application directory.

◆ icon() [3/11]

xtd::drawing::icon::icon ( const xtd::string & filename,
int32 width,
int32 height )

Initializes a new instance of the xtd::drawing::icon class with the specified width and height from the specified file.

Parameters
filenameThe file to load the xtd::drawing::icon from.
widthThe desired width of the xtd::drawing::icon.
heightThe desired height of the xtd::drawing::icon.
Remarks
If the specified file does not contain an image that matches the desired height and width, the icon that has the closest size is returned.
The filename should include the complete path if it is not in the current application directory.

◆ icon() [4/11]

xtd::drawing::icon::icon ( std::istream & stream)
explicit

Initializes a new instance of the xtd::drawing::icon class from the specified data stream.

Parameters
streamThe data stream from which to load the xtd::drawing::icon.
Remarks
An icon resource can contain multiple icon images. One icon file may contain images in several sizes and color depths. The image that is used in an application depends on the operating system and settings. The following list details the typical sizes for an icon:
  • 16 pixels x 16 pixels
  • 32 pixels x 32 pixels
  • 48 pixels x 48 pixels
This constructor returns the smallest image that is contained in the specified stream.

◆ icon() [5/11]

xtd::drawing::icon::icon ( std::istream & stream,
const xtd::drawing::size & size )

Initializes a new instance of the xtd::drawing::icon class of the specified size from the specified stream.

Parameters
streamThe data stream from which to load the xtd::drawing::icon.
sizeThe desired size of the icon.

◆ icon() [6/11]

xtd::drawing::icon::icon ( std::istream & stream,
int32 width,
int32 height )

Initializes a new instance of the xtd::drawing::icon class from the specified data stream and with the specified width and height.

Parameters
streamThe data stream from which to load the xtd::drawing::icon.
widthThe width, in pixels, of the icon.
heightThe height, in pixels, of the icon.

◆ icon() [7/11]

xtd::drawing::icon::icon ( const char *const * bits)
explicit

Initializes a new instance of the xtd::drawing::icon class from the specified data.

Parameters
streamThe data stream from which to load the xtd::drawing::icon.
Remarks
An icon resource can contain multiple icon images. One icon file may contain images in several sizes and color depths. The image that is used in an application depends on the operating system and settings. The following list details the typical sizes for an icon:
  • 16 pixels x 16 pixels
  • 32 pixels x 32 pixels
  • 48 pixels x 48 pixels
This constructor returns the smallest image that is contained in the specified data.
This constructor is used for creating a xtd::drawing::icon from an xpm (or xbm) image.

◆ icon() [8/11]

xtd::drawing::icon::icon ( const char *const * bits,
const xtd::drawing::size & size )

Initializes a new instance of the xtd::drawing::icon class of the specified size from the specified data.

Parameters
streamThe data stream from which to load the xtd::drawing::icon.
sizeThe desired size of the icon.
Remarks
This constructor is used for creating a xtd::drawing::icon from an xpm (or xbm) image.

◆ icon() [9/11]

xtd::drawing::icon::icon ( const char *const * bits,
int32 width,
int32 height )

Initializes a new instance of the xtd::drawing::icon class from the specified data and with the specified width and height.

Parameters
streamThe data stream from which to load the xtd::drawing::icon.
widthThe width, in pixels, of the icon.
heightThe height, in pixels, of the icon.
Remarks
This constructor is used for creating a xtd::drawing::icon from an xpm (or xbm) image.

◆ icon() [10/11]

xtd::drawing::icon::icon ( const icon & original,
const xtd::drawing::size & size )

Initializes a new instance of the xtd::drawing::icon class and attempts to find a version of the icon that matches the requested size.

Parameters
originalThe xtd::drawing::icon from which to load the newly sized icon.
sizeA xtd::drawing::size structure that specifies the height and width of the new xtd::drawing::icon.
Remarks
If a version cannot be found that exactly matches the size, the closest match is used. If the original parameter is an xtd::drawing::icon that has a single size, this method only creates a duplicate icon. Use the stretching capabilities of the xtd::graphics::drawing::draw_image method to resize the icon.

◆ icon() [11/11]

xtd::drawing::icon::icon ( const icon & original,
int32 width,
int32 height )

Initializes a new instance of the xtd::drawing::icon class and attempts to find a version of the icon that matches the requested size.

Parameters
originalThe xtd::drawing::icon from which to load the newly sized icon.
widthThe width of the new icon.
heightThe height of the new icon.
Remarks
If a version cannot be found that exactly matches the size, the closest match is used. If the original parameter is an xtd::drawing::icon that has a single size, this method only creates a duplicate icon. Use the stretching capabilities of the xtd::graphics::drawing::draw_image method to resize the icon.

Member Function Documentation

◆ handle()

auto xtd::drawing::icon::handle ( ) const -> xtd::intptr
nodiscardnoexcept

Gets the handle of this icon. This is not a copy of the handle; do not free it.

Returns
The Windows handle for the icon.

◆ height()

auto xtd::drawing::icon::height ( ) const -> xtd::int32
nodiscardnoexcept

Gets the height of this xtd::drawing::icon.

Returns
The height of this xtd::drawing::icon.

◆ size()

auto xtd::drawing::icon::size ( ) const -> const xtd::drawing::size &
nodiscardnoexcept

Gets the size of this xtd::drawing::icon.

Returns
The size of this xtd::drawing::icon.

◆ width()

auto xtd::drawing::icon::width ( ) const -> xtd::int32
nodiscardnoexcept

Gets the width of this xtd::drawing::icon.

Returns
The width of this xtd::drawing::icon.

◆ equals() [1/2]

auto xtd::drawing::icon::equals ( const object & obj) const -> bool
nodiscardoverridevirtualnoexcept

Determines whether the specified object is equal to the current object.

Parameters
objThe object to compare with the current object.
Returns
true if the specified object is equal to the current object. otherwise, false.

Reimplemented from xtd::object.

◆ equals() [2/2]

auto xtd::drawing::icon::equals ( const icon & other) const -> bool
nodiscardoverridenoexcept

Indicates whether the current object is equal to another object of the same type.

Parameters
otherAn object to compare with this object.
Returns
true if the current object is equal to the other parameter; otherwise, false.

◆ get_hash_code()

auto xtd::drawing::icon::get_hash_code ( ) const -> xtd::usize
nodiscardoverridevirtualnoexcept

Serves as a hash function for a particular type.

Returns
A hash code for the current object.

Reimplemented from xtd::object.

◆ save() [1/2]

auto xtd::drawing::icon::save ( const xtd::string & filename) const -> void

Saves this xtd::drawing::icon to the specified output filename.

Parameters
filenameThe file to save to.

◆ save() [2/2]

auto xtd::drawing::icon::save ( std::ostream & stream) const -> void

Saves this xtd::drawing::icon to the specified output std::ostream.

Parameters
streamThe std::ostream to save to.

◆ to_bitmap()

auto xtd::drawing::icon::to_bitmap ( ) const -> xtd::drawing::bitmap
nodiscard

Converts this xtd::drawing::icon to a GDI+ xtd::drawing::bitmap.

Returns
A Bitmap that represents the converted xtd::drawing::icon.
Remarks
The transparent areas of the icon are lost when it is converted to a bitmap, and the transparent color of the resulting bitmap is set to RGB(13,11,12). The returned bitmap has the same height and width as the original icon.

◆ to_string()

auto xtd::drawing::icon::to_string ( ) const -> xtd::string
nodiscardoverridevirtualnoexcept

Gets a human-readable string that describes the xtd::drawing::icon.

Returns
A string that describes the xtd::drawing::icon.

Reimplemented from xtd::object.

◆ from_bitmap()

auto xtd::drawing::icon::from_bitmap ( const xtd::drawing::bitmap & bitmap) -> icon
staticnodiscard

Creates a GDI+ xtd::drawing::icon from the specified bitmap.

Parameters
bitmapA xtd::drawing::bitmap use to create xtd::drawing::icon.
Returns
The xtd::drawing::icon this method creates.

◆ from_handle()

auto xtd::drawing::icon::from_handle ( intptr handle) -> icon
staticnodiscard

Creates a GDI+ xtd::drawing::icon from the specified Windows handle to an icon (HICON).

Parameters
handleA Windows handle to an icon.
Returns
The xtd::drawing::icon this method creates.
Remarks
When using this method, you must dispose of the original icon by using the DestroyIcon method in the Windows API to ensure that the resources are released.

The documentation for this class was generated from the following file:
  • xtd.drawing/include/xtd/drawing/icon.hpp