Class Image
Definition
- Namespace:
- ElmSharp
- Assembly:
- ElmSharp.dll
The Image is a widget that allows one to load and display an image file on it, be it from a disk file or from a memory region. Inherits Widget.
C#Copypublic class Image : Widget, IAccessibleObject
- Inheritance
- Derived
- Implements
Constructors
Declaration
C#Copypublic Image(EvasObject parent)
Parameters
| Type | Name | Description |
|---|---|---|
| EvasObject | parent | The parent is a given container, which will be attached by the image as a child. It's EvasObject type. |
Properties
Declaration
C#Copypublic override Color BackgroundColor { set; }
Property Value
| Type | Description |
|---|---|
| Color |
Overrides
BorderCenterFillMode
Sets or gets if the center part of the given image object (not the border) should be drawn.
Declaration
C#Copypublic ImageBorderFillMode BorderCenterFillMode { get; set; }
Property Value
| Type | Description |
|---|---|
| ImageBorderFillMode |
Remarks
When rendering, the image may be scaled to fit the size of the image object. This function sets if the center part of the scaled image is to be drawn or left completely blank, or forced to be solid. Very useful for frames and decorations.
CanFillOutside
Sets or gets whether the image fills the entire object area, when keeping the aspect ratio.
Declaration
C#Copypublic bool CanFillOutside { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Declaration
C#Copypublic bool CanScaleDown { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Declaration
C#Copypublic bool CanScaleUp { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Declaration
C#Copypublic override Color Color { get; set; }
Property Value
| Type | Description |
|---|---|
| Color |
Overrides
Declaration
C#Copypublic string File { get; }
Property Value
| Type | Description |
|---|---|
| string |
ImageObject
Gets the inlined image object of the image widget. This property allows one to get the underlying EvasObject of type Image from this elementary widget. It can be useful to do things like save the image to a file, etc.
Declaration
C#Copypublic EvasImage ImageObject { get; }
Property Value
| Type | Description |
|---|---|
| EvasImage |
Remarks
Be careful not to manipulate it, as it is under the control of the widget.
IsAnimated
Sets or gets whether an image object (which supports animation) is to animate itself.
Declaration
C#Copypublic bool IsAnimated { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Declaration
C#Copypublic bool IsAnimatedAvailable { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Declaration
C#Copypublic bool IsAnimationPlaying { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
An image object, even if it supports animation, will be displayed by default without animation. To actually start playing any image object's animation, IsAnimated should be TRUE before setting this property true.
Declaration
C#Copypublic bool IsEditable { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
IsFixedAspect
Sets or gets whether the original aspect ratio of the image should be kept on resize.
Declaration
C#Copypublic bool IsFixedAspect { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
IsOpaque
Sets or gets whether the alpha channel data is being used on the given image object.
Declaration
C#Copypublic bool IsOpaque { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Declaration
C#Copypublic bool IsScaling { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Declaration
C#Copypublic bool IsSmooth { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Declaration
C#Copypublic Size ObjectSize { get; }
Property Value
| Type | Description |
|---|---|
| Size |
Declaration
C#Copypublic ImageOrientation Orientation { get; set; }
Property Value
| Type | Description |
|---|---|
| ImageOrientation |
Declaration
C#Copypublic int PrescaleSize { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
Declaration
C#Copyprotected override IntPtr CreateHandle(EvasObject parent)
Parameters
| Type | Name | Description |
|---|---|---|
| EvasObject | parent | The parent is a given container, which will be attached by the image as a child. It's EvasObject type. |
Returns
| Type | Description |
|---|---|
| System.IntPtr | The new object, otherwise null if it cannot be created. |
Overrides
Declaration
C#Copypublic override Color GetPartColor(string part)
Parameters
| Type | Name | Description |
|---|---|---|
| string | part | The name of the Color class. |
Returns
| Type | Description |
|---|---|
| Color | The color object. |
Overrides
Load(byte*, long)
Sets a location in the memory to be used as an image object's source bitmap.
Declaration
C#Copy[Obsolete("This method will be removed. Use Load(Stream stream) instead.")] public bool Load(byte* img, long size)
Parameters
| Type | Name | Description |
|---|---|---|
| byte* | img | The binary data that is used as an image source. |
| long | size | The size of the binary data blob img. |
Returns
| Type | Description |
|---|---|
| bool | (true = success, false = error) |
Remarks
This function is handy when the contents of an image file are mapped into the memory, for example, the format string should be something like "png", "jpg", "tga", "tiff", "bmp" etc, when provided (null, on the contrary). This improves the loader performance as it tries the "correct" loader first, before trying a range of other possible loaders until one succeeds.
Declaration
C#Copypublic bool Load(Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| System.IO.Stream | stream | The stream that is used as an image source. |
Returns
| Type | Description |
|---|---|
| bool | (true = success, false = error) |
Declaration
C#Copypublic bool Load(string file)
Parameters
| Type | Name | Description |
|---|---|---|
| string | file | The path to the file that is used as an image source. |
Returns
| Type | Description |
|---|---|
| bool | (true = success, false = error) |
Declaration
C#Copypublic bool Load(Uri uri)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Uri | uri | The URI to the file that is used as an image source. |
Returns
| Type | Description |
|---|---|
| bool | (true = success, false = error) |
LoadAsync(Stream, CancellationToken)
Sets the stream that is used as the image's source with async.
Declaration
C#Copypublic Task<bool> LoadAsync(Stream stream, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| System.IO.Stream | stream | The stream that is used as an image source. |
| System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<TResult><bool> | (true = success, false = error) |
LoadAsync(string, CancellationToken)
Sets the file that is used as the image's source with async.
Declaration
C#Copypublic Task<bool> LoadAsync(string file, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | file | The path to the file that is used as an image source. |
| System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<TResult><bool> | (true = success, false = error) |
LoadAsync(Uri, CancellationToken)
Sets the URI that is used as the image's source with async.
Declaration
C#Copypublic Task<bool> LoadAsync(Uri uri, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Uri | uri | The URI to the file that is used as an image source. |
| System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<TResult><bool> | (true = success, false = error) |
SetBorder(int, int, int, int)
Sets the dimensions for an image object's border, a region which is not scaled together with its center ever.
Declaration
C#Copypublic void SetBorder(int left, int right, int top, int bottom)
Parameters
| Type | Name | Description |
|---|---|---|
| int | left | The border's left width. |
| int | right | The border's right width. |
| int | top | The border's top width. |
| int | bottom | The border's bottom width. |
Declaration
C#Copypublic override void SetPartColor(string part, Color color)
Parameters
| Type | Name | Description |
|---|---|---|
| string | part | The name of the Color class. |
| Color | color | The struct of the Color class. |
Overrides
Events
Declaration
C#Copypublic event EventHandler Clicked
Event Type
| Type | Description |
|---|---|
| System.EventHandler |
LoadingCompleted
LoadingCompleted will be triggered when the image is loaded completely.
Declaration
C#Copypublic event EventHandler LoadingCompleted
Event Type
| Type | Description |
|---|---|
| System.EventHandler |
Declaration
C#Copypublic event EventHandler LoadingFailed
Event Type
| Type | Description |
|---|---|
| System.EventHandler |