Class: OpenSeadragonImageRenderer
Defined in: openseadragon/OpenSeadragonImageRenderer.ts:49
Renderer for the tiled images of Image data objects
Multi-channel image data provides one tiled image per channel, whose tiles carry the channel's values rather than colors. Each channel is recolored by a data transfer (see OpenSeadragonContext.updateTiledImageDataTransfer) that scales the values between the channel's contrast limits and multiplies them with the channel's color. Color and contrast limits are taken from the image's channel settings, falling back to those reported by the image data; channels without a color use a default color for their channel index (see ImageUtils.getDefaultChannelColor), and channels without contrast limits use the value range of their data type. Channels whose data does not provide values are drawn as they are, as is image data that is not multi-channel. Channel visibility and opacity are not part of the transfer: like layer and image opacity, OpenSeadragon applies them when drawing the tiled image (see getTiledImageOpacity).
As data transfers are compared by identity, each channel's data transfer is kept (see resolveObject) until the image's data or the channel's color or contrast limits change, so that tiles are only recolored when needed.
Extends
Constructors
Constructor
new OpenSeadragonImageRenderer(
context,onInitialized,onError,options?):OpenSeadragonImageRenderer
Defined in: openseadragon/OpenSeadragonRendererBase.ts:69
Creates a new OpenSeadragonRendererBase instance and asynchronously adds its anchor
The renderer must not be used before onInitialized has been called;
onError is called instead if adding the anchor failed or was aborted.
Parameters
context
The OpenSeadragon context that provides access to the viewer and other shared state
onInitialized
() => void
Called once the anchor has been added to the world
onError
(error) => void
Called if the anchor could not be added
options?
Optional abort signal and world index at which to insert the anchor
anchorIndex?
number
signal?
AbortSignal
Returns
OpenSeadragonImageRenderer
Inherited from
OpenSeadragonRendererBase< Image, ImageData, OpenSeadragonImageSyncContext >.constructor
Properties
context
readonlycontext:OpenSeadragonContext
Defined in: openseadragon/OpenSeadragonRendererBase.ts:51
Inherited from
OpenSeadragonRendererBase.context
Methods
destroy()
destroy():
Promise<void>
Defined in: openseadragon/OpenSeadragonRendererBase.ts:215
Destroys the renderer by removing the anchor tiled image and all rendered objects from the OpenSeadragon viewer
Rendered objects whose tiled images have not been added to the world yet are only marked for deletion, and are removed as soon as they arrive.
The renderer is unusable afterwards: it has no anchor anymore, so updateBounds does nothing, _cleanRenderedObjects throws, and tiled images that still arrive are removed right away.
Returns
Promise<void>
Inherited from
OpenSeadragonRendererBase.destroy
getTiledImageDataTransfer()
protectedgetTiledImageDataTransfer(ref,index):DataTransfer|undefined
Defined in: openseadragon/OpenSeadragonImageRenderer.ts:217
Returns the data transfer resolved for one of an image's tiled images
Only the tiled images of an image's channels are recolored, never its backdrop.
Parameters
ref
The image reference for which to get the data transfer
index
number | null
The index of the tiled image (channel), or null for the image's backdrop
Returns
DataTransfer | undefined
The channel's data transfer resolved by resolveObject,
or undefined if the channel has none
Overrides
OpenSeadragonRendererBase.getTiledImageDataTransfer
getTiledImageOpacity()
protectedgetTiledImageOpacity(ref,index):number
Defined in: openseadragon/OpenSeadragonImageRenderer.ts:190
Computes the effective opacity for one of an image's tiled images
Multiplies the layer and image opacity computed by the base class with the visibility and opacity of the channel that the tiled image renders. Channels are only applied to multi-channel image data, and channels that the image does not define are visible at full opacity. Without a channel index, i.e. for the image's backdrop, the layer and image opacity is returned as is.
Parameters
ref
The image reference for which to compute the opacity
index
number | null
The index of the tiled image (channel), or null for the image's backdrop
Returns
number
The effective opacity for the tiled image
Overrides
OpenSeadragonRendererBase.getTiledImageOpacity
getTileSources()
protectedgetTileSources(data): (string|object|CustomTileSource)[]
Defined in: openseadragon/OpenSeadragonImageRenderer.ts:146
Returns the tile sources for the given image data
Multi-channel image data provides one tile source per channel, in channel order; all other image data provides a single tile source.
Parameters
data
The image data for which to retrieve the tile sources
Returns
(string | object | CustomTileSource)[]
The tile sources, one per channel for multi-channel image data and a single one otherwise
Overrides
OpenSeadragonRendererBase.getTileSources
resolveObject()
protectedresolveObject(image,data):Promise<void>
Defined in: openseadragon/OpenSeadragonImageRenderer.ts:93
Resolves the data transfers of an image's channels, unless they are up to date
Image data that is not multi-channel has no channels to resolve. Otherwise, each channel's color and contrast limits are resolved from the image's channel settings, falling back to those reported by the data, and its data transfer is kept as long as the image's data and the resolved values are unchanged, and is created anew otherwise (see _createDataTransfer). Channels are resolved independently, so that changing one channel only recolors the tiles of that channel.
Parameters
image
The image to resolve
data
The loaded data of the image
Returns
Promise<void>
A promise that resolves once the data transfers have been resolved
Overrides
OpenSeadragonRendererBase.resolveObject
retainObjects()
protectedretainObjects(images):void
Defined in: openseadragon/OpenSeadragonImageRenderer.ts:70
Drops the data transfers of all images other than the given ones
Parameters
images
Image[]
The images about to be displayed
Returns
void
Overrides
OpenSeadragonRendererBase.retainObjects
setExtraBounds()
setExtraBounds(
bounds):void
Defined in: openseadragon/OpenSeadragonRendererBase.ts:201
Sets additional bounds to be covered by the anchor
Used to include content that is not rendered by OpenSeadragon (e.g. points and shapes rendered with WebGL) in the viewer's world bounds. Takes effect on the next updateBounds call.
Parameters
bounds
Rect[]
Additional bounds, in world coordinates
Returns
void
Inherited from
OpenSeadragonRendererBase.setExtraBounds
synchronize()
synchronize(
layers,objects,context,options?):Promise<void>
Defined in: openseadragon/OpenSeadragonRendererBase.ts:106
Synchronizes the viewer's tiled images with the current model state
Loads all objects assigned to the given layers, removes the tiled images that are no longer needed, and creates or updates the remaining ones. Resolves once the tiled images have actually been added to the world, i.e. once the viewer reflects the given model state.
Objects whose tiled images cannot be created, e.g. because their data provides no tile sources, are logged and skipped, just like objects whose data failed to load (see _loadObjects).
Parameters
layers
Layer[]
Layers to render
objects
Image[]
Objects (images or labels) to display
context
OpenSeadragonImageSyncContext
The inputs to synchronize with: an immutable snapshot of the model state and loaders that the renderer needs. It carries inputs only; a renderer that derives state from an object does so in resolveObject.
options?
Optional abort signal
signal?
AbortSignal
Returns
Promise<void>
Inherited from
OpenSeadragonRendererBase.synchronize
updateBounds()
updateBounds(
options?):Promise<void>
Defined in: openseadragon/OpenSeadragonRendererBase.ts:164
Resizes the anchor to the bounding box of all tiled images and extra bounds
Rendered objects whose tiled images have not been added to the world yet are ignored; they update the anchor themselves upon arrival (see _createRenderedObject). Does nothing once the renderer has been destroyed, as there is no anchor to resize anymore.
Parameters
options?
Optional abort signal
signal?
AbortSignal
Returns
Promise<void>
Inherited from
OpenSeadragonRendererBase.updateBounds
usesAdditiveBlending()
protectedusesAdditiveBlending(data):boolean
Defined in: openseadragon/OpenSeadragonImageRenderer.ts:173
Returns whether the channels of the given image data are blended additively
Multi-channel image data blends additively, so that its channels add up rather than hide one another. Image data that is not multi-channel has a single tile source, so there is nothing to add up, and it keeps OpenSeadragon's default compositing, which preserves the transparency of its tiles.
Parameters
data
The image data to check
Returns
boolean
Whether the image's channels are blended additively
Overrides
OpenSeadragonRendererBase.usesAdditiveBlending