diff --git a/src/canvasdrawer.js b/src/canvasdrawer.js index 49dd1047..e91a0459 100644 --- a/src/canvasdrawer.js +++ b/src/canvasdrawer.js @@ -62,7 +62,7 @@ class CanvasDrawer extends $.DrawerBase{ this.sketchContext = null; // Image smoothing for canvas rendering (only if canvas is used). - // Canvas default is "true", so this will only be changed if user specifies "false" in setImageSmoothinEnabled. + // Canvas default is "true", so this will only be changed if user specifies "false" in the options or via setImageSmoothinEnabled. this._imageSmoothingEnabled = true; } @@ -138,7 +138,7 @@ class CanvasDrawer extends $.DrawerBase{ * {@link OpenSeadragon.Options} for more explanation. */ setImageSmoothingEnabled(imageSmoothingEnabled){ - this._imageSmoothingEnabled = imageSmoothingEnabled; + this._imageSmoothingEnabled = !!imageSmoothingEnabled; this._updateImageSmoothingEnabled(this.context); this.viewer.forceRedraw(); } diff --git a/src/viewer.js b/src/viewer.js index b32d8015..954bfc56 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -447,6 +447,8 @@ $.Viewer = function( options ) { } let drawerCandidates = Array.isArray(this.drawer) ? this.drawer : [this.drawer]; if (drawerCandidates.length === 0){ + // if an empty array was passed in, throw a warning and use the defaults + // note: if the drawer option is not specified, the defaults will already be set so this won't apply drawerCandidates = [$.DEFAULT_SETTINGS.drawer].flat(); // ensure it is a list $.console.warn('No valid drawers were selected. Using the default value.'); } @@ -487,13 +489,15 @@ $.Viewer = function( options ) { throw('Error with creating the selected drawer(s)'); } + // Pass the imageSmoothingEnabled option along to the drawer + this.drawer.setImageSmoothingEnabled(this.imageSmoothingEnabled); // Overlay container this.overlaysContainer = $.makeNeutralElement( "div" ); this.canvas.appendChild( this.overlaysContainer ); // Now that we have a drawer, see if it supports rotate. If not we need to remove the rotate buttons - if (this.drawer && !this.drawer.canRotate()) { + if (!this.drawer.canRotate()) { // Disable/remove the rotate left/right buttons since they aren't supported if (this.rotateLeft) { i = this.buttonGroup.buttons.indexOf(this.rotateLeft); diff --git a/src/webgldrawer.js b/src/webgldrawer.js index ff0cbd5b..9baccf5d 100644 --- a/src/webgldrawer.js +++ b/src/webgldrawer.js @@ -392,8 +392,10 @@ * @param {Boolean} enabled */ setImageSmoothingEnabled(enabled){ - this._clippingContext.imageSmoothingEnabled = enabled; - this._outputContext.imageSmoothingEnabled = enabled; + //TODO: does imageSmoothingEnabled make sense in the WebGL drawer? + // We aren't scaling small images up to larger ones using context2d canvas operations so it may not apply + this._clippingContext.imageSmoothingEnabled = !!enabled; + this._outputContext.imageSmoothingEnabled = !!enabled; } /**