mirror of
https://github.com/greenshot/greenshot
synced 2025-08-21 05:53:27 -07:00
Prevent overlapping Area Highlight filters
This commit is contained in:
parent
fcf4b97101
commit
f34aa8d9f2
11 changed files with 33 additions and 13 deletions
|
@ -61,6 +61,8 @@ namespace Greenshot.Base.Interfaces.Drawing
|
||||||
|
|
||||||
bool HasFilters { get; }
|
bool HasFilters { get; }
|
||||||
|
|
||||||
|
bool IsAreaHighlightContainer { get; }
|
||||||
|
|
||||||
EditStatus Status { get; set; }
|
EditStatus Status { get; set; }
|
||||||
|
|
||||||
void Invalidate();
|
void Invalidate();
|
||||||
|
|
|
@ -396,9 +396,11 @@ namespace Greenshot.Editor.Drawing
|
||||||
|
|
||||||
public bool HasFilters => Filters.Count > 0;
|
public bool HasFilters => Filters.Count > 0;
|
||||||
|
|
||||||
|
public bool IsAreaHighlightContainer => Filters.Any(f => f is BrightnessFilter) && Filters.Any(f => f is BlurFilter);
|
||||||
|
|
||||||
public abstract void Draw(Graphics graphics, RenderMode renderMode);
|
public abstract void Draw(Graphics graphics, RenderMode renderMode);
|
||||||
|
|
||||||
public virtual void DrawContent(Graphics graphics, Bitmap bmp, RenderMode renderMode, NativeRect clipRectangle)
|
public virtual void DrawContent(Graphics graphics, Bitmap bmp, RenderMode renderMode, NativeRect clipRectangle, IEnumerable<NativeRect> areasToExcludeFromFilters)
|
||||||
{
|
{
|
||||||
if (Children.Count > 0)
|
if (Children.Count > 0)
|
||||||
{
|
{
|
||||||
|
@ -414,7 +416,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
{
|
{
|
||||||
if (filter.Invert)
|
if (filter.Invert)
|
||||||
{
|
{
|
||||||
filter.Apply(graphics, bmp, Bounds, renderMode);
|
filter.Apply(graphics, bmp, Bounds, renderMode, areasToExcludeFromFilters);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -423,11 +425,11 @@ namespace Greenshot.Editor.Drawing
|
||||||
{
|
{
|
||||||
// quick&dirty bugfix, because MagnifierFilter behaves differently when drawn only partially
|
// quick&dirty bugfix, because MagnifierFilter behaves differently when drawn only partially
|
||||||
// what we should actually do to resolve this is add a better magnifier which is not that special
|
// what we should actually do to resolve this is add a better magnifier which is not that special
|
||||||
filter.Apply(graphics, bmp, Bounds, renderMode);
|
filter.Apply(graphics, bmp, Bounds, renderMode, areasToExcludeFromFilters);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
filter.Apply(graphics, bmp, drawingRect, renderMode);
|
filter.Apply(graphics, bmp, drawingRect, renderMode, areasToExcludeFromFilters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -338,7 +338,8 @@ namespace Greenshot.Editor.Drawing
|
||||||
|
|
||||||
if (dc.DrawingBounds.IntersectsWith(clipRectangle))
|
if (dc.DrawingBounds.IntersectsWith(clipRectangle))
|
||||||
{
|
{
|
||||||
dc.DrawContent(g, bitmap, renderMode, clipRectangle);
|
IEnumerable<NativeRect> areaHighlightContainers = this.Where(c => c.IsAreaHighlightContainer).Select(c => c.Bounds);
|
||||||
|
dc.DrawContent(g, bitmap, renderMode, clipRectangle, areaHighlightContainers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using Dapplo.Windows.Common.Structs;
|
using Dapplo.Windows.Common.Structs;
|
||||||
|
@ -74,7 +75,7 @@ namespace Greenshot.Editor.Drawing.Filters
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void Apply(Graphics graphics, Bitmap applyBitmap, NativeRect rect, RenderMode renderMode);
|
public abstract void Apply(Graphics graphics, Bitmap applyBitmap, NativeRect rect, RenderMode renderMode, IEnumerable<NativeRect> areasToExcludeFromFilters = null);
|
||||||
|
|
||||||
protected void OnPropertyChanged(string propertyName)
|
protected void OnPropertyChanged(string propertyName)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using Dapplo.Windows.Common.Structs;
|
using Dapplo.Windows.Common.Structs;
|
||||||
|
@ -51,7 +52,7 @@ namespace Greenshot.Editor.Drawing.Filters
|
||||||
AddField(GetType(), FieldType.PREVIEW_QUALITY, 1.0d);
|
AddField(GetType(), FieldType.PREVIEW_QUALITY, 1.0d);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Apply(Graphics graphics, Bitmap applyBitmap, NativeRect rect, RenderMode renderMode)
|
public override void Apply(Graphics graphics, Bitmap applyBitmap, NativeRect rect, RenderMode renderMode, IEnumerable<NativeRect> areasToExcludeFromFilters = null)
|
||||||
{
|
{
|
||||||
int blurRadius = GetFieldValueAsInt(FieldType.BLUR_RADIUS);
|
int blurRadius = GetFieldValueAsInt(FieldType.BLUR_RADIUS);
|
||||||
var applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
var applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
||||||
|
@ -65,6 +66,10 @@ namespace Greenshot.Editor.Drawing.Filters
|
||||||
{
|
{
|
||||||
graphics.SetClip(applyRect);
|
graphics.SetClip(applyRect);
|
||||||
graphics.ExcludeClip(rect);
|
graphics.ExcludeClip(rect);
|
||||||
|
foreach (NativeRect area in areasToExcludeFromFilters)
|
||||||
|
{
|
||||||
|
graphics.ExcludeClip(area);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GdiPlusApi.IsBlurPossible(blurRadius))
|
if (GdiPlusApi.IsBlurPossible(blurRadius))
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
|
@ -45,7 +46,7 @@ namespace Greenshot.Editor.Drawing.Filters
|
||||||
/// <param name="applyBitmap"></param>
|
/// <param name="applyBitmap"></param>
|
||||||
/// <param name="rect">NativeRect</param>
|
/// <param name="rect">NativeRect</param>
|
||||||
/// <param name="renderMode"></param>
|
/// <param name="renderMode"></param>
|
||||||
public override void Apply(Graphics graphics, Bitmap applyBitmap, NativeRect rect, RenderMode renderMode)
|
public override void Apply(Graphics graphics, Bitmap applyBitmap, NativeRect rect, RenderMode renderMode, IEnumerable<NativeRect> areasToExcludeFromFilters = null)
|
||||||
{
|
{
|
||||||
var applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
var applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
||||||
|
|
||||||
|
@ -60,6 +61,10 @@ namespace Greenshot.Editor.Drawing.Filters
|
||||||
{
|
{
|
||||||
graphics.SetClip(applyRect);
|
graphics.SetClip(applyRect);
|
||||||
graphics.ExcludeClip(rect);
|
graphics.ExcludeClip(rect);
|
||||||
|
foreach (NativeRect area in areasToExcludeFromFilters)
|
||||||
|
{
|
||||||
|
graphics.ExcludeClip(area);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float brightness = GetFieldValueAsFloat(FieldType.BRIGHTNESS);
|
float brightness = GetFieldValueAsFloat(FieldType.BRIGHTNESS);
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
|
@ -39,7 +40,7 @@ namespace Greenshot.Editor.Drawing.Filters
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Apply(Graphics graphics, Bitmap applyBitmap, NativeRect rect, RenderMode renderMode)
|
public override void Apply(Graphics graphics, Bitmap applyBitmap, NativeRect rect, RenderMode renderMode, IEnumerable<NativeRect> areasToExcludeFromFilters = null)
|
||||||
{
|
{
|
||||||
var applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
var applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using Dapplo.Windows.Common.Structs;
|
using Dapplo.Windows.Common.Structs;
|
||||||
|
@ -47,7 +48,7 @@ namespace Greenshot.Editor.Drawing.Filters
|
||||||
/// <param name="applyBitmap"></param>
|
/// <param name="applyBitmap"></param>
|
||||||
/// <param name="rect">NativeRect</param>
|
/// <param name="rect">NativeRect</param>
|
||||||
/// <param name="renderMode"></param>
|
/// <param name="renderMode"></param>
|
||||||
public override void Apply(Graphics graphics, Bitmap applyBitmap, NativeRect rect, RenderMode renderMode)
|
public override void Apply(Graphics graphics, Bitmap applyBitmap, NativeRect rect, RenderMode renderMode, IEnumerable<NativeRect> areasToExcludeFromFilters = null)
|
||||||
{
|
{
|
||||||
var applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
var applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using Dapplo.Windows.Common.Structs;
|
using Dapplo.Windows.Common.Structs;
|
||||||
|
@ -29,7 +30,7 @@ namespace Greenshot.Editor.Drawing.Filters
|
||||||
public interface IFilter : INotifyPropertyChanged, IFieldHolder
|
public interface IFilter : INotifyPropertyChanged, IFieldHolder
|
||||||
{
|
{
|
||||||
DrawableContainer Parent { get; set; }
|
DrawableContainer Parent { get; set; }
|
||||||
void Apply(Graphics graphics, Bitmap bmp, NativeRect rect, RenderMode renderMode);
|
void Apply(Graphics graphics, Bitmap bmp, NativeRect rect, RenderMode renderMode, IEnumerable<NativeRect> areasToExcludeFromFilters = null);
|
||||||
DrawableContainer GetParent();
|
DrawableContainer GetParent();
|
||||||
bool Invert { get; set; }
|
bool Invert { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using Dapplo.Windows.Common.Structs;
|
using Dapplo.Windows.Common.Structs;
|
||||||
|
@ -40,7 +41,7 @@ namespace Greenshot.Editor.Drawing.Filters
|
||||||
AddField(GetType(), FieldType.MAGNIFICATION_FACTOR, 2);
|
AddField(GetType(), FieldType.MAGNIFICATION_FACTOR, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Apply(Graphics graphics, Bitmap applyBitmap, NativeRect rect, RenderMode renderMode)
|
public override void Apply(Graphics graphics, Bitmap applyBitmap, NativeRect rect, RenderMode renderMode, IEnumerable<NativeRect> areasToExcludeFromFilters = null)
|
||||||
{
|
{
|
||||||
var applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
var applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace Greenshot.Editor.Drawing.Filters
|
||||||
AddField(GetType(), FieldType.PIXEL_SIZE, 5);
|
AddField(GetType(), FieldType.PIXEL_SIZE, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Apply(Graphics graphics, Bitmap applyBitmap, NativeRect rect, RenderMode renderMode)
|
public override void Apply(Graphics graphics, Bitmap applyBitmap, NativeRect rect, RenderMode renderMode, IEnumerable<NativeRect> areasToExcludeFromFilters = null)
|
||||||
{
|
{
|
||||||
int pixelSize = GetFieldValueAsInt(FieldType.PIXEL_SIZE);
|
int pixelSize = GetFieldValueAsInt(FieldType.PIXEL_SIZE);
|
||||||
ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue