/// <summary>
        /// Crop shot or Selected Window captures
        /// </summary>
        /// <param name="myImage">Fullscreen image</param>
        /// <param name="windowMode">True = Selected window, False = Crop shot</param>
        public Crop(Image myImage, bool windowMode)
        {
            InitializeComponent();
            selectedWindowMode = windowMode;
            bmpClean = new Bitmap(myImage);
            bmpBackground = new Bitmap(bmpClean);
            bmpRegion = new Bitmap(bmpClean);
            Bounds = CaptureHelpers.GetScreenBounds();
            this.CursorPos = this.PointToClient(Cursor.Position);
            rectIntersect.Size = new Size(Bounds.Width - 1, Bounds.Height - 1);
            SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
            CalculateBoundaryFromMousePosition();
            timer.Tick += new EventHandler(TimerTick);
            windowCheck.Tick += new EventHandler(WindowCheckTick);

            if (selectedWindowMode)
            {
                captureObjects = Engine.ConfigUI.SelectedWindowCaptureObjects;
                myRectangle = new DynamicRectangle(CaptureType.SELECTED_WINDOW);
                WindowsListAdvanced wla = new WindowsListAdvanced();
                wla.IgnoreWindows.Add(Handle);
                wla.IncludeChildWindows = captureObjects;
                windows = wla.GetWindowsRectangleList();
            }
            else
            {
                myRectangle = new DynamicRectangle(CaptureType.CROP);

                if (Engine.ConfigUI.UseHardwareCursor)
                {
                    Cursor = Cursors.Cross;
                }
                else
                {
                    Cursor.Hide();
                }
            }

            using (Graphics gBackground = Graphics.FromImage(bmpBackground))
            using (Graphics gRegion = Graphics.FromImage(bmpRegion))
            {
                gBackground.SmoothingMode = SmoothingMode.HighQuality;
                gRegion.SmoothingMode = SmoothingMode.HighQuality;

                if ((selectedWindowMode && Engine.ConfigUI.SelectedWindowRegionStyles == RegionStyles.REGION_TRANSPARENT) ||
                (!selectedWindowMode && Engine.ConfigUI.CropRegionStyles == RegionStyles.REGION_TRANSPARENT))
                { // If Region Transparent
                    gRegion.FillRectangle(new SolidBrush(Color.FromArgb(Engine.ConfigUI.RegionTransparentValue, Color.White)),
                        new Rectangle(0, 0, bmpRegion.Width, bmpRegion.Height));
                }
                else if ((selectedWindowMode && Engine.ConfigUI.SelectedWindowRegionStyles == RegionStyles.REGION_BRIGHTNESS) ||
                (!selectedWindowMode && Engine.ConfigUI.CropRegionStyles == RegionStyles.REGION_BRIGHTNESS))
                { // If Region Brightness
                    ImageAttributes imgattr = new ImageAttributes();
                    imgattr.SetColorMatrix(ColorMatrices.BrightnessFilter(Engine.ConfigUI.RegionBrightnessValue));
                    gRegion.DrawImage(bmpClean, new Rectangle(0, 0, bmpRegion.Width, bmpRegion.Height), 0, 0,
                        bmpRegion.Width, bmpRegion.Height, GraphicsUnit.Pixel, imgattr);
                }
                else if ((selectedWindowMode && Engine.ConfigUI.SelectedWindowRegionStyles == RegionStyles.BACKGROUND_REGION_TRANSPARENT) ||
                (!selectedWindowMode && Engine.ConfigUI.CropRegionStyles == RegionStyles.BACKGROUND_REGION_TRANSPARENT))
                { // If Background Region Transparent
                    gBackground.FillRectangle(new SolidBrush(Color.FromArgb(Engine.ConfigUI.BackgroundRegionTransparentValue, Color.White)),
                        new Rectangle(0, 0, bmpBackground.Width, bmpBackground.Height));
                }
                else if ((selectedWindowMode && Engine.ConfigUI.SelectedWindowRegionStyles == RegionStyles.BACKGROUND_REGION_BRIGHTNESS) ||
                (!selectedWindowMode && Engine.ConfigUI.CropRegionStyles == RegionStyles.BACKGROUND_REGION_BRIGHTNESS))
                { // If Background Region Brightness
                    ImageAttributes imgattr = new ImageAttributes();
                    imgattr.SetColorMatrix(ColorMatrices.BrightnessFilter(Engine.ConfigUI.BackgroundRegionBrightnessValue));
                    gBackground.DrawImage(bmpClean, new Rectangle(0, 0, bmpBackground.Width, bmpBackground.Height), 0, 0,
                        bmpBackground.Width, bmpBackground.Height, GraphicsUnit.Pixel, imgattr);
                }
                else if ((selectedWindowMode && Engine.ConfigUI.SelectedWindowRegionStyles == RegionStyles.BACKGROUND_REGION_GRAYSCALE) ||
                (!selectedWindowMode && Engine.ConfigUI.CropRegionStyles == RegionStyles.BACKGROUND_REGION_GRAYSCALE))
                { // If Background Region Grayscale
                    ImageAttributes imgattr = new ImageAttributes();
                    imgattr.SetColorMatrix(ColorMatrices.GrayscaleFilter());
                    gBackground.DrawImage(bmpClean, new Rectangle(0, 0, bmpBackground.Width, bmpBackground.Height), 0, 0,
                        bmpBackground.Width, bmpBackground.Height, GraphicsUnit.Pixel, imgattr);
                }
            }

            brushClean = new TextureBrush(bmpClean);
            brushBackground = new TextureBrush(bmpBackground);
            brushRegion = new TextureBrush(bmpRegion);
        }
        /// <summary>
        /// Crop shot or Selected Window captures
        /// </summary>
        /// <param name="myImage">Fullscreen image</param>
        /// <param name="windowMode">True = Selected window, False = Crop shot</param>
        public Crop(Image myImage, bool windowMode)
        {
            InitializeComponent();
            selectedWindowMode = windowMode;
            bmpClean           = new Bitmap(myImage);
            bmpBackground      = new Bitmap(bmpClean);
            bmpRegion          = new Bitmap(bmpClean);
            Bounds             = CaptureHelpers.GetScreenBounds();
            this.CursorPos     = this.PointToClient(Cursor.Position);
            rectIntersect.Size = new Size(Bounds.Width - 1, Bounds.Height - 1);
            SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
            CalculateBoundaryFromMousePosition();
            timer.Tick       += new EventHandler(TimerTick);
            windowCheck.Tick += new EventHandler(WindowCheckTick);

            if (selectedWindowMode)
            {
                captureObjects = Engine.ConfigUI.SelectedWindowCaptureObjects;
                myRectangle    = new DynamicRectangle(CaptureType.SELECTED_WINDOW);
                WindowsListAdvanced wla = new WindowsListAdvanced();
                wla.IgnoreWindows.Add(Handle);
                wla.IncludeChildWindows = captureObjects;
                windows = wla.GetWindowsRectangleList();
            }
            else
            {
                myRectangle = new DynamicRectangle(CaptureType.CROP);

                if (Engine.ConfigUI.UseHardwareCursor)
                {
                    Cursor = Cursors.Cross;
                }
                else
                {
                    Cursor.Hide();
                }
            }

            using (Graphics gBackground = Graphics.FromImage(bmpBackground))
                using (Graphics gRegion = Graphics.FromImage(bmpRegion))
                {
                    gBackground.SmoothingMode = SmoothingMode.HighQuality;
                    gRegion.SmoothingMode     = SmoothingMode.HighQuality;

                    if ((selectedWindowMode && Engine.ConfigUI.SelectedWindowRegionStyles == RegionStyles.REGION_TRANSPARENT) ||
                        (!selectedWindowMode && Engine.ConfigUI.CropRegionStyles == RegionStyles.REGION_TRANSPARENT))
                    { // If Region Transparent
                        gRegion.FillRectangle(new SolidBrush(Color.FromArgb(Engine.ConfigUI.RegionTransparentValue, Color.White)),
                                              new Rectangle(0, 0, bmpRegion.Width, bmpRegion.Height));
                    }
                    else if ((selectedWindowMode && Engine.ConfigUI.SelectedWindowRegionStyles == RegionStyles.REGION_BRIGHTNESS) ||
                             (!selectedWindowMode && Engine.ConfigUI.CropRegionStyles == RegionStyles.REGION_BRIGHTNESS))
                    { // If Region Brightness
                        ImageAttributes imgattr = new ImageAttributes();
                        imgattr.SetColorMatrix(ColorMatrices.BrightnessFilter(Engine.ConfigUI.RegionBrightnessValue));
                        gRegion.DrawImage(bmpClean, new Rectangle(0, 0, bmpRegion.Width, bmpRegion.Height), 0, 0,
                                          bmpRegion.Width, bmpRegion.Height, GraphicsUnit.Pixel, imgattr);
                    }
                    else if ((selectedWindowMode && Engine.ConfigUI.SelectedWindowRegionStyles == RegionStyles.BACKGROUND_REGION_TRANSPARENT) ||
                             (!selectedWindowMode && Engine.ConfigUI.CropRegionStyles == RegionStyles.BACKGROUND_REGION_TRANSPARENT))
                    { // If Background Region Transparent
                        gBackground.FillRectangle(new SolidBrush(Color.FromArgb(Engine.ConfigUI.BackgroundRegionTransparentValue, Color.White)),
                                                  new Rectangle(0, 0, bmpBackground.Width, bmpBackground.Height));
                    }
                    else if ((selectedWindowMode && Engine.ConfigUI.SelectedWindowRegionStyles == RegionStyles.BACKGROUND_REGION_BRIGHTNESS) ||
                             (!selectedWindowMode && Engine.ConfigUI.CropRegionStyles == RegionStyles.BACKGROUND_REGION_BRIGHTNESS))
                    { // If Background Region Brightness
                        ImageAttributes imgattr = new ImageAttributes();
                        imgattr.SetColorMatrix(ColorMatrices.BrightnessFilter(Engine.ConfigUI.BackgroundRegionBrightnessValue));
                        gBackground.DrawImage(bmpClean, new Rectangle(0, 0, bmpBackground.Width, bmpBackground.Height), 0, 0,
                                              bmpBackground.Width, bmpBackground.Height, GraphicsUnit.Pixel, imgattr);
                    }
                    else if ((selectedWindowMode && Engine.ConfigUI.SelectedWindowRegionStyles == RegionStyles.BACKGROUND_REGION_GRAYSCALE) ||
                             (!selectedWindowMode && Engine.ConfigUI.CropRegionStyles == RegionStyles.BACKGROUND_REGION_GRAYSCALE))
                    { // If Background Region Grayscale
                        ImageAttributes imgattr = new ImageAttributes();
                        imgattr.SetColorMatrix(ColorMatrices.GrayscaleFilter());
                        gBackground.DrawImage(bmpClean, new Rectangle(0, 0, bmpBackground.Width, bmpBackground.Height), 0, 0,
                                              bmpBackground.Width, bmpBackground.Height, GraphicsUnit.Pixel, imgattr);
                    }
                }

            brushClean      = new TextureBrush(bmpClean);
            brushBackground = new TextureBrush(bmpBackground);
            brushRegion     = new TextureBrush(bmpRegion);
        }