Reputation: 11
I'm using openseadragon to display a pyramid (DZI).
The hi-res image is constructed at runtime and I want the OSD viewer to be updated during the hi-res image construction process.
In order to achieve that, I initialize the DZI hirarcy with blank images (white image). Then, during the construction of the hi-res image, I replace the blank images with new ones (in the server).
How could I update specific tiles on demand? The server can send back to the client information about tiles that are "raedy" (contains real image).
Upvotes: 1
Views: 714
Reputation: 2174
Thanks for the updated question! OSD doesn't have the ability to target a specific tile for resetting, but that might be a good feature to add. I think you could put this after you load OSD:
OpenSeadragon.TileCache.prototype.clearTile = function( tile ) {
OpenSeadragon.console.assert(tile, '[TileCache.clearTilesFor] tile is required');
var tileRecord;
for ( var i = 0; i < this._tilesLoaded.length; ++i ) {
tileRecord = this._tilesLoaded[ i ];
if ( tileRecord.tile === tile ) {
this._unloadTile(tileRecord);
this._tilesLoaded.splice( i, 1 );
return;
}
}
};
...and it should add that functionality. You'd then locate the tile in question and do something like:
viewer.tileCache.clearTile(tile);
I haven't tested that code, but it should work...
The other thing you'll have to deal with is the browser wanting to cache the tile itself because it's the same image when you try to load it the second time. Presumably there's something you can put in the headers to tell the browser that it needs to reload the image every time it asks for it.
Upvotes: 1
Reputation: 2174
Do you just want to fade from a solid color to the image? You can animate the image opacity to achieve this effect, and that would be easier.
If you really want to mess with the image tiles, one possibility would be to edit them directly... assuming you're using the canvas renderer (which is used by default except on IE8) you can access individual tiles and use tile.cacheImageRecord.getRenderedContext()
to get the context for the canvas that holds its data; then you could do whatever you want to it. If you're getting into that, you might want to watch the tile-loaded
events on the viewer so you can edit incoming tiles as they're loaded if needed.
Upvotes: 0