Icon

Inheritance: java.lang.Object

All Implemented Interfaces: com.aspose.ms.System.ICloneable, com.aspose.ms.System.IDisposable

public final class Icon implements System.ICloneable, System.IDisposable

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.

Constructors

ConstructorDescription
Icon(String fileName)Initializes a new instance of the Icon class from the specified file name.
Icon(InputStream stream)Initializes a new instance of the Icon class from the specified data stream.
Icon(String fileName, Size size)Initializes a new instance of the Icon class of the specified size from the specified file.
Icon(Icon original, Size size)Initializes a new instance of the Icon class and attempts to find a version of the icon that matches the requested size.
Icon(Object type, String resource)Initializes a new instance of the Icon class from a resource in the specified assembly.
Icon(InputStream stream, Size size)Initializes a new instance of the Icon class of the specified size from the specified stream.
Icon(String fileName, int width, int height)Initializes a new instance of the Icon class with the specified width and height from the specified file.
Icon(Icon original, int width, int height)Initializes a new instance of the Icon class and attempts to find a version of the icon that matches the requested size..
Icon(InputStream stream, int width, int height)Initializes a new instance of the Icon class from the specified data stream and with the specified width and height.

Methods

MethodDescription
getHandle()Gets the handle for this Icon.
getHeight()Gets the height of this Icon.
getSize()Gets the size of this Icon.
getWidth()Gets the width of this Icon.
extractAssociatedIcon(String filePath)Returns an icon representation of an image that is contained in the specified file.
fromHandle(byte[] handle)Creates a GDI+ Icon from the specified Windows handle to an icon (HICON).
deepClone()Clones the Icon, creating a duplicate image.
dispose()Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
save(OutputStream outputStream)Saves this Icon to the specified output java.io.InputStream.
toBitmap()Converts this Icon to a GDI+ Bitmap.
toString()Gets a human-readable string that describes the Icon.

Icon(String fileName)

public Icon(String fileName)

Initializes a new instance of the Icon class from the specified file name.

Parameters:

ParameterTypeDescription
fileNamejava.lang.StringThe file to load the Icon from.

Icon(InputStream stream)

public Icon(InputStream stream)

Initializes a new instance of the Icon class from the specified data stream.

Parameters:

ParameterTypeDescription
streamjava.io.InputStreamThe data stream from which to load the Icon.

Icon(String fileName, Size size)

public Icon(String fileName, Size size)

Initializes a new instance of the Icon class of the specified size from the specified file.

Parameters:

ParameterTypeDescription
fileNamejava.lang.StringThe name and path to the file that contains the icon data.
sizeSizeThe desired size of the icon.

Icon(Icon original, Size size)

public Icon(Icon original, Size size)

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

Parameters:

ParameterTypeDescription
originalIconThe Icon from which to load the newly sized icon.
sizeSizeA Size(.getSize) structure that specifies the height and width of the new Icon.

Icon(Object type, String resource)

public Icon(Object type, String resource)

Initializes a new instance of the Icon class from a resource in the specified assembly.

Parameters:

ParameterTypeDescription
typejava.lang.ObjectA Type that specifies the assembly in which to look for the resource.
resourcejava.lang.StringThe resource name to load.

Icon(InputStream stream, Size size)

public Icon(InputStream stream, Size size)

Initializes a new instance of the Icon class of the specified size from the specified stream.

Parameters:

ParameterTypeDescription
streamjava.io.InputStreamThe stream that contains the icon data.
sizeSizeThe desired size of the icon.

Icon(String fileName, int width, int height)

public Icon(String fileName, int width, int height)

Initializes a new instance of the Icon class with the specified width and height from the specified file.

Parameters:

ParameterTypeDescription
fileNamejava.lang.StringThe name and path to the file that contains the Icon data.
widthintThe desired width of the Icon.
heightintThe desired height of the Icon.

Icon(Icon original, int width, int height)

public Icon(Icon original, int width, int height)

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

Parameters:

ParameterTypeDescription
originalIconThe icon to load the different size from.
widthintThe width of the new icon.
heightintThe height of the new icon.

Icon(InputStream stream, int width, int height)

public Icon(InputStream stream, int width, int height)

Initializes a new instance of the Icon class from the specified data stream and with the specified width and height.

Parameters:

ParameterTypeDescription
streamjava.io.InputStreamThe data stream from which to load the icon.
widthintThe width, in pixels, of the icon.
heightintThe height, in pixels, of the icon.

getHandle()

public System.IntPtr getHandle()

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

Value: The Windows handle for the icon.

Returns: com.aspose.ms.System.IntPtr

getHeight()

public int getHeight()

Gets the height of this Icon.

Value: The height of this Icon.

Returns: int

getSize()

public Size getSize()

Gets the size of this Icon.

Value: A Size(.getSize) structure that specifies the width and height of this Icon.

Returns: Size

getWidth()

public int getWidth()

Gets the width of this Icon.

Value: The width of this Icon.

Returns: int

extractAssociatedIcon(String filePath)

public static Icon extractAssociatedIcon(String filePath)

Returns an icon representation of an image that is contained in the specified file.

Parameters:

ParameterTypeDescription
filePathjava.lang.StringThe path to the file that contains an image.

Returns: Icon - The Icon representation of the image that is contained in the specified file.

fromHandle(byte[] handle)

public static Icon fromHandle(byte[] handle)

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

Parameters:

ParameterTypeDescription
handlebyte[]A Windows handle to an icon.

Returns: Icon - The Icon this method creates.

deepClone()

public Object deepClone()

Clones the Icon, creating a duplicate image.

Returns: java.lang.Object - An object that can be cast to an Icon.

dispose()

public void dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

save(OutputStream outputStream)

public void save(OutputStream outputStream)

Saves this Icon to the specified output java.io.InputStream.

Parameters:

ParameterTypeDescription
outputStreamjava.io.OutputStreamThe java.io.InputStream to save to.

toBitmap()

public Bitmap toBitmap()

Converts this Icon to a GDI+ Bitmap.

Returns: Bitmap - A Bitmap that represents the converted Icon.

toString()

public String toString()

Gets a human-readable string that describes the Icon.

Returns: java.lang.String - A string that describes the Icon.