public void ComputeTiles_AllLevelsOfSquareLogo() { var tester = new Action <int, int, int> ((inputSide, expectedTileCount, expectedFirstTileSize) => { var tiles = DeepZoomImage.ComputeTiles(new Size(inputSide, inputSide), 254, 1); var e = tiles.GetEnumerator(); e.MoveNext(); var firstTile = e.Current; var actualRectangle = firstTile.First; var expectedRectangle = new Rectangle(0, 0, expectedFirstTileSize, expectedFirstTileSize); Assert.AreEqual(expectedRectangle, actualRectangle); var actualTileCount = 1; while (e.MoveNext()) { actualTileCount++; } Assert.AreEqual(expectedTileCount, actualTileCount); } ); tester(700, 9, 255); tester(350, 4, 255); tester(175, 1, 175); tester(88, 1, 88); tester(44, 1, 44); tester(22, 1, 22); tester(11, 1, 11); tester(6, 1, 6); tester(3, 1, 3); tester(2, 1, 2); tester(1, 1, 1); }
public void ComputeTiles_SizeOfTile() { var size = new Size(254, 254); var actual = DeepZoomImage.ComputeTiles(size, 254, 1); var expected = new[] { new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(size), "0_0") }; EnumerableExtensions.EnumerateSame(expected, actual); }
private static IEnumerable <Pair <Rectangle, string> > TestComputeTiles(Size levelSize, int tileSize, int tileOverlap) { var settings = new Settings { TileSize = tileSize, TileOverlap = tileOverlap, }; var dzi = new DeepZoomImage(settings); return(dzi.ComputeTiles(levelSize)); }
public void ComputeTiles_TwoPixelsBiggerThanTileWithOverlapOfTwo() { var size = new Size(256, 256); var actual = DeepZoomImage.ComputeTiles(size, 254, 2); var expected = new[] { new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 0), new Point(255, 255)), "0_0"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 252), new Point(255, 255)), "0_1"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(252, 0), new Point(255, 255)), "1_0"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(252, 252), new Point(255, 255)), "1_1"), }; EnumerableExtensions.EnumerateSame(expected, actual); }
public void ComputeTiles_OnePixelBiggerThanTile() { var size = new Size(255, 255); var actual = DeepZoomImage.ComputeTiles(size, 254, 1); var expected = new[] { new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 0), new Point(254, 254)), "0_0"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 253), new Point(254, 254)), "0_1"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(253, 0), new Point(254, 254)), "1_0"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(253, 253), new Point(254, 254)), "1_1"), }; EnumerableExtensions.EnumerateSame(expected, actual); }
public void ComputeTiles_BiggerThanTileWithOverlapOfThree() { var size = new Size(300, 375); var actual = DeepZoomImage.ComputeTiles(size, 254, 3); var expected = new[] { new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 0), new Point(256, 256)), "0_0"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 251), new Point(256, 374)), "0_1"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(251, 0), new Point(299, 256)), "1_0"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(251, 251), new Point(299, 374)), "1_1"), }; EnumerableExtensions.EnumerateSame(expected, actual); }
public void ComputeTiles_OriginalSize() { var size = new Size(1200, 1500); var actual = DeepZoomImage.ComputeTiles(size, 254, 1); var expected = new[] { new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 0), new Point(254, 254)), "0_0"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 253), new Point(254, 508)), "0_1"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 507), new Point(254, 762)), "0_2"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 761), new Point(254, 1016)), "0_3"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 1015), new Point(254, 1270)), "0_4"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 1269), new Point(254, 1499)), "0_5"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(253, 0), new Point(508, 254)), "1_0"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(253, 253), new Point(508, 508)), "1_1"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(253, 507), new Point(508, 762)), "1_2"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(253, 761), new Point(508, 1016)), "1_3"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(253, 1015), new Point(508, 1270)), "1_4"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(253, 1269), new Point(508, 1499)), "1_5"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(507, 0), new Point(762, 254)), "2_0"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(507, 253), new Point(762, 508)), "2_1"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(507, 507), new Point(762, 762)), "2_2"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(507, 761), new Point(762, 1016)), "2_3"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(507, 1015), new Point(762, 1270)), "2_4"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(507, 1269), new Point(762, 1499)), "2_5"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(761, 0), new Point(1016, 254)), "3_0"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(761, 253), new Point(1016, 508)), "3_1"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(761, 507), new Point(1016, 762)), "3_2"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(761, 761), new Point(1016, 1016)), "3_3"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(761, 1015), new Point(1016, 1270)), "3_4"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(761, 1269), new Point(1016, 1499)), "3_5"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(1015, 0), new Point(1199, 254)), "4_0"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(1015, 253), new Point(1199, 508)), "4_1"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(1015, 507), new Point(1199, 762)), "4_2"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(1015, 761), new Point(1199, 1016)), "4_3"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(1015, 1015), new Point(1199, 1270)), "4_4"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(1015, 1269), new Point(1199, 1499)), "4_5"), }; EnumerableExtensions.EnumerateSame(expected, actual); }
public void ComputeTiles_BigWithDoubleOverlap() { var size = new Size(700, 700); var actual = DeepZoomImage.ComputeTiles(size, 254, 1); var expected = new[] { new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 0), new Point(254, 254)), "0_0"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 253), new Point(254, 508)), "0_1"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(0, 507), new Point(254, 699)), "0_2"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(253, 0), new Point(508, 254)), "1_0"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(253, 253), new Point(508, 508)), "1_1"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(253, 507), new Point(508, 699)), "1_2"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(507, 0), new Point(699, 254)), "2_0"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(507, 253), new Point(699, 508)), "2_1"), new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(507, 507), new Point(699, 699)), "2_2"), }; EnumerableExtensions.EnumerateSame(expected, actual); }
public void Slice_SquareLogo() { Assert.AreEqual(10, DeepZoomImage.DetermineMaximumLevel(SquareLogoSize)); using (var sourceBitmap = new Bitmap(SquareLogoSize.Width, SquareLogoSize.Height)) { var tester = new Action <int, IEnumerable <Size> > ((level, expectedSliceSizes) => { var levelSize = DeepZoomImage.ComputeLevelSize(SquareLogoSize, level); var tiles = DeepZoomImage.ComputeTiles(levelSize, 254, 1); var slices = DeepZoomImage.Slice(sourceBitmap, tiles); var actualSliceSizes = slices.Map(pair => pair.First.Size); EnumerableExtensions.EnumerateSame(expectedSliceSizes, actualSliceSizes); } ); tester(10, new[] { new Size(255, 255), new Size(255, 256), new Size(255, 193), new Size(256, 255), new Size(256, 256), new Size(256, 193), new Size(193, 255), new Size(193, 256), new Size(193, 193), } ); tester(9, new[] { new Size(255, 255), new Size(255, 97), new Size(97, 255), new Size(97, 97), } ); tester(8, new[] { new Size(175, 175) }); tester(7, new[] { new Size(88, 88) }); tester(6, new[] { new Size(44, 44) }); tester(5, new[] { new Size(22, 22) }); tester(4, new[] { new Size(11, 11) }); tester(3, new[] { new Size(6, 6) }); tester(2, new[] { new Size(3, 3) }); tester(1, new[] { new Size(2, 2) }); tester(0, new[] { new Size(1, 1) }); } }
private static IEnumerable<Pair<Rectangle, string>> TestComputeTiles (Size levelSize, int tileSize, int tileOverlap) { var settings = new Settings { TileSize = tileSize, TileOverlap = tileOverlap, }; var dzi = new DeepZoomImage (settings); return dzi.ComputeTiles (levelSize); }