mirror of
https://github.com/greenshot/greenshot
synced 2025-07-13 00:23:54 -07:00
Added a new feature: Zoomer opacity, make the zoomer transparent, currently only available via the greenshot.ini
This commit is contained in:
parent
fa79ebb727
commit
829a35cd37
2 changed files with 27 additions and 7 deletions
|
@ -75,7 +75,7 @@ namespace Greenshot.Forms {
|
||||||
private FixMode fixMode = FixMode.None;
|
private FixMode fixMode = FixMode.None;
|
||||||
private RectangleAnimator windowAnimator = null;
|
private RectangleAnimator windowAnimator = null;
|
||||||
private RectangleAnimator zoomAnimator = null;
|
private RectangleAnimator zoomAnimator = null;
|
||||||
|
private bool isZoomerTransparent = conf.ZoomerOpacity < 1;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Property to access the selected capture rectangle
|
/// Property to access the selected capture rectangle
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -594,7 +594,18 @@ namespace Greenshot.Forms {
|
||||||
if (capturedImage == null) {
|
if (capturedImage == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ImageAttributes attributes;
|
||||||
|
|
||||||
|
if (isZoomerTransparent) {
|
||||||
|
//create a color matrix object to change the opacy
|
||||||
|
ColorMatrix opacyMatrix = new ColorMatrix();
|
||||||
|
opacyMatrix.Matrix33 = conf.ZoomerOpacity;
|
||||||
|
attributes = new ImageAttributes();
|
||||||
|
attributes.SetColorMatrix(opacyMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
|
||||||
|
} else {
|
||||||
|
attributes = null;
|
||||||
|
}
|
||||||
|
|
||||||
graphics.SmoothingMode = SmoothingMode.HighQuality;
|
graphics.SmoothingMode = SmoothingMode.HighQuality;
|
||||||
graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
|
graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
|
||||||
graphics.CompositingQuality = CompositingQuality.HighSpeed;
|
graphics.CompositingQuality = CompositingQuality.HighSpeed;
|
||||||
|
@ -603,12 +614,19 @@ namespace Greenshot.Forms {
|
||||||
using (GraphicsPath path = new GraphicsPath()) {
|
using (GraphicsPath path = new GraphicsPath()) {
|
||||||
path.AddEllipse(destinationRectangle);
|
path.AddEllipse(destinationRectangle);
|
||||||
graphics.SetClip(path);
|
graphics.SetClip(path);
|
||||||
graphics.FillRectangle(backgroundBrush, destinationRectangle);
|
if (!isZoomerTransparent) {
|
||||||
graphics.DrawImage(capturedImage, destinationRectangle, sourceRectangle, GraphicsUnit.Pixel);
|
graphics.FillRectangle(backgroundBrush, destinationRectangle);
|
||||||
|
graphics.DrawImage(capturedImage, destinationRectangle, sourceRectangle, GraphicsUnit.Pixel);
|
||||||
|
} else {
|
||||||
|
graphics.DrawImage(capturedImage, destinationRectangle, sourceRectangle.X, sourceRectangle.Y, sourceRectangle.Width, sourceRectangle.Height, GraphicsUnit.Pixel, attributes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
int alpha = (int)(255 * conf.ZoomerOpacity);
|
||||||
|
Color opacyWhite = Color.FromArgb(alpha, 255, 255, 255);
|
||||||
|
Color opacyBlack = Color.FromArgb(alpha, 0, 0, 0);
|
||||||
|
|
||||||
// Draw the circle around the zoomer
|
// Draw the circle around the zoomer
|
||||||
using (Pen pen = new Pen(Color.White, 2)) {
|
using (Pen pen = new Pen(opacyWhite, 2)) {
|
||||||
graphics.DrawEllipse(pen, destinationRectangle);
|
graphics.DrawEllipse(pen, destinationRectangle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -628,7 +646,7 @@ namespace Greenshot.Forms {
|
||||||
int padding = pixelThickness;
|
int padding = pixelThickness;
|
||||||
|
|
||||||
// Pen to draw
|
// Pen to draw
|
||||||
using (Pen pen = new Pen(Color.Black, pixelThickness)) {
|
using (Pen pen = new Pen(opacyBlack, pixelThickness)) {
|
||||||
// Draw the croshair-lines
|
// Draw the croshair-lines
|
||||||
// Vertical top to middle
|
// Vertical top to middle
|
||||||
graphics.DrawLine(pen, drawAtWidth, destinationRectangle.Y + padding, drawAtWidth, destinationRectangle.Y + halfHeightEnd - padding);
|
graphics.DrawLine(pen, drawAtWidth, destinationRectangle.Y + padding, drawAtWidth, destinationRectangle.Y + halfHeightEnd - padding);
|
||||||
|
@ -645,7 +663,7 @@ namespace Greenshot.Forms {
|
||||||
// Fix off by one error with the DrawRectangle
|
// Fix off by one error with the DrawRectangle
|
||||||
pixelThickness -= 1;
|
pixelThickness -= 1;
|
||||||
// Change the color and the pen width
|
// Change the color and the pen width
|
||||||
pen.Color = Color.White;
|
pen.Color = opacyWhite;
|
||||||
pen.Width = 1;
|
pen.Width = 1;
|
||||||
// Vertical top to middle
|
// Vertical top to middle
|
||||||
graphics.DrawRectangle(pen, drawAtWidth, destinationRectangle.Y + padding, pixelThickness, halfHeightEnd - 2 * padding - 1);
|
graphics.DrawRectangle(pen, drawAtWidth, destinationRectangle.Y + padding, pixelThickness, halfHeightEnd - 2 * padding - 1);
|
||||||
|
|
|
@ -227,6 +227,8 @@ namespace GreenshotPlugin.Core {
|
||||||
|
|
||||||
[IniProperty("ZoomerEnabled", Description = "Sets if the zoomer is enabled", DefaultValue = "True")]
|
[IniProperty("ZoomerEnabled", Description = "Sets if the zoomer is enabled", DefaultValue = "True")]
|
||||||
public bool ZoomerEnabled;
|
public bool ZoomerEnabled;
|
||||||
|
[IniProperty("ZoomerOpacity", Description = "Specify the transparency for the zoomer, from 0-1 (where 1 is no transparency and 0 is complete transparent. An usefull setting would be 0.7)", DefaultValue = "1")]
|
||||||
|
public float ZoomerOpacity;
|
||||||
|
|
||||||
[IniProperty("MaxMenuItemLength", Description = "Maximum length of submenu items in the context menu, making this longer might cause context menu issues on dual screen systems.", DefaultValue = "25")]
|
[IniProperty("MaxMenuItemLength", Description = "Maximum length of submenu items in the context menu, making this longer might cause context menu issues on dual screen systems.", DefaultValue = "25")]
|
||||||
public int MaxMenuItemLength;
|
public int MaxMenuItemLength;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue