Esempio n. 1
0
        private static void CheckRectangleBySize(int width, int height)
        {
            var expected = new System.Windows.Rect(new System.Windows.Size(width, height));
            var actual   = DeepZoomImage.CreateRectangle(new Size(width, height));

            AssertAreEqual(expected, actual);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        private static void CheckRectangleWithTwoPoints(int x1, int y1, int x2, int y2)
        {
            // The constructor below is documented as:
            // "Initializes a new instance of the Rect structure that is
            // exactly large enough to contain the two specified points."
            var expected = new System.Windows.Rect
                           (
                new System.Windows.Point(x1, y1),
                new System.Windows.Point(x2 + 1, y2 + 1)
                           );
            var actual = DeepZoomImage.CreateRectangle(new Point(x1, y1), new Point(x2, y2));

            AssertAreEqual(expected, actual);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        public void Slice_Typical()
        {
            var tiles = 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, 374)), "0_1"),

                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(253, 0), new Point(299, 254)), "1_0"),
                new Pair <Rectangle, string>(DeepZoomImage.CreateRectangle(new Point(253, 253), new Point(299, 374)), "1_1"),
            };
            var streams = new Dictionary <string, MemoryStream>
            {
                { "0_0", new MemoryStream() },
                { "0_1", new MemoryStream() },
                { "1_0", new MemoryStream() },
                { "1_1", new MemoryStream() },
            };
            var settings = new Settings {
                PostImageEncoding = ImageFormat.Png,
            };
            var dzi = new DeepZoomImage(settings);

            try
            {
                using (var inputStream = AssemblyExtensions.OpenScopedResourceStream <DeepZoomImageTest> ("300x375.png"))
                    using (var sourceBitmap = new Bitmap(inputStream))
                    {
                        dzi.Slice(sourceBitmap, tiles, tilename => streams[tilename]);
                    }

                foreach (var keyValuePair in streams)
                {
                    var expectedResourceFileName = keyValuePair.Key + ".png";
                    var actualStream             = keyValuePair.Value;
                    ProgramTest.AssertStreamsAreEqual <DeepZoomImageTest> (expectedResourceFileName, actualStream);
                }
            }
            finally
            {
                foreach (var stream in streams.Values)
                {
                    stream.Close();
                    stream.Dispose();
                }
            }
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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);
        }