Example #1
0
        /// <summary>
        /// Creates a new target canvas to contain the results of the matrix transform.
        /// </summary>
        /// <param name="sourceRectangle">The source rectangle.</param>
        /// <param name="processMatrix">The processing matrix.</param>
        protected void CreateNewCanvas(Rectangle sourceRectangle, Matrix3x2 processMatrix)
        {
            Matrix3x2 sizeMatrix;

            this.CanvasRectangle = Matrix3x2.Invert(processMatrix, out sizeMatrix)
                ? ImageMaths.GetBoundingRectangle(sourceRectangle, sizeMatrix)
                : sourceRectangle;
        }
Example #2
0
        /// <summary>
        /// Creates a new target to contain the results of the matrix transform.
        /// </summary>
        /// <param name="target">Target image to apply the process to.</param>
        /// <param name="sourceRectangle">The source rectangle.</param>
        /// <param name="processMatrix">The processing matrix.</param>
        protected static void CreateNewTarget(ImageBase <TColor, TPacked> target, Rectangle sourceRectangle, Matrix3x2 processMatrix)
        {
            Matrix3x2 sizeMatrix;

            if (Matrix3x2.Invert(processMatrix, out sizeMatrix))
            {
                Rectangle rectangle = ImageMaths.GetBoundingRectangle(sourceRectangle, sizeMatrix);
                target.SetPixels(rectangle.Width, rectangle.Height, new TColor[rectangle.Width * rectangle.Height]);
            }
        }
Example #3
0
            public void ThenShouldBeAt00And5By5GivenPoints5UnitsApart(
                int pointX1,
                int pointY1,
                int pointX2,
                int pointY2)
            {
                // Arrange // Act
                var rectangle = ImageMaths.GetBoundingRectangle(
                    new Point(pointX1, pointY1),
                    new Point(pointX2, pointY2));

                // Assert
                Assert.That(
                    rectangle,
                    Is.EqualTo(new Rectangle(pointX1, pointY1, pointX2 - pointX1, pointY2 - pointY1)));
            }