interpolationMode Property

Summary

Interpolation mode used by this ImageViewer.

Syntax

JavaScript Syntax
Object.defineProperty(ImageViewer.prototype, 'interpolationMode', 
	get: function(), 
	set: function(value) 
) 
TypeScript Syntax
interpolationMode: InterpolationMode; 

Property Value

The interpolation mode used by this ImageViewer. Default value is InterpolationMode.None.

Remarks

For more information, refer to Image Viewer Interpolation.

Example

Run the below demo and as you click the "Example" button, the viewer will cycle through the interpolation modes.

Start with the ImageViewer example, remove all the code inside the example function (search for the "// TODO: add example code here" comment) and insert the following code

JavaScript Example
var _interpolationModeNames = ["None", "Resample", "ScaleToGray"]; 
var _interpolationModeStatus = ["Started", "Completed", "Aborted", "Error"]; 
 
var urls = [ 
   "http://demo.leadtools.com/images/png/ocr1.png", 
   "http://demo.leadtools.com/images/png/ocr2.png", 
   "http://demo.leadtools.com/images/png/ocr3.png", 
   "http://demo.leadtools.com/images/png/ocr4.png" 
]; 
 
// Optional: tell the imageViewer to interpolate in parallel 
this._imageViewer.interpolationRunMode = lt.Controls.InterpolationRunMode.Parallel; 
 
this._imageViewer.beginTransform(); 
for (var urlIndex = 0; urlIndex < urls.length; urlIndex++) { 
   var item = new lt.Controls.ImageViewerItem(); 
   item.text = "Item" + urlIndex; 
   item.resolution = lt.LeadSizeD.create(300, 300); 
   item.url = urls[urlIndex]; 
   this._imageViewer.items.add(item); 
} 
this._imageViewer.endTransform(); 
 
this._imageViewer.interpolation.add(function (sender, e) { 
   var itemIndex = this._imageViewer.items.indexOf(e.item); 
   alert("Interpolation Item(" + itemIndex + ") ," + _interpolationModeNames[e.mode] + " " + _interpolationModeStatus[e.status]); 
   if (e.status == lt.Controls.InterpolationStatus.error) { 
      alert("  Error name:" + e.error.name + " message:" + e.error.message); 
   } 
}); 
 
var interpolationModes = [lt.Controls.InterpolationMode.none, lt.Controls.InterpolationMode.resample, lt.Controls.InterpolationMode.scaleToGray]; 
 
// Add a combobox control to show the items 
var comboBox = document.getElementById("combo"); 
 
for (var index = 0; index < interpolationModes.length; index++) { 
   var value = interpolationModes[index]; 
   var option = document.createElement("option"); 
   option.textContent = _interpolationModeNames[value]; 
   comboBox.appendChild(option); 
} 
 
var myImageViewer = this._imageViewer; 
comboBox.addEventListener("change", function () { 
   var index = comboBox.selectedIndex; 
 
   switch (index) { 
      case 0: 
         myImageViewer.interpolationMode = lt.Controls.InterpolationMode.none; 
         break; 
      case 1: 
         myImageViewer.interpolationMode = lt.Controls.InterpolationMode.resample; 
         break; 
      case 2: 
         myImageViewer.interpolationMode = lt.Controls.InterpolationMode.scaleToGray; 
         break; 
   } 
}); 

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