These are chat archives for openseadragon/openseadragon

25th
Apr 2017
sohaib
@sohaib_ghani_twitter
Apr 25 2017 05:15
@iangilman Image smoothing disabling is working fine but it has one issue. Whenever I resize the window or open console window the image automatically changes to the imagesmoothing enabled one. How can i avoid that? On reload it started working fine until i do anything with the window. Thanks
sohaib
@sohaib_ghani_twitter
Apr 25 2017 13:11
@iangilman I am getting a strange result. I disabled the image smoothing and the code runs well on my laptop. The same code when runs on my desktop it is not disabling the image smoothing. I printed the viewer on console to check and it shows that image smoothing is enabled even though i have explicitly disabled it.
console.log( viewer.drawer.context.imageSmoothingEnabled); return false, but
console.log(viewer); is showing that imageSmoothingEnabled is true.
I am not resizing the window as i know that resizing the window again loads default canvas setting. I am confused what it is doing because the same code is disabling the image smoothing on my laptop and console print also confirm it. I am using same windows and same chrome on both the machines. Please advise me what could be the problem? Is there anyway to disable the image smoothing in chrome permanently?
Waiting for your response. Thanks
Ian Gilman
@iangilman
Apr 25 2017 16:42
@sohaib_ghani_twitter Wow, that's very strange! OpenSeadragon doesn't do anything with imageSmoothingEnabled, so maybe it's something the browser is doing? You might try making a simple test case with canvas but without OpenSeadragon to see if you can reproduce the issue that way.
You could try resetting the value constantly with requestAnimationFrame or something, though of course that's just a hack
Ian Gilman
@iangilman
Apr 25 2017 16:54
According to http://stackoverflow.com/a/29564875/306351 imageSmoothingEnabled gets reset by the browser every time you resize your canvas, so you'd need to set it back every time. The trick is knowing when the canvas changes size. It just sort of does it automatically here: https://github.com/openseadragon/openseadragon/blob/master/src/drawer.js#L250

...but it probably coincides with the viewer's "resize" event, so something like this might work:

viewer.addHandler('resize', function() {
  viewer.drawer.context.imageSmoothingEnabled = false;
});

If that doesn't work, you might need to add a short setTimeout, like so:

viewer.addHandler('resize', function() {
  setTimeout(function() {
    viewer.drawer.context.imageSmoothingEnabled = false;
  }, 1);
});
Ian Gilman
@iangilman
Apr 25 2017 17:00
Another option would be to actually patch OSD to reset the imageSmoothingEnabled every time the canvas changes size. It seems like a reasonable addition to the API if you wanted to submit such a patch...
sohaib
@sohaib_ghani_twitter
Apr 25 2017 19:54
Thanks @iangilman. I was thinking on the same line for window resize problem. Hopefully, as you suggested it will be solved.
My question is that i am explicitly disabling the image smoothing and still it is not disabled. I tried on three other machines and the problem persists. I dont know why it is running fine on my mac laptop running windows. On other windows machines image smoothing is not disabling ( i am using same chrome version on all of them). More strangely,
viewer.drawer.context.imageSmoothingEnabled = false;
console.log( viewer.drawer.context.imageSmoothingEnabled); return false, but
console.log(viewer); is showing that imageSmoothingEnabled is true.
Only on my laptop both 2nd and third line above show image smoothing is false. Any advice from you in this regard. Thank You so much for your help.
How can I reset the value constantly with requestAnimationFrame?
Ian Gilman
@iangilman
Apr 25 2017 20:12
@sohaib_ghani_twitter This will do it:
function frame() {
  requestAnimationFrame(frame);
  viewer.drawer.context.imageSmoothingEnabled = false;
}

frame();
The difference between console.log( viewer.drawer.context.imageSmoothingEnabled) and console.log(viewer) is that the former gives you the value at a particular moment in time, whereas the latter I think keeps updated with the latest value (though I'm not sure about that). Anyway, if that's the case, it implies that it's false at first and then becomes true, which is the same thing you're experiencing elsewhere, except maybe on those other machines something is happening right away to trigger the resize
Anyway, I think chasing down the resize thing is the most promising avenue for starters