mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 05:06:09 +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
|
// explicit left-align
|
||||||
this.container.style.textAlign = "left";
|
this.container.style.textAlign = "left";
|
||||||
this.container.appendChild( this.canvas );
|
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 */
|
/** @lends OpenSeadragon.Drawer.prototype */
|
||||||
@ -254,6 +258,7 @@ $.Drawer.prototype = {
|
|||||||
this.sketchCanvas.width = sketchCanvasSize.x;
|
this.sketchCanvas.width = sketchCanvasSize.x;
|
||||||
this.sketchCanvas.height = sketchCanvasSize.y;
|
this.sketchCanvas.height = sketchCanvasSize.y;
|
||||||
}
|
}
|
||||||
|
this._updateImageSmoothingEnabled();
|
||||||
}
|
}
|
||||||
this._clear();
|
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.
|
* 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){
|
setImageSmoothingEnabled: function(imageSmoothingEnabled){
|
||||||
if ( this.useCanvas ) {
|
if ( this.useCanvas ) {
|
||||||
var context = this.context;
|
this._imageSmoothingEnabled = imageSmoothingEnabled;
|
||||||
context.mozImageSmoothingEnabled = imageSmoothingEnabled;
|
this._updateImageSmoothingEnabled();
|
||||||
context.webkitImageSmoothingEnabled = imageSmoothingEnabled;
|
|
||||||
context.msImageSmoothingEnabled = imageSmoothingEnabled;
|
|
||||||
context.imageSmoothingEnabled = imageSmoothingEnabled;
|
|
||||||
|
|
||||||
this.viewer.forceRedraw();
|
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
|
* 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
|
||||||
@ -686,8 +695,9 @@ $.Drawer.prototype = {
|
|||||||
var pixelDensityRatio = $.pixelDensityRatio;
|
var pixelDensityRatio = $.pixelDensityRatio;
|
||||||
var viewportSize = this.viewport.getContainerSize();
|
var viewportSize = this.viewport.getContainerSize();
|
||||||
return {
|
return {
|
||||||
x: viewportSize.x * pixelDensityRatio,
|
// canvas width and height are integers
|
||||||
y: viewportSize.y * pixelDensityRatio
|
x: Math.round(viewportSize.x * pixelDensityRatio),
|
||||||
|
y: Math.round(viewportSize.y * pixelDensityRatio)
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user