Class: TiledImage

OpenSeadragon.TiledImage

Handles rendering of tiles for an OpenSeadragon.Viewer. A new instance is created for each TileSource opened.

Constructor

new TiledImage(options)

You shouldn't have to create a TiledImage directly; use OpenSeadragon.Viewer#open or OpenSeadragon.Viewer#addTiledImage instead.
Parameters:
Name Type Description
options Object Configuration for this TiledImage.
Properties
Name Type Attributes Default Description
source OpenSeadragon.TileSource The TileSource that defines this TiledImage.
viewer OpenSeadragon.Viewer The Viewer that owns this TiledImage.
tileCache OpenSeadragon.TileCache The TileCache for this TiledImage to use.
drawer OpenSeadragon.Drawer The Drawer for this TiledImage to draw onto.
imageLoader OpenSeadragon.ImageLoader The ImageLoader for this TiledImage to use.
x Number <optional>
0 Left position, in viewport coordinates.
y Number <optional>
0 Top position, in viewport coordinates.
width Number <optional>
1 Width, in viewport coordinates.
height Number <optional>
Height, in viewport coordinates.
fitBounds OpenSeadragon.Rect <optional>
The bounds in viewport coordinates to fit the image into. If specified, x, y, width and height get ignored.
fitBoundsPlacement OpenSeadragon.Placement <optional>
OpenSeadragon.Placement.CENTER How to anchor the image in the bounds if options.fitBounds is set.
clip OpenSeadragon.Rect <optional>
An area, in image pixels, to clip to (portions of the image outside of this area will not be visible). Only works on browsers that support the HTML5 canvas.
springStiffness Number <optional>
See OpenSeadragon.Options.
animationTime Boolean <optional>
See OpenSeadragon.Options.
minZoomImageRatio Number <optional>
See OpenSeadragon.Options.
wrapHorizontal Boolean <optional>
See OpenSeadragon.Options.
wrapVertical Boolean <optional>
See OpenSeadragon.Options.
immediateRender Boolean <optional>
See OpenSeadragon.Options.
blendTime Number <optional>
See OpenSeadragon.Options.
alwaysBlend Boolean <optional>
See OpenSeadragon.Options.
minPixelRatio Number <optional>
See OpenSeadragon.Options.
smoothTileEdgesMinZoom Number <optional>
See OpenSeadragon.Options.
iOSDevice Boolean <optional>
See OpenSeadragon.Options.
opacity Number <optional>
1 Opacity the tiled image should be drawn at.
compositeOperation String <optional>
How the image is composited onto other images; see compositeOperation in OpenSeadragon.Options for possible values.
debugMode Boolean <optional>
See OpenSeadragon.Options.
placeholderFillStyle String | CanvasGradient | CanvasPattern | function <optional>
See OpenSeadragon.Options.
crossOriginPolicy String | Boolean <optional>
See OpenSeadragon.Options.
Source:

Extends

Methods

addHandler(eventName, handler, userDataopt)

Add an event handler for a given event.
Parameters:
Name Type Attributes Default Description
eventName String Name of event to register.
handler OpenSeadragon.EventHandler Function to call when event is triggered.
userData Object <optional>
null Arbitrary object to be passed unchanged to the handler.
Inherited From:
Source:

addOnceHandler(eventName, handler, userDataopt, timesopt)

Add an event handler to be triggered only once (or a given number of times) for a given event.
Parameters:
Name Type Attributes Default Description
eventName String Name of event to register.
handler OpenSeadragon.EventHandler Function to call when event is triggered.
userData Object <optional>
null Arbitrary object to be passed unchanged to the handler.
times Number <optional>
1 The number of times to handle the event before removing it.
Inherited From:
Source:

destroy()

Destroy the TiledImage (unload current loaded tiles).
Source:

draw()

Draws the TiledImage to its Drawer.
Source:

fitBounds(bounds, anchoropt, immediatelyopt)

Positions and scales the TiledImage to fit in the specified bounds. Note: this method fires OpenSeadragon.TiledImage.event:bounds-change twice
Parameters:
Name Type Attributes Default Description
bounds OpenSeadragon.Rect The bounds to fit the image into.
anchor OpenSeadragon.Placement <optional>
OpenSeadragon.Placement.CENTER How to anchor the image in the bounds.
immediately Boolean <optional>
false Whether to animate to the new size or snap immediately.
Source:
Fires:

getBounds(currentopt) → {OpenSeadragon.Rect}

Parameters:
Name Type Attributes Default Description
current Boolean <optional>
false Pass true for the current location; false for target location.
Source:
Returns:
This TiledImage's bounds in viewport coordinates.
Type
OpenSeadragon.Rect

getClip() → {OpenSeadragon.Rect|null}

Source:
Returns:
The TiledImage's current clip rectangle, in image pixels, or null if none.
Type
OpenSeadragon.Rect | null

getClippedBounds(currentopt) → {$.Rect}

Get the bounds of the displayed part of the tiled image.
Parameters:
Name Type Attributes Default Description
current Boolean <optional>
false Pass true for the current location, false for the target location.
Source:
Returns:
The clipped bounds in viewport coordinates.
Type
$.Rect

getCompositeOperation() → {String}

Source:
Returns:
The TiledImage's current compositeOperation.
Type
String

getContentSize() → {OpenSeadragon.Point}

Source:
Returns:
This TiledImage's content size, in original pixels.
Type
OpenSeadragon.Point

getHandler(eventName)

Get a function which iterates the list of all handlers registered for a given event, calling the handler for each.
Parameters:
Name Type Description
eventName String Name of event to get handlers for.
Inherited From:
Source:

getOpacity() → {Number}

Source:
Returns:
The TiledImage's current opacity.
Type
Number

imageToViewerElementCoordinates(pixel) → {OpenSeadragon.Point}

Convert pixel coordinates relative to the image to viewer element coordinates.
Parameters:
Name Type Description
pixel OpenSeadragon.Point
Source:
Returns:
Type
OpenSeadragon.Point

imageToViewportCoordinates(imageX, imageYopt, currentopt) → {OpenSeadragon.Point}

Translates from image coordinate system to OpenSeadragon viewer coordinate system This method can be called either by passing X,Y coordinates or an OpenSeadragon.Point.
Parameters:
Name Type Attributes Default Description
imageX Number | OpenSeadragon.Point The X coordinate or point in image coordinate system.
imageY Number <optional>
The Y coordinate in image coordinate system.
current Boolean <optional>
false Pass true to use the current location; false for target location.
Source:
Returns:
A point representing the coordinates in the viewport.
Type
OpenSeadragon.Point

imageToViewportRectangle(imageX, imageYopt, pixelWidthopt, pixelHeightopt, currentopt) → {OpenSeadragon.Rect}

Translates from a rectangle which describes a portion of the image in pixel coordinates to OpenSeadragon viewport rectangle coordinates. This method can be called either by passing X,Y,width,height or an OpenSeadragon.Rect.
Parameters:
Name Type Attributes Default Description
imageX Number | OpenSeadragon.Rect The left coordinate or rectangle in image coordinate system.
imageY Number <optional>
The top coordinate in image coordinate system.
pixelWidth Number <optional>
The width in pixel of the rectangle.
pixelHeight Number <optional>
The height in pixel of the rectangle.
current Boolean <optional>
false Pass true to use the current location; false for target location.
Source:
Returns:
A rect representing the coordinates in the viewport.
Type
OpenSeadragon.Rect

imageToViewportZoom(imageZoom) → {Number}

Convert an image zoom to a viewport zoom. Image zoom: ratio of the original image size to displayed image size. 1 means original image size, 0.5 half size... Viewport zoom: ratio of the displayed image's width to viewport's width. 1 means identical width, 2 means image's width is twice the viewport's width... Note: not accurate with multi-image.
Parameters:
Name Type Description
imageZoom Number The image zoom
Source:
Returns:
viewportZoom The viewport zoom
Type
Number

imageToWindowCoordinates(pixel) → {OpenSeadragon.Point}

Convert image coordinates to pixel coordinates relative to the window.
Parameters:
Name Type Description
pixel OpenSeadragon.Point
Source:
Returns:
Type
OpenSeadragon.Point

needsDraw() → {Boolean}

Source:
Returns:
Whether the TiledImage needs to be drawn.
Type
Boolean

raiseEvent(eventName, eventArgs)

Trigger an event, optionally passing additional information.
Parameters:
Name Type Description
eventName String Name of event to register.
eventArgs Object Event-specific data.
Inherited From:
Source:

removeAllHandlers(eventName)

Remove all event handlers for a given event type. If no type is given all event handlers for every event type are removed.
Parameters:
Name Type Description
eventName String Name of event for which all handlers are to be removed.
Inherited From:
Source:

removeHandler(eventName, handler)

Remove a specific event handler for a given event.
Parameters:
Name Type Description
eventName String Name of event for which the handler is to be removed.
handler OpenSeadragon.EventHandler Function to be removed.
Inherited From:
Source:

reset()

Clears all tiles and triggers an update on the next call to OpenSeadragon.TiledImage#update.
Source:

setClip(newClip)

Parameters:
Name Type Description
newClip OpenSeadragon.Rect | null An area, in image pixels, to clip to (portions of the image outside of this area will not be visible). Only works on browsers that support the HTML5 canvas.
Source:

setCompositeOperation(compositeOperation)

Parameters:
Name Type Description
compositeOperation String the tiled image should be drawn with this globalCompositeOperation.
Source:

setHeight(height, immediatelyopt)

Sets the TiledImage's height in the world, adjusting the width to match based on aspect ratio.
Parameters:
Name Type Attributes Default Description
height Number The new height, in viewport coordinates.
immediately Boolean <optional>
false Whether to animate to the new size or snap immediately.
Source:
Fires:

setOpacity(opacity)

Parameters:
Name Type Description
opacity Number Opacity the tiled image should be drawn at.
Source:

setPosition(position, immediatelyopt)

Sets the TiledImage's position in the world.
Parameters:
Name Type Attributes Default Description
position OpenSeadragon.Point The new position, in viewport coordinates.
immediately Boolean <optional>
false Whether to animate to the new position or snap immediately.
Source:
Fires:

setWidth(width, immediatelyopt)

Sets the TiledImage's width in the world, adjusting the height to match based on aspect ratio.
Parameters:
Name Type Attributes Default Description
width Number The new width, in viewport coordinates.
immediately Boolean <optional>
false Whether to animate to the new size or snap immediately.
Source:
Fires:

update() → {Boolean}

Updates the TiledImage's bounds, animating if needed.
Source:
Returns:
Whether the TiledImage animated.
Type
Boolean

viewerElementToImageCoordinates(pixel) → {OpenSeadragon.Point}

Convert pixel coordinates relative to the viewer element to image coordinates.
Parameters:
Name Type Description
pixel OpenSeadragon.Point
Source:
Returns:
Type
OpenSeadragon.Point

viewportToImageCoordinates(viewerX, viewerYopt, currentopt) → {OpenSeadragon.Point}

Translates from OpenSeadragon viewer coordinate system to image coordinate system. This method can be called either by passing X,Y coordinates or an OpenSeadragon.Point.
Parameters:
Name Type Attributes Default Description
viewerX Number | OpenSeadragon.Point The X coordinate or point in viewport coordinate system.
viewerY Number <optional>
The Y coordinate in viewport coordinate system.
current Boolean <optional>
false Pass true to use the current location; false for target location.
Source:
Returns:
A point representing the coordinates in the image.
Type
OpenSeadragon.Point

viewportToImageRectangle(viewerX, viewerYopt, pointWidthopt, pointHeightopt, currentopt) → {OpenSeadragon.Rect}

Translates from a rectangle which describes a portion of the viewport in point coordinates to image rectangle coordinates. This method can be called either by passing X,Y,width,height or an OpenSeadragon.Rect.
Parameters:
Name Type Attributes Default Description
viewerX Number | OpenSeadragon.Rect The left coordinate or rectangle in viewport coordinate system.
viewerY Number <optional>
The top coordinate in viewport coordinate system.
pointWidth Number <optional>
The width in viewport coordinate system.
pointHeight Number <optional>
The height in viewport coordinate system.
current Boolean <optional>
false Pass true to use the current location; false for target location.
Source:
Returns:
A rect representing the coordinates in the image.
Type
OpenSeadragon.Rect

viewportToImageZoom(viewportZoom) → {Number}

Convert a viewport zoom to an image zoom. Image zoom: ratio of the original image size to displayed image size. 1 means original image size, 0.5 half size... Viewport zoom: ratio of the displayed image's width to viewport's width. 1 means identical width, 2 means image's width is twice the viewport's width...
Parameters:
Name Type Description
viewportZoom Number The viewport zoom
Source:
Returns:
imageZoom The image zoom
Type
Number

windowToImageCoordinates(pixel) → {OpenSeadragon.Point}

Convert pixel coordinates relative to the window to image coordinates.
Parameters:
Name Type Description
pixel OpenSeadragon.Point
Source:
Returns:
Type
OpenSeadragon.Point

Events

bounds-change

Raised when the TiledImage's bounds are changed. Note that this event is triggered only when the animation target is changed; not for every frame of animation.
Type:
  • object
Properties:
Name Type Attributes Description
eventSource OpenSeadragon.World A reference to the TiledImage which raised the event.
userData Object <nullable>
Arbitrary subscriber-defined object.
Source: