Documentation for tile-drawing event
See original GitHub issueThe new tile-drawing functionality isn’t documented. I’ve been giving it a go via guesswork, looking at the source, and using a debugger, and so far I’ve got:
sd.addHandler(‘tile-drawing’, function(viewer){
ctx = viewer.rendered;
if(ctx){
var width=viewer.tile.size.x ;
var height=viewer.tile.size.y ;
width*=2 ; // ?? tile size is not necessarily canvas size??
height*=2 ; // ?? tile size is not necessarily canvas size??
if(width>0 && height>0){
var imgd = ctx.getImageData(0, 0, width, height);
// Do some Simple image processing
// Draw the ImageData at the given (x,y) coordinates.
ctx.putImageData(imgd, 0, 0);
}
}
}
});
I have 2 issues:
i) Surely there is a better way of setting the width/height of the canvas than multiplying the tile size by 2 (certainly if you just set it to the tile size you don’t process the whole tile canvas … presumably due to tile scaling).
ii) While it works fine at low zoom, it is really slow when you zoom in. Surely the same number of tiles should be rendered (approximately) whatever the zoom?
I presume this is mainly down to me not having any documentation, so thanks in advvance for the help!
Derek
Issue Analytics
- State:
- Created 9 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
tcod.console - Tile Drawing/Printing - python-tcod
A console object containing a grid of characters with foreground/background colors. width and height are the size of the console (in tiles.) order...
Read more >Class: Viewer - OpenSeadragon
The main OpenSeadragon viewer class. Members, Methods, Events. canvas · container · drawer · element · initialPage · navigator ...
Read more >Event reference - MDN Web Docs - Mozilla
Events are fired to notify code of "interesting changes" that may ... The documentation for every event has a table (near the top)...
Read more >Documentation: DevExtreme - JavaScript Tile View Events
Raised only once, after the UI component is initialized. Type: Event. Main article: onInitialized. See Also. Handle Events ...
Read more >TEC Tech Docs | Technical documentation for The Events ...
Articles and tutorials on everything from getting started to customizing the plugins, troubleshooting, integrations and more! The Events Calendar · Event ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have been developing a filtering plugin the last few days. (I hope to be able to publish it soon)
I discovered that you shouldn’t flag the tile as already processed but the context. The reason being that OSD will discard some rendered context to free up memory. When the rendered context of a tile get re-created, you will need to re-perform whatever operation you are doing on it.
So, your code should look like:
Good point… this should definitely be better documented.
Looking at https://github.com/openseadragon/openseadragon/blob/master/src/tile.js#L275-L294 I’d say you want to say
var width = ctx.canvas.width
, which should obviate the need for the*= 2
.Regarding the speed, one possible issue is continually processing the same tiles every frame. You can add a flag to the tile (
viewer.tile._alreadyProcessed = true
or somesuch), and only process tiles that don’t have that.