mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 14:46:10 +03:00
Merge branch 'master' of https://github.com/openseadragon/openseadragon
This commit is contained in:
commit
576d0eb317
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,3 +7,4 @@ instrumented/
|
||||
.idea
|
||||
/nbproject/private/
|
||||
.directory
|
||||
test/demo/temp
|
||||
|
@ -11,6 +11,8 @@ OPENSEADRAGON CHANGELOG
|
||||
* Improved IIIF options.maxLevel calculation (#1401)
|
||||
* Added canvas-key events, along with the ability to cancel key actions (#1414)
|
||||
* Added optional zoom in the middle of the image instead of pointer position (#1423)
|
||||
* Now supporting square edge tiles that are padded rather than cropped (#1426)
|
||||
* Fixed an issue causing the simple image tileSource to sometimes show duplicate copies (#1370)
|
||||
|
||||
2.3.1:
|
||||
|
||||
|
5862
package-lock.json
generated
Normal file
5862
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
26
src/tile.js
26
src/tile.js
@ -40,7 +40,7 @@
|
||||
* @param {Number} level The zoom level this tile belongs to.
|
||||
* @param {Number} x The vector component 'x'.
|
||||
* @param {Number} y The vector component 'y'.
|
||||
* @param {OpenSeadragon.Point} bounds Where this tile fits, in normalized
|
||||
* @param {OpenSeadragon.Rect} bounds Where this tile fits, in normalized
|
||||
* coordinates.
|
||||
* @param {Boolean} exists Is this tile a part of a sparse image? ( Also has
|
||||
* this tile failed to load? )
|
||||
@ -49,8 +49,11 @@
|
||||
* is provided directly by the tile source.
|
||||
* @param {Boolean} loadWithAjax Whether this tile image should be loaded with an AJAX request .
|
||||
* @param {Object} ajaxHeaders The headers to send with this tile's AJAX request (if applicable).
|
||||
* @param {OpenSeadragon.Rect} sourceBounds The portion of the tile to use as the source of the
|
||||
* drawing operation, in pixels. Note that this only works when drawing with canvas; when drawing
|
||||
* with HTML the entire tile is always used.
|
||||
*/
|
||||
$.Tile = function(level, x, y, bounds, exists, url, context2D, loadWithAjax, ajaxHeaders) {
|
||||
$.Tile = function(level, x, y, bounds, exists, url, context2D, loadWithAjax, ajaxHeaders, sourceBounds) {
|
||||
/**
|
||||
* The zoom level this tile belongs to.
|
||||
* @member {Number} level
|
||||
@ -75,6 +78,13 @@ $.Tile = function(level, x, y, bounds, exists, url, context2D, loadWithAjax, aja
|
||||
* @memberof OpenSeadragon.Tile#
|
||||
*/
|
||||
this.bounds = bounds;
|
||||
/**
|
||||
* The portion of the tile to use as the source of the drawing operation, in pixels. Note that
|
||||
* this only works when drawing with canvas; when drawing with HTML the entire tile is always used.
|
||||
* @member {OpenSeadragon.Rect} sourceBounds
|
||||
* @memberof OpenSeadragon.Tile#
|
||||
*/
|
||||
this.sourceBounds = sourceBounds;
|
||||
/**
|
||||
* Is this tile a part of a sparse image? Also has this tile failed to load?
|
||||
* @member {Boolean} exists
|
||||
@ -357,12 +367,16 @@ $.Tile.prototype = {
|
||||
// changes as we are rendering the image
|
||||
drawingHandler({context: context, tile: this, rendered: rendered});
|
||||
|
||||
if (!this.sourceBounds) { // Just in case
|
||||
this.sourceBounds = new $.Rect(0, 0, rendered.canvas.width, rendered.canvas.height);
|
||||
}
|
||||
|
||||
context.drawImage(
|
||||
rendered.canvas,
|
||||
0,
|
||||
0,
|
||||
rendered.canvas.width,
|
||||
rendered.canvas.height,
|
||||
this.sourceBounds.x,
|
||||
this.sourceBounds.y,
|
||||
this.sourceBounds.width,
|
||||
this.sourceBounds.height,
|
||||
position.x,
|
||||
position.y,
|
||||
size.x,
|
||||
|
@ -1372,6 +1372,7 @@ function getTile(
|
||||
var xMod,
|
||||
yMod,
|
||||
bounds,
|
||||
sourceBounds,
|
||||
exists,
|
||||
url,
|
||||
ajaxHeaders,
|
||||
@ -1389,6 +1390,7 @@ function getTile(
|
||||
xMod = ( numTiles.x + ( x % numTiles.x ) ) % numTiles.x;
|
||||
yMod = ( numTiles.y + ( y % numTiles.y ) ) % numTiles.y;
|
||||
bounds = tileSource.getTileBounds( level, xMod, yMod );
|
||||
sourceBounds = tileSource.getTileBounds( level, xMod, yMod, true );
|
||||
exists = tileSource.tileExists( level, xMod, yMod );
|
||||
url = tileSource.getTileUrl( level, xMod, yMod );
|
||||
|
||||
@ -1418,7 +1420,8 @@ function getTile(
|
||||
url,
|
||||
context2D,
|
||||
tiledImage.loadTilesWithAjax,
|
||||
ajaxHeaders
|
||||
ajaxHeaders,
|
||||
sourceBounds
|
||||
);
|
||||
|
||||
if (xMod === numTiles.x - 1) {
|
||||
|
@ -360,7 +360,7 @@ $.TileSource.prototype = {
|
||||
if (point.x >= 1) {
|
||||
x = this.getNumTiles(level).x - 1;
|
||||
}
|
||||
var EPSILON = 1e-16;
|
||||
var EPSILON = 1e-15;
|
||||
if (point.y >= 1 / this.aspectRatio - EPSILON) {
|
||||
y = this.getNumTiles(level).y - 1;
|
||||
}
|
||||
@ -373,8 +373,12 @@ $.TileSource.prototype = {
|
||||
* @param {Number} level
|
||||
* @param {Number} x
|
||||
* @param {Number} y
|
||||
* @param {Boolean} [isSource=false] Whether to return the source bounds of the tile.
|
||||
* @returns {OpenSeadragon.Rect} Either where this tile fits (in normalized coordinates) or the
|
||||
* portion of the tile to use as the source of the drawing operation (in pixels), depending on
|
||||
* the isSource parameter.
|
||||
*/
|
||||
getTileBounds: function( level, x, y ) {
|
||||
getTileBounds: function( level, x, y, isSource ) {
|
||||
var dimensionsScaled = this.dimensions.times( this.getLevelScale( level ) ),
|
||||
tileWidth = this.getTileWidth(level),
|
||||
tileHeight = this.getTileHeight(level),
|
||||
@ -387,6 +391,12 @@ $.TileSource.prototype = {
|
||||
sx = Math.min( sx, dimensionsScaled.x - px );
|
||||
sy = Math.min( sy, dimensionsScaled.y - py );
|
||||
|
||||
if (isSource) {
|
||||
scale = 1;
|
||||
px = 0;
|
||||
py = 0;
|
||||
}
|
||||
|
||||
return new $.Rect( px * scale, py * scale, sx * scale, sy * scale );
|
||||
},
|
||||
|
||||
|
@ -107,6 +107,17 @@
|
||||
maxLevel: 0,
|
||||
});
|
||||
assertTileAtPoint(0, new OpenSeadragon.Point(1, 1239 / 4036), new OpenSeadragon.Point(0, 0));
|
||||
|
||||
// Test for issue #1362
|
||||
tileSource = new OpenSeadragon.TileSource({
|
||||
width: 2000,
|
||||
height: 3033,
|
||||
tileWidth: 2000,
|
||||
tileHeight: 3033,
|
||||
tileOverlap: 0,
|
||||
maxLevel: 0,
|
||||
});
|
||||
assertTileAtPoint(0, new OpenSeadragon.Point(1, 3033 / 2000), new OpenSeadragon.Point(0, 0));
|
||||
});
|
||||
|
||||
}());
|
||||
|
Loading…
Reference in New Issue
Block a user