mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-24 22:26:10 +03:00
Merge pull request #1595 from doutsh/pr/imagesmoothing
[WIP] Fixing "imageSmoothingEnabled" resetting to 'True' (should fix #1593)
This commit is contained in:
commit
d003aab06f
@ -130,6 +130,10 @@ $.Drawer = function( options ) {
|
||||
// explicit left-align
|
||||
this.container.style.textAlign = "left";
|
||||
this.container.appendChild( this.canvas );
|
||||
|
||||
// Image smoothing for canvas rendering (only if canvas is used).
|
||||
// Canvas default is "true", so this will only be changed if user specified "false".
|
||||
this._imageSmoothingEnabled = true;
|
||||
};
|
||||
|
||||
/** @lends OpenSeadragon.Drawer.prototype */
|
||||
@ -254,6 +258,7 @@ $.Drawer.prototype = {
|
||||
this.sketchCanvas.width = sketchCanvasSize.x;
|
||||
this.sketchCanvas.height = sketchCanvasSize.y;
|
||||
}
|
||||
this._updateImageSmoothingEnabled();
|
||||
}
|
||||
this._clear();
|
||||
}
|
||||
@ -608,7 +613,6 @@ $.Drawer.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Turns image smoothing on or off for this viewer. Note: Ignored in some (especially older) browsers that do not support this property.
|
||||
*
|
||||
@ -619,16 +623,21 @@ $.Drawer.prototype = {
|
||||
*/
|
||||
setImageSmoothingEnabled: function(imageSmoothingEnabled){
|
||||
if ( this.useCanvas ) {
|
||||
var context = this.context;
|
||||
context.mozImageSmoothingEnabled = imageSmoothingEnabled;
|
||||
context.webkitImageSmoothingEnabled = imageSmoothingEnabled;
|
||||
context.msImageSmoothingEnabled = imageSmoothingEnabled;
|
||||
context.imageSmoothingEnabled = imageSmoothingEnabled;
|
||||
|
||||
this._imageSmoothingEnabled = imageSmoothingEnabled;
|
||||
this._updateImageSmoothingEnabled();
|
||||
this.viewer.forceRedraw();
|
||||
}
|
||||
},
|
||||
|
||||
// private
|
||||
_updateImageSmoothingEnabled: function(){
|
||||
var context = this.context;
|
||||
context.mozImageSmoothingEnabled = this._imageSmoothingEnabled;
|
||||
context.webkitImageSmoothingEnabled = this._imageSmoothingEnabled;
|
||||
context.msImageSmoothingEnabled = this._imageSmoothingEnabled;
|
||||
context.imageSmoothingEnabled = this._imageSmoothingEnabled;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the canvas size
|
||||
* @param {Boolean} sketch If set to true return the size of the sketch canvas
|
||||
@ -686,8 +695,9 @@ $.Drawer.prototype = {
|
||||
var pixelDensityRatio = $.pixelDensityRatio;
|
||||
var viewportSize = this.viewport.getContainerSize();
|
||||
return {
|
||||
x: viewportSize.x * pixelDensityRatio,
|
||||
y: viewportSize.y * pixelDensityRatio
|
||||
// canvas width and height are integers
|
||||
x: Math.round(viewportSize.x * pixelDensityRatio),
|
||||
y: Math.round(viewportSize.y * pixelDensityRatio)
|
||||
};
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user