Fixed some drawing defaults for Bug #3588716

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2391 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-12-17 16:20:45 +00:00
parent 263bfbf158
commit 4be6799f4a
7 changed files with 87 additions and 96 deletions

View file

@ -52,36 +52,33 @@ namespace Greenshot.Drawing {
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.None;
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
ArrowHeadCombination heads = (ArrowHeadCombination)GetFieldValue(FieldType.ARROWHEADS);
if (shadow) {
//draw shadow first
int basealpha = 100;
int alpha = basealpha;
int steps = 5;
int currentStep = 1;
while ( currentStep <= steps ) {
using (Pen shadowCapPen = new Pen(Color.FromArgb(alpha, 100, 100, 100))) {
shadowCapPen.Width = lineThickness;
SetArrowHeads(heads, shadowCapPen);
if (lineThickness > 0) {
if (shadow) {
//draw shadow first
int basealpha = 100;
int alpha = basealpha;
int steps = 5;
int currentStep = 1;
while (currentStep <= steps) {
using (Pen shadowCapPen = new Pen(Color.FromArgb(alpha, 100, 100, 100), lineThickness)) {
SetArrowHeads(heads, shadowCapPen);
graphics.DrawLine(shadowCapPen,
this.Left + currentStep,
this.Top + currentStep,
this.Left + currentStep + this.Width,
this.Top + currentStep + this.Height);
currentStep++;
alpha = alpha - (basealpha / steps);
graphics.DrawLine(shadowCapPen,
this.Left + currentStep,
this.Top + currentStep,
this.Left + currentStep + this.Width,
this.Top + currentStep + this.Height);
currentStep++;
alpha = alpha - (basealpha / steps);
}
}
}
}
using (Pen pen = new Pen(lineColor)) {
pen.Width = lineThickness;
if ( pen.Width > 0 ) {
using (Pen pen = new Pen(lineColor, lineThickness)) {
SetArrowHeads(heads, pen);
graphics.DrawLine(pen, this.Left, this.Top, this.Left + this.Width, this.Top + this.Height);
}

View file

@ -43,7 +43,7 @@ namespace Greenshot.Drawing {
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.None;
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
@ -66,18 +66,15 @@ namespace Greenshot.Drawing {
}
}
}
//draw the original shape
Rectangle rect = GuiRectangle.GetGuiRectangle(this.Left, this.Top, this.Width, this.Height);
if (!Color.Transparent.Equals(fillColor)) {
if (Colors.IsVisible(fillColor)) {
using (Brush brush = new SolidBrush(fillColor)) {
graphics.FillEllipse(brush, rect);
}
}
using (Pen pen = new Pen(lineColor)) {
pen.Width = lineThickness;
if (pen.Width > 0) {
if (lineVisible) {
using (Pen pen = new Pen(lineColor, lineThickness)) {
graphics.DrawEllipse(pen, rect);
}
}
@ -104,8 +101,7 @@ namespace Greenshot.Drawing {
// check the rest of the lines
if (lineThickness > 0) {
using (Pen pen = new Pen(Color.White)) {
pen.Width = lineThickness;
using (Pen pen = new Pen(Color.White, lineThickness)) {
using (GraphicsPath path = new GraphicsPath()) {
path.AddEllipse(rect);
return path.IsOutlineVisible(x, y, pen);

View file

@ -23,6 +23,7 @@ using System.Drawing;
using Greenshot.Drawing.Fields;
using Greenshot.Helpers;
using Greenshot.Plugin.Drawing;
using System.Drawing.Drawing2D;
namespace Greenshot.Drawing {
/// <summary>
@ -44,41 +45,38 @@ namespace Greenshot.Drawing {
AddField(GetType(), FieldType.SHADOW, false);
}
public override void Draw(Graphics g, RenderMode rm) {
public override void Draw(Graphics graphics, RenderMode rm) {
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
bool lineVisible = (lineThickness > 0 && Colors.IsVisible(lineColor));
if (shadow && lineVisible) {
if (lineVisible) {
graphics.SmoothingMode = SmoothingMode.HighSpeed;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.None;
//draw shadow first
int basealpha = 100;
int alpha = basealpha;
int steps = 5;
int currentStep = lineVisible ? 1 : 0;
while (currentStep <= steps) {
using (Pen shadowPen = new Pen(Color.FromArgb(alpha, 100, 100, 100))) {
shadowPen.Width = lineVisible ? lineThickness : 1;
Rectangle shadowRect = GuiRectangle.GetGuiRectangle(
this.Left + currentStep,
this.Top + currentStep,
this.Width,
this.Height);
g.DrawRectangle(shadowPen, shadowRect);
currentStep++;
alpha = alpha - (basealpha / steps);
if (shadow) {
int basealpha = 100;
int alpha = basealpha;
int steps = 5;
int currentStep = lineVisible ? 1 : 0;
while (currentStep <= steps) {
using (Pen shadowPen = new Pen(Color.FromArgb(alpha, 100, 100, 100), lineThickness)) {
Rectangle shadowRect = GuiRectangle.GetGuiRectangle(this.Left + currentStep, this.Top + currentStep, this.Width, this.Height);
graphics.DrawRectangle(shadowPen, shadowRect);
currentStep++;
alpha = alpha - (basealpha / steps);
}
}
}
Rectangle rect = GuiRectangle.GetGuiRectangle(this.Left, this.Top, this.Width, this.Height);
if (lineThickness > 0) {
using (Pen pen = new Pen(lineColor, lineThickness)) {
graphics.DrawRectangle(pen, rect);
}
}
}
Rectangle rect = GuiRectangle.GetGuiRectangle(this.Left, this.Top, this.Width, this.Height);
using (Pen pen = new Pen(lineColor)) {
pen.Width = lineThickness;
if(pen.Width > 0) {
g.DrawRectangle(pen, rect);
}
}
}
}
}

View file

@ -57,39 +57,36 @@ namespace Greenshot.Drawing {
public override void Draw(Graphics graphics, RenderMode rm) {
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.None;
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
if ( shadow && lineThickness > 0 ) {
//draw shadow first
int basealpha = 100;
int alpha = basealpha;
int steps = 5;
int currentStep = 1;
while (currentStep <= steps) {
using (Pen shadowCapPen = new Pen(Color.FromArgb(alpha, 100, 100, 100))) {
shadowCapPen.Width = lineThickness;
graphics.DrawLine(shadowCapPen,
this.Left + currentStep,
this.Top + currentStep,
this.Left + currentStep + this.Width,
this.Top + currentStep + this.Height);
currentStep++;
alpha = alpha - (basealpha / steps);
if (lineThickness > 0) {
if (shadow) {
//draw shadow first
int basealpha = 100;
int alpha = basealpha;
int steps = 5;
int currentStep = 1;
while (currentStep <= steps) {
using (Pen shadowCapPen = new Pen(Color.FromArgb(alpha, 100, 100, 100), lineThickness)) {
graphics.DrawLine(shadowCapPen,
this.Left + currentStep,
this.Top + currentStep,
this.Left + currentStep + this.Width,
this.Top + currentStep + this.Height);
currentStep++;
alpha = alpha - (basealpha / steps);
}
}
}
}
using (Pen pen = new Pen(lineColor)) {
pen.Width = lineThickness;
if(pen.Width > 0) {
using (Pen pen = new Pen(lineColor, lineThickness)) {
graphics.DrawLine(pen, this.Left, this.Top, this.Left + this.Width, this.Top + this.Height);
}
}

View file

@ -74,16 +74,16 @@ namespace Greenshot.Drawing {
}
Rectangle rect = GuiRectangle.GetGuiRectangle(this.Left, this.Top, this.Width, this.Height);
if (!Color.Transparent.Equals(fillColor)) {
if (Colors.IsVisible(fillColor)) {
using (Brush brush = new SolidBrush(fillColor)) {
graphics.FillRectangle(brush, rect);
}
}
if (lineThickness > 0) {
using (Pen pen = new Pen(lineColor)) {
pen.Width = lineThickness;
graphics.SmoothingMode = SmoothingMode.HighSpeed;
if (lineVisible) {
using (Pen pen = new Pen(lineColor, lineThickness)) {
graphics.DrawRectangle(pen, rect);
}
}
@ -103,8 +103,7 @@ namespace Greenshot.Drawing {
// check the rest of the lines
if (lineThickness > 0) {
using (Pen pen = new Pen(Color.White)) {
pen.Width = lineThickness;
using (Pen pen = new Pen(Color.White, lineThickness)) {
using (GraphicsPath path = new GraphicsPath()) {
path.AddRectangle(rect);
return path.IsOutlineVisible(x, y, pen);

View file

@ -23,6 +23,9 @@ using System.Drawing;
using System.Drawing.Drawing2D;
namespace Greenshot.Drawing {
/// <summary>
/// TODO: currently this is only used in the capture form, we might move this code directly to there!
/// </summary>
public abstract class RoundedRectangle {
public enum RectangleCorners {
None = 0, TopLeft = 1, TopRight = 2,

View file

@ -272,7 +272,7 @@ namespace Greenshot.Drawing {
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.None;
graphics.TextRenderingHint = TextRenderingHint.SystemDefault;
Rectangle rect = GuiRectangle.GetGuiRectangle(this.Left, this.Top, this.Width, this.Height);
@ -308,12 +308,13 @@ namespace Greenshot.Drawing {
}
}
}
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
Rectangle fontRect = rect;
if (lineThickness > 0) {
fontRect.Inflate(-textOffset,-textOffset);
graphics.SmoothingMode = SmoothingMode.HighSpeed;
fontRect.Inflate(-textOffset, -textOffset);
}
graphics.SmoothingMode = SmoothingMode.HighQuality;
using (Brush fontBrush = new SolidBrush(lineColor)) {
graphics.DrawString(text, font, fontBrush, fontRect);
}