Hey, and thanks for this awesome project
I have a javascript app where the user sees a list of images. He can select an image, and the viewer loads the selected image.
For better performance, I would like to preload the first tiles that the OSD would request from the image server when requested to load an image.
Is there a way to understand what these tiles would be before loading the image into the viewer?
There's no way to do that outside of a viewer. You can preload tiles once the image has been added to a viewer... For instance if you add an image with 0 opacity and a preload of true, it'll load the tiles even though the image isn't visible.
So, one approach is to load all of the images into the viewer at once but set all but one to opacity 0 (with preload on). If that doesn't work for your scenario, you could make a hidden viewer (just position it offscreen or something) and add the images there.
As a feature request (adding something like this to OSD), it seems worth considering, though I'm not quite sure what the API would be for it.
Hope this helps!
@iangilman thanks for the answer! I see iI can use addTiledImage to add an image with opacity 0. How can I later change the opacity to 1? Couldn't find a way to do it with the API.
The "world" holds all the tiled images. If you want to target the first image, it would be:
viewer.world.getItemAt(0).setOpacity(1);