Simplified imageSmoothingEnabled Option. The option can be set during viewer creation and also later with the function viewer.drawer.setImageSmoothingEnabled().

This commit is contained in:
Peter 2018-08-03 18:47:16 -04:00
parent 17e25c0428
commit 9968025782
3 changed files with 34 additions and 0 deletions

View File

@ -600,6 +600,28 @@ $.Drawer.prototype = {
}
},
/**
* Turns image smoothing on or off for this viewer. Note: Ignored in some (especially older) browsers that do not support this property.
*
* @function
* @param {Boolean} [imageSmoothingEnabled] - Whether or not the image is
* drawn smoothly on the canvas; see imageSmoothingEnabled in
* {@link OpenSeadragon.Options} for more explanation.
*/
setImageSmoothingEnabled: function(imageSmoothingEnabled){
if ( this.useCanvas ) {
this.context.mozImageSmoothingEnabled = imageSmoothingEnabled;
this.context.webkitImageSmoothingEnabled = imageSmoothingEnabled;
this.context.msImageSmoothingEnabled = imageSmoothingEnabled;
this.context.imageSmoothingEnabled = imageSmoothingEnabled;
this.context.restore();
this.viewer.world.draw();
}
},
/**
* Get the canvas size
* @param {Boolean} sketch If set to true return the size of the sketch canvas

View File

@ -198,6 +198,11 @@
* 'destination-over', 'destination-atop', 'destination-in',
* 'destination-out', 'lighter', 'copy' or 'xor'
*
* @property {Boolean} [imageSmoothingEnabled=true]
* Image smoothing for canvas rendering (only if canvas is used). Note: Ignored
* by some (especially older) browsers which do not support this canvas property.
* This property can be changed in {@link Viewer.Drawer.setImageSmoothingEnabled}.
*
* @property {String|CanvasGradient|CanvasPattern|Function} [placeholderFillStyle=null]
* Draws a colored rectangle behind the tile if it is not loaded yet.
* You can pass a CSS color value like "#FF8800".
@ -1178,6 +1183,7 @@ function OpenSeadragon( options ){
opacity: 1,
preload: false,
compositeOperation: null,
imageSmoothingEnabled: true,
placeholderFillStyle: null,
//REFERENCE STRIP SETTINGS

View File

@ -466,6 +466,12 @@ $.Viewer = function( options ) {
$.requestAnimationFrame( function(){
beginControlsAutoHide( _this );
} );
// Initial canvas options
if ( this.imageSmoothingEnabled !== undefined && !this.imageSmoothingEnabled){
this.drawer.setImageSmoothingEnabled(this.imageSmoothingEnabled);
}
};
$.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, /** @lends OpenSeadragon.Viewer.prototype */{