Updates the HTML Image Element of an item.
ImageViewerItems.prototype.updateImage =function(
item,
image,
resolution
)
updateImage(
item:ImageViewerItem,
image: HTMLImageElement,
resolution:LeadSizeD
):void;
item
Item to update
image
New HTML Image Element. If this isnull, then the item will be empty after this method returns.
resolution
The resolution to use of the image in dots/inch (or DPI). A value of 0,0 orEmptymeans use the default image resolution which is 96 pixels.
This method is a shortcut for updating theImageandResolutionproperties. It is equivalent to:
item.image = image;
item.resolution = resolution;
UpdateElementis a shortcut for updating not onlyImage, but alsoElement, andCanvas. Passing a valid HTML Image Element toUpdateElementsets theImageproperty just asUpdateImagedoes. Similarly, passing a valid HTML5 Canvas Element toUpdateElementsets theCanvasproperty just asUpdateCanvasdoes. The item can have a value in only one ofImage,ElementorCanvas. Setting one value will automatically delete the values of the others.
This example updates the active item's url with a new image.
import{ ImageViewer_Example } from"../ImageViewer";
exportclassImageViewerItems_UpdateImageExample {
privateviewerExample;
constructor() {
this.viewerExample =newImageViewer_Example(this.run);
}
privaterun = (viewer: lt.Controls.ImageViewer) => {
constimg = document.createElement("img");
img.onload = () => {
viewer.items.updateImage(viewer.activeItem, img, lt.LeadSizeD.create(96, 96));
};
img.src ="https://demo.leadtools.com/images/png/pngimage.png";
}
}
exportclassImageViewer_Example {
// LEADTOOLS ImageViewer to be used with this example
protectedimageViewer: lt.Controls.ImageViewer =null;
// Generic state value used by the examples
publictimesClicked:number= 0;
constructor(callback?: (viewer: lt.Controls.ImageViewer) =>void) {
// Set the LEADTOOLS license. Replace this with your actual license file
lt.RasterSupport.setLicenseUri("https://demo.leadtools.com/licenses/js/LEADTOOLSEVAL.txt","EVAL",null);
// Create an image viewer inside the imageViewerDiv element
constimageViewerDiv = document.getElementById("imageViewerDiv");
constcreateOptions: lt.Controls.ImageViewerCreateOptions =newlt.Controls.ImageViewerCreateOptions(imageViewerDiv);
this.imageViewer =newlt.Controls.ImageViewer(createOptions);
this.imageViewer.viewVerticalAlignment = lt.Controls.ControlAlignment.center;
this.imageViewer.viewHorizontalAlignment = lt.Controls.ControlAlignment.center;
this.imageViewer.autoCreateCanvas =true;
// Add Pan/Zoom interactive mode
// Click and drag to pan, CTRL-Click and drag to zoom in and out
this.imageViewer.interactiveModes.add(newlt.Controls.ImageViewerPanZoomInteractiveMode());
// Load an image
this.imageViewer.imageUrl ="https://demo.leadtools.com/images/jpeg/cannon.jpg";
this.imageViewer.zoom(lt.Controls.ControlSizeMode.fit, .9,this.imageViewer.defaultZoomOrigin);
constexampleButton = document.getElementById("exampleButton");
exampleButton.addEventListener("click", () => {
this.timesClicked++;
// Run the example
if(callback)
callback(this.imageViewer);
});
}
}
import{ ImageViewer_Example } from"../ImageViewer";
exportclassImageViewerItems_UpdateImageExample {
viewerExample;
constructor() {
this.viewerExample =newImageViewer_Example(this.run);
}
run = (viewer) => {
constimg = document.createElement("img");
img.onload = () => {
viewer.items.updateImage(viewer.activeItem, img, lt.LeadSizeD.create(96, 96));
};
img.src ="https://demo.leadtools.com/images/png/pngimage.png";
}
}
exportclassImageViewer_Example {
// LEADTOOLS ImageViewer to be used with this example
imageview =null;
// Generic state value used by the examples
timesClicked = 0;
constructor(callback) {
// Set the LEADTOOLS license. Replace this with your actual license file
lt.RasterSupport.setLicenseUri("https://demo.leadtools.com/licenses/js/LEADTOOLSEVAL.txt","EVAL",null);
// Create an image viewer inside the imageViewerDiv element
constimageViewerDiv = document.getElementById("imageViewerDiv");
constcreateOptions =newlt.Controls.ImageViewerCreateOptions(imageViewerDiv);
this.imageViewer =newlt.Controls.ImageViewer(createOptions);
this.imageViewer.viewVerticalAlignment = lt.Controls.ControlAlignment.center;
this.imageViewer.viewHorizontalAlignment = lt.Controls.ControlAlignment.center;
this.imageViewer.autoCreateCanvas =true;
// Add Pan/Zoom interactive mode
// Click and drag to pan, CTRL-Click and drag to zoom in and out
this.imageViewer.interactiveModes.add(newlt.Controls.ImageViewerPanZoomInteractiveMode());
// Load an image
this.imageViewer.imageUrl ="https://demo.leadtools.com/images/jpeg/cannon.jpg";
this.imageViewer.zoom(lt.Controls.ControlSizeMode.fit, .9,this.imageViewer.defaultZoomOrigin);
constexampleButton = document.getElementById("exampleButton");
exampleButton.addEventListener("click", () => {
this.timesClicked++;
// Run the example
if(callback)
callback(this.imageViewer);
});
}
}
"en">
Controls Example | UpdateImage body {
font-family:'Segoe UI', sans-serif;
}
#imageViewerDiv {
border: 1px solid #888;
width: 500px;
height: 500px;
background-color: #eee;
}
Press and drag on the image to pan.
Hold down the control key and press and drag on the image or pinchwithtwo fingers to zoominand out.
"imageViewerDiv">
"output">window.onload = () => {
constexample =newwindow.examples.ImageViewerItems.UpdateImage();
};
Help Collections
Raster.NET|C API|C++ Class Library|HTML5 JavaScript
Document.NET|C API|C++ Class Library|HTML5 JavaScript
Medical.NET|C API|C++ Class Library|HTML5 JavaScript
Medical Web Viewer.NET
188宝金博怎么下载
Media Foundation.NET|C API|Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.