Ejemplo n.º 1
0
        /// <summary>
        /// Gets the RegionCaptureInfo for the given region capture.
        /// </summary>
        /// <returns> The image/color captured and other info.</returns>
        public RegionReturn GetRsult()
        {
            if (result == RegionResult.Region)
            {
                if (leftClickStart.X < leftClickStop.X)
                {
                    leftClickStop = new Point(leftClickStop.X + 1, leftClickStop.Y);
                }
                else
                {
                    leftClickStop = new Point(leftClickStop.X - 1, leftClickStop.Y);
                }

                if (leftClickStart.Y < leftClickStop.Y)
                {
                    leftClickStop = new Point(leftClickStop.X, leftClickStop.Y + 1);
                }
                else
                {
                    leftClickStop = new Point(leftClickStop.X, leftClickStop.Y - 1);
                }
            }

            switch (result)
            {
            case RegionResult.Close:
                return(new RegionReturn(RegionResult.Close));

            case RegionResult.Region:
                return(new RegionReturn(
                           RegionResult.Region,
                           PointToScreen(leftClickStart),
                           PointToScreen(leftClickStop),
                           Helper.CreateRect(leftClickStart, leftClickStop),
                           ImageProcessor.GetCroppedBitmap(leftClickStart, leftClickStop, image, PixelFormat.Format24bppRgb)));

            case RegionResult.LastRegion:
                return(new RegionReturn(
                           RegionResult.LastRegion,
                           LastRegionReturn.StartLeftClick,
                           LastRegionReturn.StopLeftClick,
                           LastRegionReturn.Region,
                           ImageProcessor.GetCroppedBitmap(LastRegionReturn.Region, image, PixelFormat.Format24bppRgb)));

            case RegionResult.Fullscreen:
                return(new RegionReturn(RegionResult.Fullscreen, true, image));

            case RegionResult.ActiveMonitor:
                return(new RegionReturn(
                           Screen.FromPoint(ScreenHelper.GetCursorPosition()),
                           ImageProcessor.GetCroppedBitmap(ScreenHelper.GetActiveScreenBounds0Based(), image, PixelFormat.Format24bppRgb)));

            case RegionResult.Color:
                return(new RegionReturn(
                           PointToScreen(leftClickStop),
                           image.GetPixel(leftClickStop.X, leftClickStop.Y)));
            }
            return(null);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Crop the current bitmap and track the change. (will call a reference update event)
        /// </summary>
        /// <param name="crop"></param>
        public void CropImage(Rectangle crop)
        {
            if (CurrentBitmap == null)
            {
                return;
            }

            TrackChange(BitmapChanges.Cropped);

            Image i = ImageProcessor.GetCroppedBitmap(crop, CurrentBitmap, CurrentBitmap.Image.PixelFormat);

            CurrentBitmap.UpdateImage(i);
        }