public bool ChangePixel(Object startPixel,LaMLibrary.SeamDirection seamDirection)
        {

            if (seamDirection == LaMLibrary.SeamDirection.Horizontal)
            {
                ShiftPixelsHor((byte*)(int)startPixel);
            }
            else if (seamDirection == LaMLibrary.SeamDirection.Vertical)
            {
                ShiftPixelsVer((byte*)(int)startPixel);
            }
            else
            {
                throw new NotImplementedException();
            }

            return true;
        }
        /// <summary>
        /// Resizes Bitmap
        /// </summary>
        /// <param name="n">Number of Resizesz to Make</param>
        // TODO : problem with creating new image when there is a image with boundary equal to 1
        private void ResizeBitmap(LaMLibrary.SeamDirection seamDirection)
        {
            UnlockBits();

            if (seamDirection == LaMLibrary.SeamDirection.Horizontal)
            {
                if (_bmp.Width != 1)
                {
                    _bmp = _bmp.Clone(new Rectangle(0, 0, _bmp.Width - 1, _bmp.Height), _bmp.PixelFormat);
                }
            }
            else if (seamDirection == LaMLibrary.SeamDirection.Vertical)
            {
                if (_bmp.Height != 1)
                {
                    _bmp = _bmp.Clone(new Rectangle(0, 0, _bmp.Width, _bmp.Height - 1), _bmp.PixelFormat);
                }
            }
            else
            {
                throw new Exception("This should Never Happen :D Wrong SeamDirection Passed To ResizeBitmap Method");
            }
            LockBits();
        }
 public bool ChangePixel(Object startPixel,LaMLibrary.SeamDirection seamDirection)
 {
     LibraryUnsafe.SetColorRGB(0, 0, 255, (byte*)(int)startPixel);
     return false;
 }
        //Tablica Wejsciowa sformatowana jako [x1,y1,x2,y2,......]
        public void DynamicRow(IPixelManipulator pixelManipulator, int [] inTab,LaMLibrary.SeamDirection seamDirection)
        {
            int[] parameters = new int[3];
            bool resize = false;
            if (seamDirection == LaMLibrary.SeamDirection.Horizontal)
            {
                parameters[0] = _bmp.Height;
                parameters[1] = _bmd.Width;
                parameters[2] = 3;
            }
            else if (seamDirection == LaMLibrary.SeamDirection.Vertical)
            {
                parameters[0] = _bmp.Width;
                parameters[1] = _bmd.Height;
                parameters[2] = _bmd.Stride;
            }
                
            for (int i = 0; i < parameters[0] - 1; i++)
            {
                int pxNumber = inTab[i * 2];

                pixelManipulator.SetUp(parameters[1] , pxNumber, parameters[2]);


                if (seamDirection == LaMLibrary.SeamDirection.Horizontal)
                {
                    GoToXY(inTab[i * 2], i);
                }
                else if (seamDirection == LaMLibrary.SeamDirection.Vertical)
                {
                    GoToXY(i, inTab[i * 2]);
                }


                if (pixelManipulator.ChangePixel((int)_current,seamDirection))
                {
                    resize = true;
                }
            }
            if (resize)
            {
                ResizeBitmap(seamDirection);
            }
           

        }
        public static int[] CreateDynamicSeam(int[,] energy,LaMLibrary.SeamDirection seamDirection)
        {
            int INFINITE = 999;
            int[] seamArray;
            int[] tmpArray;
            int[] tmpArray1= new int[3];
            int[] parameters = new int[2];

            if (seamDirection == SeamDirection.Horizontal)
            {
                parameters[0]= energy.GetLength(1);
                parameters[1]= energy.GetLength(0);
            }
            else if (seamDirection == SeamDirection.Vertical)
            {
                parameters[0] = energy.GetLength(0);
                parameters[1] = energy.GetLength(1);
            }
            // Na razie nie mam mozliwosci wyboru obu kierunkow na raz....
            else
            {
                throw new NotImplementedException();
            }

            seamArray = new int[parameters[0] * 2];
            tmpArray = new int[parameters[0]];


            int y = 0;
            int iterator = 0;

            // wyciecie jednego wiersza do nowej array z ktorej pobierzemy minimum ;]
            tmpArray = CutFirstRow(energy,seamDirection);

            int x = FindIndexWithLowestValue(tmpArray);

            seamArray[iterator++] = x;
            seamArray[iterator++] = y++;

            while (y < parameters[0] - 1)
            {
                tmpArray = CutOneRow(energy, y, seamDirection);

                if (x < parameters[1] - 1)
                {
                    if (x - 1 >= 0)
                    {

                        tmpArray1[0] = tmpArray[x - 1];
                        tmpArray1[1] = tmpArray[x];
                        tmpArray1[2] = tmpArray[x + 1];
                    }
                    else if (x > 0)
                    {
                        tmpArray1[0] = INFINITE;
                        tmpArray1[1] = tmpArray[x];
                        tmpArray1[2] = tmpArray[x + 1];
                    }
                    else
                    {
                        tmpArray1[0] = INFINITE;
                        tmpArray1[1] = 0;
                        tmpArray1[2] = INFINITE;
                    }
                }
                else if (x > 0)
                {
                    tmpArray1[0] = tmpArray[x - 1];
                    tmpArray1[1] = tmpArray[x];
                    tmpArray1[2] = INFINITE;
                }
                else
                {
                    tmpArray1[0] = INFINITE;
                    tmpArray1[1] = tmpArray[x];
                    tmpArray1[2] = INFINITE;
                }

                x += FindIndexWithLowestValue(tmpArray1) - 1;

                seamArray[iterator++] = x;
                seamArray[iterator++] = y++;

            }

            return seamArray;
        }