mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-04 12:14:45 +13:00
Apply drawings to all capture methods inside region capture
This commit is contained in:
parent
a1175b13b6
commit
7eaac502c7
3 changed files with 84 additions and 72 deletions
|
@ -694,31 +694,26 @@ public void UpdateRegionPath()
|
|||
}
|
||||
}
|
||||
|
||||
public override Image GetResultImage()
|
||||
{
|
||||
if (SurfaceImage != null)
|
||||
protected override Image GetOutputImage()
|
||||
{
|
||||
Image img = base.GetOutputImage();
|
||||
|
||||
if (AreaManager.DrawingShapes.Length > 0)
|
||||
{
|
||||
using (Bitmap bmp = new Bitmap(SurfaceImage))
|
||||
using (Graphics g = Graphics.FromImage(bmp))
|
||||
using (Bitmap bmpCopy = new Bitmap(img))
|
||||
using (Graphics g = Graphics.FromImage(img))
|
||||
{
|
||||
foreach (BaseDrawingShape shape in AreaManager.DrawingShapes)
|
||||
{
|
||||
if (shape != null)
|
||||
{
|
||||
shape.DrawOutput(g, bmp);
|
||||
shape.DrawOutput(g, bmpCopy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ShapeCaptureHelpers.GetRegionImage(bmp, regionFillPath, regionDrawPath, Config);
|
||||
}
|
||||
}
|
||||
|
||||
return ShapeCaptureHelpers.GetRegionImage(SurfaceImage, regionFillPath, regionDrawPath, Config);
|
||||
}
|
||||
|
||||
return null;
|
||||
return img;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
|
|
|
@ -139,7 +139,7 @@ public virtual void Prepare()
|
|||
using (Bitmap darkBackground = (Bitmap)SurfaceImage.Clone())
|
||||
using (Graphics g = Graphics.FromImage(darkBackground))
|
||||
{
|
||||
using (Brush brush = new SolidBrush(Color.FromArgb(50, Color.Black)))
|
||||
using (Brush brush = new SolidBrush(Color.FromArgb(40, Color.Black)))
|
||||
{
|
||||
g.FillRectangle(brush, 0, 0, darkBackground.Width, darkBackground.Height);
|
||||
}
|
||||
|
@ -260,7 +260,48 @@ protected override void OnPaint(PaintEventArgs e)
|
|||
|
||||
public virtual Image GetResultImage()
|
||||
{
|
||||
return ShapeCaptureHelpers.GetRegionImage(SurfaceImage, regionFillPath, regionDrawPath, Config);
|
||||
if (Result == SurfaceResult.Region)
|
||||
{
|
||||
using (Image img = GetOutputImage())
|
||||
{
|
||||
return ShapeCaptureHelpers.GetRegionImage(img, regionFillPath, regionDrawPath, Config);
|
||||
}
|
||||
}
|
||||
else if (Result == SurfaceResult.Fullscreen)
|
||||
{
|
||||
return GetOutputImage();
|
||||
}
|
||||
else if (Result == SurfaceResult.Monitor)
|
||||
{
|
||||
Screen[] screens = Screen.AllScreens;
|
||||
|
||||
if (MonitorIndex < screens.Length)
|
||||
{
|
||||
Screen screen = screens[MonitorIndex];
|
||||
Rectangle screenRect = CaptureHelpers.ScreenToClient(screen.Bounds);
|
||||
|
||||
using (Image img = GetOutputImage())
|
||||
{
|
||||
return ImageHelpers.CropImage(img, screenRect);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Result == SurfaceResult.ActiveMonitor)
|
||||
{
|
||||
Rectangle activeScreenRect = CaptureHelpers.GetActiveScreenBounds0Based();
|
||||
|
||||
using (Image img = GetOutputImage())
|
||||
{
|
||||
return ImageHelpers.CropImage(img, activeScreenRect);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected virtual Image GetOutputImage()
|
||||
{
|
||||
return (Image)SurfaceImage.Clone();
|
||||
}
|
||||
|
||||
public virtual WindowInfo GetWindowInfo()
|
||||
|
|
|
@ -2091,22 +2091,22 @@ private void CaptureRegion(CaptureType captureType, TaskSettings taskSettings, b
|
|||
DoCapture(() =>
|
||||
{
|
||||
Image img = null;
|
||||
Image screenshot = Screenshot.CaptureFullscreen();
|
||||
Image screenshot = null;
|
||||
|
||||
try
|
||||
{
|
||||
screenshot = Screenshot.CaptureFullscreen();
|
||||
|
||||
surface.Config = taskSettings.CaptureSettingsReference.SurfaceOptions;
|
||||
surface.SurfaceImage = screenshot;
|
||||
surface.Prepare();
|
||||
surface.ShowDialog();
|
||||
|
||||
if (surface.Result == SurfaceResult.Region)
|
||||
{
|
||||
using (screenshot)
|
||||
{
|
||||
img = surface.GetResultImage();
|
||||
|
||||
if (taskSettings.UploadSettings.RegionCaptureUseWindowPattern)
|
||||
if (img != null)
|
||||
{
|
||||
if (surface.Result == SurfaceResult.Region && taskSettings.UploadSettings.RegionCaptureUseWindowPattern)
|
||||
{
|
||||
WindowInfo windowInfo = surface.GetWindowInfo();
|
||||
|
||||
|
@ -2119,47 +2119,23 @@ private void CaptureRegion(CaptureType captureType, TaskSettings taskSettings, b
|
|||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (surface.Result == SurfaceResult.Fullscreen)
|
||||
{
|
||||
img = screenshot;
|
||||
}
|
||||
else if (surface.Result == SurfaceResult.Monitor)
|
||||
{
|
||||
Screen[] screens = Screen.AllScreens;
|
||||
|
||||
if (surface.MonitorIndex < screens.Length)
|
||||
{
|
||||
Screen screen = screens[surface.MonitorIndex];
|
||||
Rectangle screenRect = CaptureHelpers.ScreenToClient(screen.Bounds);
|
||||
|
||||
using (screenshot)
|
||||
{
|
||||
img = ImageHelpers.CropImage(screenshot, screenRect);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (surface.Result == SurfaceResult.ActiveMonitor)
|
||||
{
|
||||
Rectangle activeScreenRect = CaptureHelpers.GetActiveScreenBounds0Based();
|
||||
|
||||
using (screenshot)
|
||||
{
|
||||
img = ImageHelpers.CropImage(screenshot, activeScreenRect);
|
||||
}
|
||||
}
|
||||
|
||||
if (img != null)
|
||||
{
|
||||
lastRegionCaptureType = LastRegionCaptureType.Surface;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (surface != null)
|
||||
{
|
||||
surface.Dispose();
|
||||
}
|
||||
|
||||
if (screenshot != null)
|
||||
{
|
||||
screenshot.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
return img;
|
||||
}, captureType, taskSettings, autoHideForm);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue