mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 17:56:51 +13:00
Don't create new brushes every draw text
This commit is contained in:
parent
9feac51b08
commit
c349a32101
2 changed files with 9 additions and 7 deletions
|
@ -592,15 +592,17 @@ public static void DrawTextWithOutline(Graphics g, string text, PointF position,
|
|||
|
||||
public static void DrawTextWithShadow(Graphics g, string text, PointF position, Font font, Color textColor, Color shadowColor, int shadowOffset = 1)
|
||||
{
|
||||
using (Brush textBrush = new SolidBrush(textColor))
|
||||
using (Brush shadowBrush = new SolidBrush(shadowColor))
|
||||
{
|
||||
g.DrawString(text, font, shadowBrush, position.X + shadowOffset, position.Y + shadowOffset);
|
||||
DrawTextWithShadow(g, text, position, font, textBrush, shadowBrush, shadowOffset);
|
||||
}
|
||||
}
|
||||
|
||||
using (Brush textBrush = new SolidBrush(textColor))
|
||||
{
|
||||
g.DrawString(text, font, textBrush, position.X, position.Y);
|
||||
}
|
||||
public static void DrawTextWithShadow(Graphics g, string text, PointF position, Font font, Brush textBrush, Brush shadowBrush, int shadowOffset = 1)
|
||||
{
|
||||
g.DrawString(text, font, shadowBrush, position.X + shadowOffset, position.Y + shadowOffset);
|
||||
g.DrawString(text, font, textBrush, position.X, position.Y);
|
||||
}
|
||||
|
||||
public static bool IsImagesEqual(Bitmap bmp1, Bitmap bmp2)
|
||||
|
|
|
@ -315,7 +315,7 @@ private void DrawAreaText(Graphics g, Rectangle area)
|
|||
g.DrawRectangleProper(textBackgroundPenBlack, backgroundRect.Offset(-1));
|
||||
g.DrawRectangleProper(textBackgroundPenWhite, backgroundRect);
|
||||
|
||||
ImageHelpers.DrawTextWithShadow(g, areaText, textPos, infoFont, Color.White, Color.Black);
|
||||
ImageHelpers.DrawTextWithShadow(g, areaText, textPos, infoFont, Brushes.White, Brushes.Black);
|
||||
}
|
||||
|
||||
private void DrawTips(Graphics g, int offset, int padding)
|
||||
|
@ -339,7 +339,7 @@ private void DrawTips(Graphics g, int offset, int padding)
|
|||
g.DrawRectangleProper(textBackgroundPenBlack, textRectangle.Offset(-1));
|
||||
g.DrawRectangleProper(textBackgroundPenWhite, textRectangle);
|
||||
|
||||
ImageHelpers.DrawTextWithShadow(g, tipText, textRectangle.Offset(-padding).Location, infoFont, Color.White, Color.Black);
|
||||
ImageHelpers.DrawTextWithShadow(g, tipText, textRectangle.Offset(-padding).Location, infoFont, Brushes.White, Brushes.Black);
|
||||
}
|
||||
|
||||
protected virtual void WriteTips(StringBuilder sb)
|
||||
|
|
Loading…
Reference in a new issue