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

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.

Represents a Windows icon, which is a small bitmap image that is used to represent an object....
Definition icon.hpp:28
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:42
#define drawing_export_
Define shared library export.
Definition drawing_export.hpp:13
Inheritance
xtd::objectxtd::drawing::icon
Namespace
xtd::drawing
Library
xtd.drawing
Examples
minesweeper.cpp, and stopwatch_form.cpp.

Static Public Member Functions

static icon from_handle (intptr handle)
 Creates a GDI+ xtd::drawing::icon from the specified Windows handle to an icon (HICON).
 
- Static Public Member Functions inherited from xtd::object
template<typename object_a_t , typename object_b_t >
static bool equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 
template<typename object_a_t , typename object_b_t >
static bool reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are the same instance.
 

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

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

Public Methods

bool equals (const icon &icon) const noexcept override
 
void save (const xtd::string &filename) const
 Saves this xtd::drawing::icon to the specified output filename.
 
void save (std::ostream &stream) const
 Saves this xtd::drawing::icon to the specified output std::ostream.
 
xtd::drawing::bitmap to_bitmap () const
 Converts this xtd::drawing::icon to a GDI+ xtd::drawing::bitmap.
 
xtd::string to_string () const noexcept override
 Gets a human-readable string that describes the xtd::drawing::icon.
 
virtual bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object.
 
template<typename object_a_t , typename object_b_t >
static bool equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 

Public Static Methods

static icon from_bitmap (const xtd::drawing::bitmap &bitmap)
 Creates a GDI+ xtd::drawing::icon from the specified bitmap.
 

Additional Inherited Members

- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object.
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type.
 
virtual type_object get_type () const noexcept
 Gets the type of the current instance.
 
template<typename object_t >
xtd::uptr< object_t > memberwise_clone () const
 Creates a shallow copy of the current object.
 
- Public Member Functions inherited from xtd::iequatable< icon >
virtual bool equals (const icon &) const noexcept=0
 Indicates whether the current object is equal to another object of the same type.
 

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()

intptr xtd::drawing::icon::handle ( ) const
noexcept

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()

int32 xtd::drawing::icon::height ( ) const
noexcept

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

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

◆ size()

const xtd::drawing::size & xtd::drawing::icon::size ( ) const
noexcept

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

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

◆ width()

int32 xtd::drawing::icon::width ( ) const
noexcept

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

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

◆ save() [1/2]

void xtd::drawing::icon::save ( const xtd::string filename) const

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

Parameters
filenameThe file to save to.

◆ save() [2/2]

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

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

Parameters
streamThe std::ostream to save to.

◆ to_bitmap()

xtd::drawing::bitmap xtd::drawing::icon::to_bitmap ( ) const

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()

xtd::string xtd::drawing::icon::to_string ( ) const
overridevirtualnoexcept

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_handle()

static icon xtd::drawing::icon::from_handle ( intptr  handle)
static

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.

◆ from_bitmap()

static icon xtd::drawing::icon::from_bitmap ( const xtd::drawing::bitmap bitmap)
static

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.

◆ equals() [1/2]

virtual bool xtd::object::equals ( const object obj) const
virtualnoexcept

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.
Examples
The following code example compares the current instance with another object.
#include <xtd/console>
using namespace xtd;
auto main() -> int {
auto object1 = new_ptr<object>();
auto object2 = new_ptr<object>();
auto object3 = object2;
console::write_line(object1->equals(*object3));
console::write_line(*object1 == *object3);
object3 = object1;
console::write_line(object1->equals(*object3));
console::write_line(*object1 == *object3);
}
// This code produces the following output :
//
// false
// false
// true
// true
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10

Reimplemented from xtd::object.

◆ equals() [2/2]

template<typename object_a_t , typename object_b_t >
static bool xtd::object::equals ( const object_a_t &  object_a,
const object_b_t &  object_b 
)
inlinestaticnoexcept

Determines whether the specified object instances are considered equal.

Parameters
object_aThe first object to compare.
object_bThe second object to compare.
Returns
true if object_a is the same instance as object_b or if both are null references or if object_a(object_b) returns true. otherwise, false.
Examples
The following code example compares different objects.
#include <xtd/console>
using namespace xtd;
auto main() -> int {
string s1 = "Tom";
string s2 = "Carol";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
s1 = "Tom";
s2 = "Tom";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
s1 = "";
s2 = "Tom";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
s1 = "Carol";
s2 = "";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
s1 = "";
s2 = "";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
}
// This code produces the following output :
//
// object::equals("Tom", "Carol") => false
// object::equals("Tom", "Tom") => true
// object::equals("", "Tom") => false
// object::equals("Carol", "") => false
// object::equals("", "") => true
virtual bool equals(const object &obj) const noexcept
Determines whether the specified object is equal to the current object.

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