Example #1
0
        public void TestIsPointInsideArc()
        {
            var cropRect = new Rectangle(1, 1, 8, 8);

            Assert.IsFalse(ImageCropper.IsPointInsideArc(new Point(0, 0), cropRect));
            Assert.IsFalse(ImageCropper.IsPointInsideArc(new Point(0, 7), cropRect));
            Assert.IsFalse(ImageCropper.IsPointInsideArc(new Point(7, 0), cropRect));
            Assert.IsFalse(ImageCropper.IsPointInsideArc(new Point(7, 7), cropRect));
            Assert.IsTrue(ImageCropper.IsPointInsideArc(new Point(4, 4), cropRect), "Some point in the centre");
        }
Example #2
0
        bool IsZoomedPixelInsideCropRect(int x, int y)
        {
            bool result = false;

            switch (CropKind)
            {
            case ImageCropper.CropKind.Arc:
                result = ImageCropper.IsPointInsideArc(new Point(x - CropRect.Left, y - CropRect.Top), CropRect);
                break;

            case ImageCropper.CropKind.Rectangle:
                result =
                    x >= CropRect.Left && x < CropRect.RightExclusive &&
                    y >= CropRect.Top && y < CropRect.BottomExclusive;
                break;
            }
            return(result);
        }