Error processing SSI file
LEADTOOLS JavaScript (Leadtools.Controls)

AutoCreateCanvas Property (ImageViewerItem)

Show in webframe
Example 
Indicates whether to automatically create an HTML5 Canvas Element when the image is updated.
Syntax
get_autoCreateCanvas();
set_autoCreateCanvas(value);
Object.defineProperty('autoCreateCanvas');

Property Value

TypeDescription
booleantrue to automatically create the canvas when the image is updated; otherwise, false. Default value is false.
Remarks

ImageViewerItem supports using an HTML Image Element (in the Image property), an HTML5 Canvas Element (in the Canvas property), or other HTML Elements and SVG Elements (in the Element property). The automatic creation of an HTML5 Canvas Element is not supported when Element is being used.

Using an img generally consumes less system resources, supports larger sizes, takes advantage of browser caching, and is not affected by cross-origin security policy. However, the image data is read-only and cannot be changed directly.

Using a canvas might consume more system resources, have limited size in some platforms, does not use the browser caching and is affected by cross-origin browser security policy. However, the image data is read-write and can be changed directly using the HTML5 Canvas Element drawing context.

If using a canvas is always desired, the user can create the canvas outside of the ImageViewer and populate it with the image data. Or, the user can set the value of AutoCreateCanvas to true and set the image element (or URL) into the ImageViewerItem. In this mode, the viewer will create the HTML5 Canvas Element and populate with the image data, then set it in the Canvas property; the original img is discarded.

As mentioned above, an HTML5 Canvas Element might have size limitation depending on the current platform and number of current canvas elements in the page. ImageViewer can automatically adjust the size of a large canvas using the global CanvasOptions class as follows:

Example
// move the following line to _imageViewer create section...
this._imageViewer.autoCreateCanvas = true;

// now, back to the example...
var canvas = this._imageViewer.canvas;
var context = canvas.getContext("2d");
context.fillStyle = "rgba(0, 0, 0, .5)";
context.fillRect(25, 25, 125, 125);

this._imageViewer.invalidate(lt.LeadRectD.create(25, 25, 125, 125));
See Also

Reference

ImageViewerItem Object
ImageViewerItem Members

Error processing SSI file