Пример #1
0
        private Color[] ExtractSection(Color[] imageColors, Rect selectionRect)
        {
            ImageSelectionExtractor selectionExtractor = new ImageSelectionExtractor(imageColors, imageSelection.width, imageSelection.height);

            Color[] extractedSection = selectionExtractor.ExtractSection(selectionRect);

            return(extractedSection);
        }
        public void ExtractSection_NoChanges_FullImageExpected()
        {
            //Arrange
            Color[] sourceImage         = CreateSoureImage();
            Color[] expectedTargetImage = CreateSoureImage();

            ImageSelectionExtractor imageSelectionExtractor = new ImageSelectionExtractor(sourceImage, 3, 3);

            Rect selectionRect = new Rect(0, 0, 3, 3);

            //Action
            Color[] extractedImage = imageSelectionExtractor.ExtractSection(selectionRect);

            //Assert
            CompareArrays(extractedImage, expectedTargetImage);
        }
        public void ExtractSecion_MiddleSection1x1_ColorArrayLength1Red()
        {
            //Arrange
            Color[] sourceImage         = CreateSoureImage();
            Color[] expectedTargetImage = new Color[1];
            expectedTargetImage[0] = Color.red;

            ImageSelectionExtractor imageSelectionExtractor = new ImageSelectionExtractor(sourceImage, 3, 3);

            Rect selectionRect = new Rect(1, 1, 1, 1);

            //Action
            Color[] extractedImage = imageSelectionExtractor.ExtractSection(selectionRect);

            //Assert
            CompareArrays(extractedImage, expectedTargetImage);
        }