canvas Property

Summary

The HTML5 Canvas Element associated with this item.

Syntax

JavaScript Syntax
Object.defineProperty(ImageViewerItem.prototype, 'canvas', 
	get: function(), 
	set: function(value) 
) 
TypeScript Syntax
canvas: HTMLCanvasElement; 

Property Value

The canvas associated with this item. Default value is null.

Remarks

The item can have a value in only one of Image, Element or Canvas. Setting one value will automatically delete the values of the others. Element accepts any element, but may still be null after the set operation. An HTML Image Element set to Element will actually be set to Image, and an HTML5 Canvas Element set to Element will actually be set to Canvas.

Changing the value of this property will fire the ItemChanged event with ImageViewerItemChangedReason.Image. The value of Resolution will not be automatically updated with the DPI of the new image. The user must set this value manually.

Canvas property of ImageViewer will update this member if this is the active item when the viewer is used in single item mode.

For more information, refer to Image Viewer Items.

Example

JavaScript Example
var canvas = document.createElement("canvas"); 
canvas.width = 150; 
canvas.height = 150; 
var context = canvas.getContext("2d"); 
context.fillStyle = "rgba(0, 0, 255, .5)"; 
context.fillRect(25, 25, 100, 100); 
 
var item = new lt.Controls.ImageViewerItem(); 
item.size = lt.LeadSizeD.create(canvas.width, canvas.height); 
item.text = "Item # 1"; 
item.canvas = canvas; 
 
this._imageViewer.beginUpdate(); 
this._imageViewer.items.add(item); 
this._imageViewer.endUpdate(); 

Requirements

Target Platforms

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Controls Assembly