mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 14:46:10 +03:00
Discard the image as soon as possible.
This commit is contained in:
parent
b85d0674e6
commit
f58a525f47
@ -103,7 +103,7 @@
|
|||||||
* @throws {Error}
|
* @throws {Error}
|
||||||
*/
|
*/
|
||||||
getImageInfo: function (url) {
|
getImageInfo: function (url) {
|
||||||
var image = new Image();
|
var image = this.image = new Image();
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
if (this.crossOriginPolicy) {
|
if (this.crossOriginPolicy) {
|
||||||
@ -122,7 +122,7 @@
|
|||||||
_this._tileHeight = _this.height;
|
_this._tileHeight = _this.height;
|
||||||
_this.tileOverlap = 0;
|
_this.tileOverlap = 0;
|
||||||
_this.minLevel = 0;
|
_this.minLevel = 0;
|
||||||
_this.levels = _this._buildLevels(image);
|
_this.levels = _this._buildLevels();
|
||||||
_this.maxLevel = _this.levels.length - 1;
|
_this.maxLevel = _this.levels.length - 1;
|
||||||
|
|
||||||
_this.ready = true;
|
_this.ready = true;
|
||||||
@ -226,30 +226,34 @@
|
|||||||
* @private Build the differents levels of the pyramid if possible
|
* @private Build the differents levels of the pyramid if possible
|
||||||
* (canvas API enabled and no canvas tainting issue)
|
* (canvas API enabled and no canvas tainting issue)
|
||||||
*/
|
*/
|
||||||
_buildLevels: function (image) {
|
_buildLevels: function () {
|
||||||
var levels = [{
|
var levels = [{
|
||||||
url: image.src,
|
url: this.image.src,
|
||||||
width: image.naturalWidth,
|
width: this.image.naturalWidth,
|
||||||
height: image.naturalHeight
|
height: this.image.naturalHeight
|
||||||
}];
|
}];
|
||||||
|
|
||||||
if (!this.buildPyramid || !$.supportsCanvas || !this.useCanvas) {
|
if (!this.buildPyramid || !$.supportsCanvas || !this.useCanvas) {
|
||||||
|
// We don't need the image anymore. Allows it to be GC.
|
||||||
|
delete this.image;
|
||||||
return levels;
|
return levels;
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentWidth = image.naturalWidth;
|
var currentWidth = this.image.naturalWidth;
|
||||||
var currentHeight = image.naturalHeight;
|
var currentHeight = this.image.naturalHeight;
|
||||||
|
|
||||||
var bigCanvas = document.createElement("canvas");
|
var bigCanvas = document.createElement("canvas");
|
||||||
var bigContext = bigCanvas.getContext("2d");
|
var bigContext = bigCanvas.getContext("2d");
|
||||||
|
|
||||||
bigCanvas.width = currentWidth;
|
bigCanvas.width = currentWidth;
|
||||||
bigCanvas.height = currentHeight;
|
bigCanvas.height = currentHeight;
|
||||||
bigContext.drawImage(image, 0, 0, currentWidth, currentHeight);
|
bigContext.drawImage(this.image, 0, 0, currentWidth, currentHeight);
|
||||||
// We cache the context of the highest level because the browser
|
// We cache the context of the highest level because the browser
|
||||||
// is a lot faster at downsampling something it already has
|
// is a lot faster at downsampling something it already has
|
||||||
// downsampled before.
|
// downsampled before.
|
||||||
levels[0].context2D = bigContext;
|
levels[0].context2D = bigContext;
|
||||||
|
// We don't need the image anymore. Allows it to be GC.
|
||||||
|
delete this.image;
|
||||||
|
|
||||||
if ($.isCanvasTainted(bigCanvas)) {
|
if ($.isCanvasTainted(bigCanvas)) {
|
||||||
// If the canvas is tainted, we can't compute the pyramid.
|
// If the canvas is tainted, we can't compute the pyramid.
|
||||||
|
Loading…
Reference in New Issue
Block a user