Added a new feature: Zoomer opacity, make the zoomer transparent, currently only available via the greenshot.ini

This commit is contained in:
RKrom 2014-02-07 17:24:50 +01:00
parent fa79ebb727
commit 829a35cd37
2 changed files with 27 additions and 7 deletions

View file

@ -75,7 +75,7 @@ namespace Greenshot.Forms {
private FixMode fixMode = FixMode.None;
private RectangleAnimator windowAnimator = null;
private RectangleAnimator zoomAnimator = null;
private bool isZoomerTransparent = conf.ZoomerOpacity < 1;
/// <summary>
/// Property to access the selected capture rectangle
/// </summary>
@ -594,6 +594,17 @@ namespace Greenshot.Forms {
if (capturedImage == null) {
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.InterpolationMode = InterpolationMode.NearestNeighbor;
@ -603,12 +614,19 @@ namespace Greenshot.Forms {
using (GraphicsPath path = new GraphicsPath()) {
path.AddEllipse(destinationRectangle);
graphics.SetClip(path);
if (!isZoomerTransparent) {
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
using (Pen pen = new Pen(Color.White, 2)) {
using (Pen pen = new Pen(opacyWhite, 2)) {
graphics.DrawEllipse(pen, destinationRectangle);
}
@ -628,7 +646,7 @@ namespace Greenshot.Forms {
int padding = pixelThickness;
// Pen to draw
using (Pen pen = new Pen(Color.Black, pixelThickness)) {
using (Pen pen = new Pen(opacyBlack, pixelThickness)) {
// Draw the croshair-lines
// Vertical top to middle
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
pixelThickness -= 1;
// Change the color and the pen width
pen.Color = Color.White;
pen.Color = opacyWhite;
pen.Width = 1;
// Vertical top to middle
graphics.DrawRectangle(pen, drawAtWidth, destinationRectangle.Y + padding, pixelThickness, halfHeightEnd - 2 * padding - 1);

View file

@ -227,6 +227,8 @@ namespace GreenshotPlugin.Core {
[IniProperty("ZoomerEnabled", Description = "Sets if the zoomer is enabled", DefaultValue = "True")]
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")]
public int MaxMenuItemLength;