Ejemplo n.º 1
0
        private void PerformScreenshot(bool shouldCrop)
        {
            var screenshotPath = GenerateFilename();
            var curScreen      = GetCurrentScreen();
            var bmpScreenshot  = new Bitmap(curScreen.Bounds.Width, curScreen.Bounds.Height, PixelFormat.Format32bppArgb);
            var gfxScreenshot  = Graphics.FromImage(bmpScreenshot);

            gfxScreenshot.CopyFromScreen(curScreen.Bounds.X, curScreen.Bounds.Y, 0, 0, curScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
            bmpScreenshot.Save(screenshotPath, ImageFormat.Png);

            if (!shouldCrop)
            {
                UploadScreenshot(screenshotPath);
                return;
            }

            var formDisplayImage = new FormDisplayImage(bmpScreenshot);

            formDisplayImage.SetScreen(curScreen);
            formDisplayImage.ShowDialog();

            if (formDisplayImage.HasSelection)
            {
                var croppedImageName = Path.GetFileNameWithoutExtension(screenshotPath) + "-cropped.png";
                formDisplayImage.SelectedBitmap.Save(croppedImageName, ImageFormat.Png);

                UploadScreenshot(croppedImageName);
            }
        }
Ejemplo n.º 2
0
        private void PerformScreenshot(bool shouldCrop)
        {
            var screenshotPath = GenerateFilename();
            var curScreen = GetCurrentScreen();
            var bmpScreenshot = new Bitmap(curScreen.Bounds.Width, curScreen.Bounds.Height, PixelFormat.Format32bppArgb);
            var gfxScreenshot = Graphics.FromImage(bmpScreenshot);

            gfxScreenshot.CopyFromScreen(curScreen.Bounds.X, curScreen.Bounds.Y, 0, 0, curScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
            bmpScreenshot.Save(screenshotPath, ImageFormat.Png);

            if (!shouldCrop)
            {
                UploadScreenshot(screenshotPath);
                return;
            }

            var formDisplayImage = new FormDisplayImage(bmpScreenshot);
            formDisplayImage.SetScreen(curScreen);
            formDisplayImage.ShowDialog();

            if (formDisplayImage.HasSelection)
            {
                var croppedImageName = Path.GetFileNameWithoutExtension(screenshotPath) + "-cropped.png";
                formDisplayImage.SelectedBitmap.Save(croppedImageName, ImageFormat.Png);

                UploadScreenshot(croppedImageName);
            }
        }