|
|
@ -173,7 +173,7 @@ private static readonly Regex ShadowRegex = new Regex(@"shadow-true", RegexOptio |
|
|
|
|
|
|
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
// Dont use an object initializer here.
|
|
|
// Don't use an object initializer here.
|
|
|
newImage = new Bitmap(image); |
|
|
newImage = new Bitmap(image); |
|
|
newImage.Tag = image.Tag; |
|
|
newImage.Tag = image.Tag; |
|
|
|
|
|
|
|
|
@ -193,12 +193,12 @@ private static readonly Regex ShadowRegex = new Regex(@"shadow-true", RegexOptio |
|
|
{ |
|
|
{ |
|
|
Point origin = textLayer.Position; |
|
|
Point origin = textLayer.Position; |
|
|
|
|
|
|
|
|
// We need to ensure that there is a position set for the watermark
|
|
|
|
|
|
if (origin == Point.Empty) |
|
|
|
|
|
{ |
|
|
|
|
|
// Work out the size of the text.
|
|
|
// Work out the size of the text.
|
|
|
SizeF textSize = graphics.MeasureString(text, font, new SizeF(image.Width, image.Height), drawFormat); |
|
|
SizeF textSize = graphics.MeasureString(text, font, new SizeF(image.Width, image.Height), drawFormat); |
|
|
|
|
|
|
|
|
|
|
|
// We need to ensure that there is a position set for the watermark
|
|
|
|
|
|
if (origin == Point.Empty) |
|
|
|
|
|
{ |
|
|
int x = (int)(image.Width - textSize.Width) / 2; |
|
|
int x = (int)(image.Width - textSize.Width) / 2; |
|
|
int y = (int)(image.Height - textSize.Height) / 2; |
|
|
int y = (int)(image.Height - textSize.Height) / 2; |
|
|
origin = new Point(x, y); |
|
|
origin = new Point(x, y); |
|
|
@ -207,6 +207,9 @@ private static readonly Regex ShadowRegex = new Regex(@"shadow-true", RegexOptio |
|
|
// Set the hinting and draw the text.
|
|
|
// Set the hinting and draw the text.
|
|
|
graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; |
|
|
graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; |
|
|
|
|
|
|
|
|
|
|
|
// Create bounds for the text.
|
|
|
|
|
|
RectangleF bounds; |
|
|
|
|
|
|
|
|
if (textLayer.DropShadow) |
|
|
if (textLayer.DropShadow) |
|
|
{ |
|
|
{ |
|
|
// Shadow opacity should change with the base opacity.
|
|
|
// Shadow opacity should change with the base opacity.
|
|
|
@ -219,11 +222,18 @@ private static readonly Regex ShadowRegex = new Regex(@"shadow-true", RegexOptio |
|
|
// Magic number but it's based on artistic preference.
|
|
|
// Magic number but it's based on artistic preference.
|
|
|
int shadowDiff = (int)Math.Ceiling(fontSize / 24f); |
|
|
int shadowDiff = (int)Math.Ceiling(fontSize / 24f); |
|
|
Point shadowPoint = new Point(origin.X + shadowDiff, origin.Y + shadowDiff); |
|
|
Point shadowPoint = new Point(origin.X + shadowDiff, origin.Y + shadowDiff); |
|
|
graphics.DrawString(text, font, shadowBrush, shadowPoint, drawFormat); |
|
|
|
|
|
|
|
|
// Set the bounds so any overlapping text will wrap.
|
|
|
|
|
|
bounds = new RectangleF(shadowPoint, new SizeF(image.Width - shadowPoint.X, image.Height - shadowPoint.Y)); |
|
|
|
|
|
|
|
|
|
|
|
graphics.DrawString(text, font, shadowBrush, bounds, drawFormat); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
graphics.DrawString(text, font, brush, origin, drawFormat); |
|
|
// Set the bounds so any overlapping text will wrap.
|
|
|
|
|
|
bounds = new RectangleF(origin, new SizeF(image.Width - origin.X, image.Height - origin.Y)); |
|
|
|
|
|
|
|
|
|
|
|
graphics.DrawString(text, font, brush, bounds, drawFormat); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|