Merge pull request #1507 from jetic83/master

Enable to switch off smoothed rendering of images on canvas
This commit is contained in:
Ian Gilman 2018-08-10 09:31:26 -07:00 committed by GitHub
commit 959f8e739a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 0 deletions

View File

@ -600,6 +600,27 @@ $.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 ) {
var context = this.context;
context.mozImageSmoothingEnabled = imageSmoothingEnabled;
context.webkitImageSmoothingEnabled = imageSmoothingEnabled;
context.msImageSmoothingEnabled = imageSmoothingEnabled;
context.imageSmoothingEnabled = imageSmoothingEnabled;
this.viewer.forceRedraw();
}
},
/** /**
* Get the canvas size * Get the canvas size
* @param {Boolean} sketch If set to true return the size of the sketch canvas * @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-over', 'destination-atop', 'destination-in',
* 'destination-out', 'lighter', 'copy' or 'xor' * '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] * @property {String|CanvasGradient|CanvasPattern|Function} [placeholderFillStyle=null]
* Draws a colored rectangle behind the tile if it is not loaded yet. * Draws a colored rectangle behind the tile if it is not loaded yet.
* You can pass a CSS color value like "#FF8800". * You can pass a CSS color value like "#FF8800".
@ -1178,6 +1183,7 @@ function OpenSeadragon( options ){
opacity: 1, opacity: 1,
preload: false, preload: false,
compositeOperation: null, compositeOperation: null,
imageSmoothingEnabled: true,
placeholderFillStyle: null, placeholderFillStyle: null,
//REFERENCE STRIP SETTINGS //REFERENCE STRIP SETTINGS

View File

@ -466,6 +466,12 @@ $.Viewer = function( options ) {
$.requestAnimationFrame( function(){ $.requestAnimationFrame( function(){
beginControlsAutoHide( _this ); 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 */{ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, /** @lends OpenSeadragon.Viewer.prototype */{