Skip to content

Commit 156b2da

Browse files
committed
fixed interface
1 parent 57c462c commit 156b2da

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

src/OpenSlideSharp/DeepZoomGenerator.cs

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ public DeepZoomGenerator(OpenSlideImage image, int tileSize = 254, int overlap =
9191
/// </summary>
9292
public int LevelCount => _layers.Length;
9393

94-
private IEnumerable<ImageDimension> _levelTilesCache;
94+
private IEnumerable<TileDimensions> _levelTilesCache;
9595

9696
/// <summary>
9797
/// The number of tiles in each level.
9898
/// </summary>
99-
public IEnumerable<ImageDimension> LevelTiles
100-
=> _levelTilesCache != null ? _levelTilesCache : _levelTilesCache = _layers.Select(l => new ImageDimension((int)((l.LayerWidth + _tileSize - 1) / _tileSize), (int)((l.LayerHeight + _tileSize - 1) / _tileSize)));
99+
public IEnumerable<TileDimensions> LevelTiles
100+
=> _levelTilesCache != null ? _levelTilesCache : _levelTilesCache = _layers.Select(l => new TileDimensions((int)((l.LayerWidth + _tileSize - 1) / _tileSize), (int)((l.LayerHeight + _tileSize - 1) / _tileSize)));
101101

102102
private IEnumerable<ImageDimension> _levelDimensionsCache;
103103

@@ -325,4 +325,45 @@ public void Dispose()
325325
GC.SuppressFinalize(this);
326326
}
327327
}
328+
329+
/// <summary>
330+
/// Tile position
331+
/// </summary>
332+
public struct TileDimensions
333+
{
334+
internal int cols;
335+
internal int rows;
336+
337+
/// <summary>
338+
/// tile col
339+
/// </summary>
340+
public int Cols => cols;
341+
/// <summary>
342+
/// tile row
343+
/// </summary>
344+
public int Rows => rows;
345+
346+
/// <summary>
347+
///
348+
/// </summary>
349+
/// <param name="_cols">cols</param>
350+
/// <param name="_rows">rows</param>
351+
public TileDimensions(int _cols, int _rows)
352+
{
353+
cols = _cols;
354+
rows = _rows;
355+
}
356+
357+
/// <summary>
358+
///
359+
/// </summary>
360+
/// <param name="cols"></param>
361+
/// <param name="rows"></param>
362+
public void Deconstruct(out int cols, out int rows)
363+
{
364+
cols = this.cols;
365+
rows = this.rows;
366+
}
367+
368+
}
328369
}

test/OpenSlideSharp.Tests/DeepZoomBasics.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public void TestMetadata()
1818
Assert.Equal(10, dz.LevelCount);
1919
Assert.Equal(11, dz.TileCount);
2020
Assert.Equal(new (int, int)[] { (1, 1), (1, 1), (1, 1), (1, 1), (1, 1), (1, 1), (1, 1), (1, 1), (1, 1), (2, 1) }, dz.LevelTiles.Select(_ => (_.Cols, _.Rows)));
21-
Assert.Equal(new (long, long)[] { (1, 1), (2, 1), (3, 2), (5, 4), (10, 8), (19, 16), (38, 32), (75, 63), (150, 125), (300, 250) }, dz.LevelDimemsions.Select(_ => (_.Width, _.Height)));
21+
Assert.Equal(new (long, long)[] { (1, 1), (2, 1), (3, 2), (5, 4), (10, 8), (19, 16), (38, 32), (75, 63), (150, 125), (300, 250) }, dz.LevelDimensions.Select(_ => (_.Width, _.Height)));
2222
}
2323
}
2424

0 commit comments

Comments
 (0)