openlayers / ol2

OpenLayers v2 - deprecated!
Other
1.47k stars 770 forks source link

Zoomify code fails to display bottom and rightmost tiles #924

Open loonycoon opened 11 years ago

loonycoon commented 11 years ago

When used with an image which is an evenly-sized multiple of the tile size, the zoomify code incorrectly assigns an image size of [0,0] to the rightmost and/or bottom tile images. Even though the images are in the DOM and positioned correctly, they do not display (because, of course, they have a size of zero).

The problem is due to sizing code in Zoomify.js, getImageSize().

The original code is:

    /* getImageSize returns size for a particular tile. If bounds are given as
     * first argument, size is calculated (bottom-right tiles are non square). */

            var w = this.standardTileSize;
            var h = this.standardTileSize;
            if (x == this.tierSizeInTiles[z].w -1 ) {
                var w = this.tierImageSize[z].w % this.standardTileSize;
            };
            if (y == this.tierSizeInTiles[z].h -1 ) {
                var h = this.tierImageSize[z].h % this.standardTileSize;
            };

When (tierImageSize[z].w == standardTileSize), the modulo result is 0, not standardTileSize.

A possible fix is:

            if (x == this.tierSizeInTiles[z].w -1 ) {
                var w_1 = this.tierImageSize[z].w % this.standardTileSize;
                if(w_1 != 0)
                  w = w_1;
            };
            if (y == this.tierSizeInTiles[z].h -1 ) {
                var h_1 = this.tierImageSize[z].h % this.standardTileSize;
                if(h_1 != 0)
                  h = h_1;
            };
moschlar commented 9 years ago

This has been fixed in #976.