mirror of
https://github.com/greenshot/greenshot
synced 2025-07-14 00:53:51 -07:00
Cleanup for code-analyses 2nd phase
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2483 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
157cace477
commit
5ffe3dfb42
15 changed files with 190 additions and 137 deletions
|
@ -56,10 +56,6 @@ namespace Greenshot.Drawing {
|
||||||
get { return cursor; }
|
get { return cursor; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose() {
|
|
||||||
base.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
// The bulk of the clean-up code is implemented in Dispose(bool)
|
// The bulk of the clean-up code is implemented in Dispose(bool)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -44,17 +44,23 @@ namespace Greenshot.Drawing.Filters {
|
||||||
|
|
||||||
private bool invert = false;
|
private bool invert = false;
|
||||||
public bool Invert {
|
public bool Invert {
|
||||||
get { return invert; }
|
get {
|
||||||
set { invert=value; OnPropertyChanged("Invert"); }
|
return invert;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
invert = value;
|
||||||
|
OnPropertyChanged("Invert");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
[NonSerialized]
|
|
||||||
protected BitmapBuffer bbb;
|
|
||||||
|
|
||||||
protected Rectangle applyRect;
|
|
||||||
protected DrawableContainer parent;
|
protected DrawableContainer parent;
|
||||||
public DrawableContainer Parent {
|
public DrawableContainer Parent {
|
||||||
get {return parent;}
|
get {
|
||||||
set {parent = value;}
|
return parent;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
parent = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractFilter(DrawableContainer parent) {
|
public AbstractFilter(DrawableContainer parent) {
|
||||||
|
@ -65,36 +71,12 @@ namespace Greenshot.Drawing.Filters {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) {
|
public abstract void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode);
|
||||||
applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
|
||||||
|
|
||||||
if (applyRect.Width == 0 || applyRect.Height == 0) {
|
|
||||||
// nothing to do
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bbb = new BitmapBuffer(applyBitmap, applyRect);
|
|
||||||
try {
|
|
||||||
bbb.Lock();
|
|
||||||
for(int y=0;y<bbb.Height; y++) {
|
|
||||||
for(int x=0;x<bbb.Width; x++) {
|
|
||||||
if(parent.Contains(applyRect.Left+x, applyRect.Top+y) ^ Invert) {
|
|
||||||
IteratePixel(x, y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
bbb.DrawTo(graphics, applyRect.Location);
|
|
||||||
bbb.Dispose();
|
|
||||||
bbb = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void IteratePixel(int x, int y) {}
|
|
||||||
|
|
||||||
protected void OnPropertyChanged(string propertyName) {
|
protected void OnPropertyChanged(string propertyName) {
|
||||||
if(propertyChanged != null) propertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
if (propertyChanged != null) {
|
||||||
|
propertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,31 +22,50 @@ using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using Greenshot.Drawing.Fields;
|
using Greenshot.Drawing.Fields;
|
||||||
using Greenshot.Plugin.Drawing;
|
using Greenshot.Plugin.Drawing;
|
||||||
|
using GreenshotPlugin.Core;
|
||||||
|
|
||||||
namespace Greenshot.Drawing.Filters {
|
namespace Greenshot.Drawing.Filters {
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
public class BrightnessFilter : AbstractFilter {
|
public class BrightnessFilter : AbstractFilter {
|
||||||
|
|
||||||
private double brightness;
|
|
||||||
|
|
||||||
public BrightnessFilter(DrawableContainer parent) : base(parent) {
|
public BrightnessFilter(DrawableContainer parent) : base(parent) {
|
||||||
AddField(GetType(), FieldType.BRIGHTNESS, 0.9d);
|
AddField(GetType(), FieldType.BRIGHTNESS, 0.9d);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void IteratePixel(int x, int y) {
|
/// <summary>
|
||||||
Color color = bbb.GetColorAt(x, y);
|
/// Implements the Apply code for the Brightness Filet
|
||||||
int r = Convert.ToInt16(color.R*brightness);
|
/// </summary>
|
||||||
int g = Convert.ToInt16(color.G*brightness);
|
/// <param name="graphics"></param>
|
||||||
int b = Convert.ToInt16(color.B*brightness);
|
/// <param name="applyBitmap"></param>
|
||||||
r = (r>255) ? 255 : r;
|
/// <param name="rect"></param>
|
||||||
g = (g>255) ? 255 : g;
|
/// <param name="renderMode"></param>
|
||||||
b = (b>255) ? 255 : b;
|
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) {
|
||||||
bbb.SetColorAt(x, y, Color.FromArgb(color.A, r, g, b));
|
Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
||||||
}
|
|
||||||
|
if (applyRect.Width == 0 || applyRect.Height == 0) {
|
||||||
public override void Apply(Graphics graphics, Bitmap bmp, Rectangle rect, RenderMode renderMode) {
|
// nothing to do
|
||||||
brightness = GetFieldValueAsDouble(FieldType.BRIGHTNESS);
|
return;
|
||||||
base.Apply(graphics, bmp, rect, renderMode);
|
}
|
||||||
|
|
||||||
|
using (BitmapBuffer bbb = new BitmapBuffer(applyBitmap, applyRect)) {
|
||||||
|
bbb.Lock();
|
||||||
|
double brightness = GetFieldValueAsDouble(FieldType.BRIGHTNESS);
|
||||||
|
for (int y = 0; y < bbb.Height; y++) {
|
||||||
|
for (int x = 0; x < bbb.Width; x++) {
|
||||||
|
if (parent.Contains(applyRect.Left + x, applyRect.Top + y) ^ Invert) {
|
||||||
|
Color color = bbb.GetColorAt(x, y);
|
||||||
|
int r = Convert.ToInt16(color.R * brightness);
|
||||||
|
int g = Convert.ToInt16(color.G * brightness);
|
||||||
|
int b = Convert.ToInt16(color.B * brightness);
|
||||||
|
r = (r > 255) ? 255 : r;
|
||||||
|
g = (g > 255) ? 255 : g;
|
||||||
|
b = (b > 255) ? 255 : b;
|
||||||
|
bbb.SetColorAt(x, y, Color.FromArgb(color.A, r, g, b));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bbb.DrawTo(graphics, applyRect.Location);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using GreenshotPlugin.Core;
|
||||||
|
using Greenshot.Plugin.Drawing;
|
||||||
|
|
||||||
namespace Greenshot.Drawing.Filters {
|
namespace Greenshot.Drawing.Filters {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -29,12 +31,29 @@ namespace Greenshot.Drawing.Filters {
|
||||||
public class GrayscaleFilter : AbstractFilter {
|
public class GrayscaleFilter : AbstractFilter {
|
||||||
public GrayscaleFilter(DrawableContainer parent) : base(parent) {
|
public GrayscaleFilter(DrawableContainer parent) : base(parent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void IteratePixel(int x, int y) {
|
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) {
|
||||||
Color color = bbb.GetColorAt(x, y);
|
Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
||||||
int luma = (int)((0.3*color.R) + (0.59*color.G) + (0.11*color.B));
|
|
||||||
color = Color.FromArgb(luma, luma, luma);
|
if (applyRect.Width == 0 || applyRect.Height == 0) {
|
||||||
bbb.SetColorAt(x, y, color);
|
// nothing to do
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using (BitmapBuffer bbb = new BitmapBuffer(applyBitmap, applyRect)) {
|
||||||
|
bbb.Lock();
|
||||||
|
for (int y = 0; y < bbb.Height; y++) {
|
||||||
|
for (int x = 0; x < bbb.Width; x++) {
|
||||||
|
if (parent.Contains(applyRect.Left + x, applyRect.Top + y) ^ Invert) {
|
||||||
|
Color color = bbb.GetColorAt(x, y);
|
||||||
|
int luma = (int)((0.3 * color.R) + (0.59 * color.G) + (0.11 * color.B));
|
||||||
|
color = Color.FromArgb(luma, luma, luma);
|
||||||
|
bbb.SetColorAt(x, y, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bbb.DrawTo(graphics, applyRect.Location);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,26 +22,44 @@ using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using Greenshot.Drawing.Fields;
|
using Greenshot.Drawing.Fields;
|
||||||
using Greenshot.Plugin.Drawing;
|
using Greenshot.Plugin.Drawing;
|
||||||
|
using GreenshotPlugin.Core;
|
||||||
|
|
||||||
namespace Greenshot.Drawing.Filters {
|
namespace Greenshot.Drawing.Filters {
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
public class HighlightFilter : AbstractFilter {
|
public class HighlightFilter : AbstractFilter {
|
||||||
[NonSerialized]
|
|
||||||
private Color highlightColor;
|
|
||||||
|
|
||||||
public HighlightFilter(DrawableContainer parent) : base(parent) {
|
public HighlightFilter(DrawableContainer parent) : base(parent) {
|
||||||
AddField(GetType(), FieldType.FILL_COLOR, Color.Yellow);
|
AddField(GetType(), FieldType.FILL_COLOR, Color.Yellow);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void IteratePixel(int x, int y) {
|
|
||||||
Color color = bbb.GetColorAt(x, y);
|
|
||||||
color = Color.FromArgb(color.A, Math.Min(highlightColor.R,color.R), Math.Min(highlightColor.G,color.G), Math.Min(highlightColor.B,color.B));
|
|
||||||
bbb.SetColorAt(x, y, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Apply(Graphics graphics, Bitmap bmp, Rectangle rect, RenderMode renderMode) {
|
/// <summary>
|
||||||
highlightColor = GetFieldValueAsColor(FieldType.FILL_COLOR);
|
/// Implements the Apply code for the Brightness Filet
|
||||||
base.Apply(graphics, bmp, rect, renderMode);
|
/// </summary>
|
||||||
|
/// <param name="graphics"></param>
|
||||||
|
/// <param name="applyBitmap"></param>
|
||||||
|
/// <param name="rect"></param>
|
||||||
|
/// <param name="renderMode"></param>
|
||||||
|
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) {
|
||||||
|
Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
||||||
|
|
||||||
|
if (applyRect.Width == 0 || applyRect.Height == 0) {
|
||||||
|
// nothing to do
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using (BitmapBuffer bbb = new BitmapBuffer(applyBitmap, applyRect)) {
|
||||||
|
bbb.Lock();
|
||||||
|
Color highlightColor = GetFieldValueAsColor(FieldType.FILL_COLOR);
|
||||||
|
for (int y = 0; y < bbb.Height; y++) {
|
||||||
|
for (int x = 0; x < bbb.Width; x++) {
|
||||||
|
if (parent.Contains(applyRect.Left + x, applyRect.Top + y) ^ Invert) {
|
||||||
|
Color color = bbb.GetColorAt(x, y);
|
||||||
|
color = Color.FromArgb(color.A, Math.Min(highlightColor.R, color.R), Math.Min(highlightColor.G, color.G), Math.Min(highlightColor.B, color.B));
|
||||||
|
bbb.SetColorAt(x, y, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bbb.DrawTo(graphics, applyRect.Location);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,34 +27,37 @@ using GreenshotPlugin.Core;
|
||||||
namespace Greenshot.Drawing.Filters {
|
namespace Greenshot.Drawing.Filters {
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class MagnifierFilter : AbstractFilter {
|
public class MagnifierFilter : AbstractFilter {
|
||||||
|
|
||||||
[NonSerialized]
|
|
||||||
private BitmapBuffer bbbSrc;
|
|
||||||
private int magnificationFactor;
|
|
||||||
|
|
||||||
public MagnifierFilter(DrawableContainer parent) : base(parent) {
|
public MagnifierFilter(DrawableContainer parent) : base(parent) {
|
||||||
AddField(GetType(), FieldType.MAGNIFICATION_FACTOR, 2);
|
AddField(GetType(), FieldType.MAGNIFICATION_FACTOR, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) {
|
|
||||||
magnificationFactor = GetFieldValueAsInt(FieldType.MAGNIFICATION_FACTOR);
|
|
||||||
applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
|
||||||
|
|
||||||
using (bbbSrc = new BitmapBuffer(applyBitmap, applyRect)) {
|
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) {
|
||||||
bbbSrc.Lock();
|
Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
||||||
base.Apply(graphics, applyBitmap, applyRect, renderMode);
|
|
||||||
|
if (applyRect.Width == 0 || applyRect.Height == 0) {
|
||||||
|
// nothing to do
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int magnificationFactor = GetFieldValueAsInt(FieldType.MAGNIFICATION_FACTOR);
|
||||||
|
|
||||||
|
using (BitmapBuffer bbb = new BitmapBuffer(applyBitmap, applyRect)) {
|
||||||
|
int halfWidth = bbb.Size.Width / 2;
|
||||||
|
int halfHeight = bbb.Size.Height / 2;
|
||||||
|
bbb.Lock();
|
||||||
|
using (BitmapBuffer bbbSrc = new BitmapBuffer(applyBitmap, applyRect)) {
|
||||||
|
for (int y = 0; y < bbb.Height; y++) {
|
||||||
|
int yDistanceFromCenter = halfHeight - y;
|
||||||
|
for (int x = 0; x < bbb.Width; x++) {
|
||||||
|
int xDistanceFromCenter = halfWidth - x;
|
||||||
|
if (parent.Contains(applyRect.Left + x, applyRect.Top + y) ^ Invert) {
|
||||||
|
Color color = bbbSrc.GetColorAt(halfWidth - xDistanceFromCenter / magnificationFactor, halfHeight - yDistanceFromCenter / magnificationFactor);
|
||||||
|
bbb.SetColorAt(x, y, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bbb.DrawTo(graphics, applyRect.Location);
|
||||||
}
|
}
|
||||||
bbbSrc = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void IteratePixel(int x, int y) {
|
|
||||||
int halfWidth = bbb.Size.Width/2;
|
|
||||||
int halfHeight = bbb.Size.Height/2;
|
|
||||||
int yDistanceFromCenter = halfHeight-y;
|
|
||||||
int xDistanceFromCenter = halfWidth-x;
|
|
||||||
Color color = bbbSrc.GetColorAt(halfWidth-xDistanceFromCenter/magnificationFactor,halfHeight-yDistanceFromCenter/magnificationFactor);
|
|
||||||
bbb.SetColorAt(x, y, color);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,35 +35,40 @@ namespace Greenshot.Drawing.Filters {
|
||||||
AddField(GetType(), FieldType.PIXEL_SIZE, 5);
|
AddField(GetType(), FieldType.PIXEL_SIZE, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, int pixelSize) {
|
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) {
|
||||||
|
int pixelSize = GetFieldValueAsInt(FieldType.PIXEL_SIZE);
|
||||||
if(pixelSize <= 1 || rect.Width == 0 || rect.Height == 0) {
|
Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
||||||
|
if (pixelSize <= 1 || rect.Width == 0 || rect.Height == 0) {
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(rect.Width < pixelSize) pixelSize = rect.Width;
|
if (rect.Width < pixelSize) {
|
||||||
if(rect.Height < pixelSize) pixelSize = rect.Height;
|
pixelSize = rect.Width;
|
||||||
|
}
|
||||||
|
if (rect.Height < pixelSize) {
|
||||||
|
pixelSize = rect.Height;
|
||||||
|
}
|
||||||
|
|
||||||
using (BitmapBuffer bbbDest = new BitmapBuffer(applyBitmap, rect)) {
|
using (BitmapBuffer bbbDest = new BitmapBuffer(applyBitmap, rect)) {
|
||||||
bbbDest.Lock();
|
bbbDest.Lock();
|
||||||
using(BitmapBuffer bbbSrc = new BitmapBuffer(applyBitmap, rect)) {
|
using (BitmapBuffer bbbSrc = new BitmapBuffer(applyBitmap, rect)) {
|
||||||
bbbSrc.Lock();
|
bbbSrc.Lock();
|
||||||
List<Color> colors = new List<Color>();
|
List<Color> colors = new List<Color>();
|
||||||
int halbPixelSize = pixelSize/2;
|
int halbPixelSize = pixelSize / 2;
|
||||||
for(int y=-halbPixelSize;y<bbbSrc.Height+halbPixelSize; y=y+pixelSize) {
|
for (int y = -halbPixelSize; y < bbbSrc.Height + halbPixelSize; y = y + pixelSize) {
|
||||||
for(int x=-halbPixelSize;x<=bbbSrc.Width+halbPixelSize; x=x+pixelSize) {
|
for (int x = -halbPixelSize; x <= bbbSrc.Width + halbPixelSize; x = x + pixelSize) {
|
||||||
colors.Clear();
|
colors.Clear();
|
||||||
for(int yy=y;yy<y+pixelSize;yy++) {
|
for (int yy = y; yy < y + pixelSize; yy++) {
|
||||||
if (yy >=0 && yy < bbbSrc.Height) {
|
if (yy >= 0 && yy < bbbSrc.Height) {
|
||||||
for(int xx=x;xx<x+pixelSize;xx++) {
|
for (int xx = x; xx < x + pixelSize; xx++) {
|
||||||
colors.Add(bbbSrc.GetColorAt(xx,yy));
|
colors.Add(bbbSrc.GetColorAt(xx, yy));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Color currentAvgColor = Colors.Mix(colors);
|
Color currentAvgColor = Colors.Mix(colors);
|
||||||
for(int yy=y;yy<=y+pixelSize;yy++) {
|
for (int yy = y; yy <= y + pixelSize; yy++) {
|
||||||
if (yy >=0 && yy < bbbSrc.Height) {
|
if (yy >= 0 && yy < bbbSrc.Height) {
|
||||||
for(int xx=x;xx<=x+pixelSize;xx++) {
|
for (int xx = x; xx <= x + pixelSize; xx++) {
|
||||||
bbbDest.SetColorAt(xx, yy, currentAvgColor);
|
bbbDest.SetColorAt(xx, yy, currentAvgColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,12 +79,5 @@ namespace Greenshot.Drawing.Filters {
|
||||||
bbbDest.DrawTo(graphics, rect.Location);
|
bbbDest.DrawTo(graphics, rect.Location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) {
|
|
||||||
int pixelSize = GetFieldValueAsInt(FieldType.PIXEL_SIZE);
|
|
||||||
applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
|
||||||
|
|
||||||
Apply(graphics, applyBitmap, applyRect, pixelSize);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -434,16 +434,6 @@ namespace Greenshot.Drawing {
|
||||||
captureDetails = capture.CaptureDetails;
|
captureDetails = capture.CaptureDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The public accessible Dispose
|
|
||||||
/// Will call the GarbageCollector to SuppressFinalize, preventing being cleaned twice
|
|
||||||
/// </summary>
|
|
||||||
public new void Dispose() {
|
|
||||||
Dispose(true);
|
|
||||||
base.Dispose();
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Dispose(bool disposing) {
|
protected override void Dispose(bool disposing) {
|
||||||
if (disposing) {
|
if (disposing) {
|
||||||
Count--;
|
Count--;
|
||||||
|
@ -464,6 +454,17 @@ namespace Greenshot.Drawing {
|
||||||
while (redoStack != null && redoStack.Count > 0) {
|
while (redoStack != null && redoStack.Count > 0) {
|
||||||
redoStack.Pop().Dispose();
|
redoStack.Pop().Dispose();
|
||||||
}
|
}
|
||||||
|
foreach (IDrawableContainer container in elements) {
|
||||||
|
container.Dispose();
|
||||||
|
}
|
||||||
|
if (undrawnElement != null) {
|
||||||
|
undrawnElement.Dispose();
|
||||||
|
undrawnElement = null;
|
||||||
|
}
|
||||||
|
if (cropContainer != null) {
|
||||||
|
cropContainer.Dispose();
|
||||||
|
cropContainer = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
|
@ -909,7 +910,7 @@ namespace Greenshot.Drawing {
|
||||||
ex.Data.Add("Width", Image.Width);
|
ex.Data.Add("Width", Image.Width);
|
||||||
ex.Data.Add("Height", Image.Height);
|
ex.Data.Add("Height", Image.Height);
|
||||||
ex.Data.Add("Pixelformat", Image.PixelFormat);
|
ex.Data.Add("Pixelformat", Image.PixelFormat);
|
||||||
throw ex;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
Point offset = new Point(-cropRectangle.Left, -cropRectangle.Top);
|
Point offset = new Point(-cropRectangle.Left, -cropRectangle.Top);
|
||||||
|
|
|
@ -132,7 +132,12 @@ namespace Greenshot {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AboutForm() {
|
public AboutForm() {
|
||||||
// Make sure our resources are removed again.
|
// Make sure our resources are removed again.
|
||||||
this.Disposed += delegate { Cleanup(); };
|
this.Disposed += delegate {
|
||||||
|
Cleanup();
|
||||||
|
};
|
||||||
|
this.FormClosing += delegate {
|
||||||
|
Cleanup();
|
||||||
|
};
|
||||||
|
|
||||||
// Enable animation for this form, when we don't set this the timer doesn't start as soon as the form is loaded.
|
// Enable animation for this form, when we don't set this the timer doesn't start as soon as the form is loaded.
|
||||||
EnableAnimation = true;
|
EnableAnimation = true;
|
||||||
|
@ -228,6 +233,9 @@ namespace Greenshot {
|
||||||
/// Called from the AnimatingForm, for every frame
|
/// Called from the AnimatingForm, for every frame
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override void Animate() {
|
protected override void Animate() {
|
||||||
|
if (gBitmap == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!isTerminalServerSession) {
|
if (!isTerminalServerSession) {
|
||||||
// Color cycle
|
// Color cycle
|
||||||
if (waitFrames != 0) {
|
if (waitFrames != 0) {
|
||||||
|
|
|
@ -35,6 +35,7 @@ using GreenshotPlugin.UnmanagedHelpers;
|
||||||
using GreenshotPlugin.Core;
|
using GreenshotPlugin.Core;
|
||||||
using Greenshot.IniFile;
|
using Greenshot.IniFile;
|
||||||
using GreenshotPlugin.Controls;
|
using GreenshotPlugin.Controls;
|
||||||
|
using System.Security.Permissions;
|
||||||
|
|
||||||
namespace Greenshot.Forms {
|
namespace Greenshot.Forms {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -106,6 +107,7 @@ namespace Greenshot.Forms {
|
||||||
/// This should prevent childs to draw backgrounds
|
/// This should prevent childs to draw backgrounds
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override CreateParams CreateParams {
|
protected override CreateParams CreateParams {
|
||||||
|
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
|
||||||
get {
|
get {
|
||||||
CreateParams cp = base.CreateParams;
|
CreateParams cp = base.CreateParams;
|
||||||
cp.ExStyle |= 0x02000000;
|
cp.ExStyle |= 0x02000000;
|
||||||
|
|
|
@ -657,7 +657,7 @@ namespace Greenshot {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AboutToolStripMenuItemClick(object sender, System.EventArgs e) {
|
void AboutToolStripMenuItemClick(object sender, System.EventArgs e) {
|
||||||
new AboutForm().ShowDialog(this);
|
MainForm.Instance.ShowAbout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesToolStripMenuItemClick(object sender, System.EventArgs e) {
|
void PreferencesToolStripMenuItemClick(object sender, System.EventArgs e) {
|
||||||
|
|
|
@ -968,6 +968,10 @@ namespace Greenshot {
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
void Contextmenu_aboutClick(object sender, EventArgs e) {
|
void Contextmenu_aboutClick(object sender, EventArgs e) {
|
||||||
|
ShowAbout();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShowAbout() {
|
||||||
if (aboutForm != null) {
|
if (aboutForm != null) {
|
||||||
WindowDetails.ToForeground(aboutForm.Handle);
|
WindowDetails.ToForeground(aboutForm.Handle);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -582,7 +582,9 @@ namespace Greenshot.Helpers {
|
||||||
if (element.attributes.ContainsKey("greenshot") && element.attributes["greenshot"] != null) {
|
if (element.attributes.ContainsKey("greenshot") && element.attributes["greenshot"] != null) {
|
||||||
string greenshotAction = element.attributes["greenshot"];
|
string greenshotAction = element.attributes["greenshot"];
|
||||||
if ("hide".Equals(greenshotAction)) {
|
if ("hide".Equals(greenshotAction)) {
|
||||||
PixelizationFilter.Apply(graphicsTarget, returnBitmap, element.rectangle, 4);
|
using (Brush brush = new SolidBrush(Color.Black)) {
|
||||||
|
graphicsTarget.FillRectangle(brush, element.rectangle);
|
||||||
|
}
|
||||||
} else if ("red".Equals(greenshotAction)) {
|
} else if ("red".Equals(greenshotAction)) {
|
||||||
using (Brush brush = new SolidBrush(Color.Red)) {
|
using (Brush brush = new SolidBrush(Color.Red)) {
|
||||||
graphicsTarget.FillRectangle(brush, element.rectangle);
|
graphicsTarget.FillRectangle(brush, element.rectangle);
|
||||||
|
|
|
@ -159,6 +159,7 @@ namespace GreenshotPlugin.Core {
|
||||||
/// Provides details about a Window returned by the
|
/// Provides details about a Window returned by the
|
||||||
/// enumeration
|
/// enumeration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1049:TypesThatOwnNativeResourcesShouldBeDisposable")]
|
||||||
public class WindowDetails : IEquatable<WindowDetails>{
|
public class WindowDetails : IEquatable<WindowDetails>{
|
||||||
private const string METRO_WINDOWS_CLASS = "Windows.UI.Core.CoreWindow";
|
private const string METRO_WINDOWS_CLASS = "Windows.UI.Core.CoreWindow";
|
||||||
private const string METRO_APPLAUNCHER_CLASS = "ImmersiveLauncher";
|
private const string METRO_APPLAUNCHER_CLASS = "ImmersiveLauncher";
|
||||||
|
|
|
@ -69,7 +69,7 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
||||||
public static extern IntPtr GetWindow(IntPtr hWnd, GetWindowCommand uCmd);
|
public static extern IntPtr GetWindow(IntPtr hWnd, GetWindowCommand uCmd);
|
||||||
[DllImport("user32", SetLastError = true)]
|
[DllImport("user32", SetLastError = true)]
|
||||||
public static extern int ShowWindow(IntPtr hWnd, ShowWindowCommand nCmdShow);
|
public static extern int ShowWindow(IntPtr hWnd, ShowWindowCommand nCmdShow);
|
||||||
[DllImport("user32", CharSet = CharSet.Auto, SetLastError = true)]
|
[DllImport("user32", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||||
public extern static int GetWindowText(IntPtr hWnd, StringBuilder lpString, int cch);
|
public extern static int GetWindowText(IntPtr hWnd, StringBuilder lpString, int cch);
|
||||||
[DllImport("user32", CharSet = CharSet.Auto, SetLastError = true)]
|
[DllImport("user32", CharSet = CharSet.Auto, SetLastError = true)]
|
||||||
public extern static int GetWindowTextLength(IntPtr hWnd);
|
public extern static int GetWindowTextLength(IntPtr hWnd);
|
||||||
|
@ -97,7 +97,7 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
||||||
[DllImport("user32", SetLastError = true)]
|
[DllImport("user32", SetLastError = true)]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
public extern static bool IsZoomed(IntPtr hwnd);
|
public extern static bool IsZoomed(IntPtr hwnd);
|
||||||
[DllImport("user32", CharSet = CharSet.Auto, SetLastError = true)]
|
[DllImport("user32", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||||
public extern static int GetClassName (IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
|
public extern static int GetClassName (IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
|
||||||
[DllImport("user32", SetLastError = true)]
|
[DllImport("user32", SetLastError = true)]
|
||||||
public static extern IntPtr GetClassLong(IntPtr hWnd, int nIndex);
|
public static extern IntPtr GetClassLong(IntPtr hWnd, int nIndex);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue