/// <summary>
        /// once the seam has been calculated, we use this method to shrink the array and remove the unwanted pixels.
        /// </summary>
        /// <param name="injectedContext"></param>
        public void resize(SeamCarvingContext injectedContext)
        {
            int newSize = ((int)ImageControl.Width - 1) * ((int)ImageControl.Height) * 4;

            byte[] newImage = new byte[newSize];

            int encountered = 0;

            for (int i = 0; i < ImageControl.Width; i++)
            {
                encountered = 0;
                for (int f = 0; f < ImageControl.Height - 1; f++)
                {
                    if (this.seamUtilities.getIndex(injectedContext.dirtyArray, f, i, injectedContext) != 1)
                    {
                        for (int k = 0; k < 4; k++)
                        {
                            seamUtilities.setPixel(newImage, f - encountered, i, k, seamUtilities.getPixel(injectedContext.imageDataArray, f, i, k, injectedContext), injectedContext);
                        }
                    }
                    else
                    {
                        encountered = 1;
                    }
                }
            }
            ImageControl.Height--;
            injectedContext.imageDataArray = newImage;
        }
        /// <summary>
        /// takes in a byte array and a seam context and displays it to the application window as an image.
        /// </summary>
        /// <param name="toDisplay"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="injectedContext"></param>
        public void display(byte[] toDisplay, int width, int height, SeamCarvingContext injectedContext)
        {
            Bitmap     newBitmap = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            BitmapData bmData    = newBitmap.LockBits(new System.Drawing.Rectangle(0, 0, newBitmap.Width, newBitmap.Height), ImageLockMode.ReadWrite, newBitmap.PixelFormat);
            IntPtr     pNative   = bmData.Scan0;

            Marshal.Copy(toDisplay, 0, pNative, width * height * 4);
            newBitmap.UnlockBits(bmData);

            injectedContext.newBitmapImage = new BitmapImage();
            using (MemoryStream memory = new MemoryStream())
            {
                newBitmap.Save(memory, ImageFormat.Png);
                memory.Position = 0;
                injectedContext.newBitmapImage.BeginInit();
                injectedContext.newBitmapImage.CacheOption  = BitmapCacheOption.OnLoad;
                injectedContext.newBitmapImage.StreamSource = memory;
                injectedContext.newBitmapImage.EndInit();
            }
            ImageControl.Width = width;
            Application.Current.MainWindow.Height = height + 400;
            Application.Current.MainWindow.Width  = width + 600;

            ImageControl.Height = height;
            ImageControl.Source = injectedContext.newBitmapImage;
        }
        /// <summary>
        /// constructor
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();
            this.context = new SeamCarvingContext();

            this.context.Height = ImageControl.Height;
            this.context.Width  = ImageControl.Width;

            this.seamUtilities      = new SeamUtilities();
            this.gradientCalculator = new GradientCalculator(seamUtilities);
            this.heatCalculator     = new HeatCalculator(seamUtilities);
            this.seamCalculator     = new SeamCalculator(seamUtilities);
        }
        public void basicSuccess()
        {
            int x = 3;
            int y = 3;

            var mock = new Mock <ISeamUtilities>();

            mock.Setup(m => m.findMinIndex(It.IsAny <int[]>(), It.IsAny <SeamCarvingContext>())).Returns(0);

            var testContext = new SeamCarvingContext()
            {
                energy = new int[x * y], dirtyArray = new int[x * y]
            };

            for (int i = 0; i < x; i++)
            {
                testContext.energy[i] = 0;
            }
            for (int i = x; i < testContext.energy.Length; i++)
            {
                testContext.energy[i] = Int32.MaxValue;
            }

            var testSeamCalculator = new SeamCalculator(mock.Object);

            testSeamCalculator.calculateSeam(testContext);

            for (int i = 0; i < x; i++)
            {
                Assert.AreEqual(testContext.dirtyArray[i], 1);
            }
            for (int i = x; i < testContext.energy.Length; i++)
            {
                Assert.AreEqual(testContext.dirtyArray[i], 0);
            }
        }