TW3Image



TW3Image


Represents class for image component. This component may be also used as standalone component, but it is used within other components too.


Unit: SmartCL.Controls.Image.pas

Hierarchy
TObject
TW3TagObj
TW3Component
TW3MovableControl
TW3CustomControl
TW3Image
Properties
Property-icon.png Ready
Property-icon.png Url
Methods
Method-icon.png LoadFromURL
Method-icon.png toDataUrl
Method-icon.png toImageData
Events
Event-icon.png OnLoad

Properties

Property-icon.png Ready

Determine whether image is completely loaded.

property Ready: Boolean read getReady;

Property-icon.png Url

Specifies address (path) of loaded image.

property Url: String read getSrc write setSrc;

If URL differ from currently loaded image, LoadFromURL method will be called in order to load new image.

Methods

Method-icon.png LoadFromURL

Start loading image from address.

procedure LoadFromURL(aURL: String);

Parameters:

aURL

String
Remote or local path to image.


Example:

W3Image1.LoadFromURL('http://www.mysite.com/folder/my_image.jpg');

To load image from your local resources sub-folder, write:

W3Image1.LoadFromURL('res/my_image.jpg'); // notice res/ part.

If image is successfully loaded, OnLoad event will occur. At that point is safe to do further actions with your image.

Method-icon.png toDataUrl

Returns a string representing the canvas image (by calling datatoDataURL DOM method).

function toDataUrl: String;

Example partial output:

url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAARQAAAAfCAYAAAAmwDIOAAAGyklEQVR42u2da3NURRCGD1HIhktQEiEXbhFCDBcBQQRchBgiEMArKkQ+4P//EfjGaqpP5a1TT50drGRxPjw7PWf6Nt1zpli2Cpq3b98mzqS4JDbFlvh7j/KmXL88fsqsV563P69A3...

Method-icon.png toImageData

Returns TW3ImageData representation of Image.

function ToImageData: TW3ImageData;

TW3ImageData object provide access to the individual pixels of image.

Events

Event-icon.png OnLoad

Occurs after image set via LoadFromURL method is fully loaded (Handle is allocated and size is set).

property OnLoad: TNotifyEvent read FOnLoad write _setOnLoad;