Rank: Advanced Member
Groups: Guest
Joined: 7/28/2003(UTC) Posts: 1,660
Thanks: 5 times Was thanked: 76 time(s) in 74 post(s)
|
The Shadow.Size, Shadow.OffsetX, and Shadow.OffsetY properties are in points (not in pixels). That's why it works correctly with DPI = 72 only. To fix the problem you should convert points to pixels: Code:using System;
using Aurigma.GraphicsMill;
using Aurigma.GraphicsMill.AdvancedDrawing.Art;
using Aurigma.GraphicsMill.AdvancedDrawing.Effects;
using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Codecs;
namespace Forum_13972
{
class Program
{
static void Main(string[] args)
{
var text = "Hello World!";
var intensity = 0.2f;
var targetFile = "../../../ArtText.pdf";
var width = 1000;
var height = 300;
int dpi = 150;
using (var pdfWriter = new PdfWriter(targetFile))
{
pdfWriter.AddPage(width, height, dpi, dpi);
using (var graphics = pdfWriter.GetGraphics())
{
var font = graphics.CreateFont("Tahoma", 80);
var brush = new SolidBrush(RgbColor.Blue);
var artText = new BridgeText(text, font, brush, 0, 0, intensity);
var shadowSizePt = 5f;
var shadowOffsetXPt = 20f;
var shadowOffsetYPt = 15f;
artText.Effect = new Shadow(RgbColor.Red, shadowSizePt, shadowOffsetXPt, shadowOffsetYPt, 1);
artText.Center = new System.Drawing.PointF(width / 2, height / 2);
graphics.DrawText(artText);
//Text blackbox
var textBlackBox = artText.GetBlackBox();
graphics.DrawRectangle(new Pen(RgbColor.Black, 1f), textBlackBox);
var shadowSizePx = UnitConverter.ConvertUnitsToPixels(dpi, shadowSizePt, Unit.Point);
var shadowOffsetXPx = UnitConverter.ConvertUnitsToPixels(dpi, shadowOffsetXPt, Unit.Point);
var shadowOffsetYPx = UnitConverter.ConvertUnitsToPixels(dpi, shadowOffsetYPt, Unit.Point);
//Shadow blackbox
var shadowBlackBox = new System.Drawing.RectangleF(
textBlackBox.X - shadowSizePx + shadowOffsetXPx,
textBlackBox.Y - shadowSizePx + shadowOffsetYPx,
textBlackBox.Width + shadowSizePx * 2,
textBlackBox.Height + shadowSizePx * 2);
graphics.DrawRectangle(new Pen(RgbColor.Red, 1f), shadowBlackBox);
//Union blackbox
var unionBlackbox = System.Drawing.RectangleF.Union(textBlackBox, shadowBlackBox);
graphics.DrawRectangle(new Pen(RgbColor.Green, 1f), unionBlackbox);
}
}
}
}
}
Edited by user Monday, January 11, 2016 9:25:18 PM(UTC)
| Reason: Not specified |
Best regards, Fedor Skvortsov
|
1 user thanked Fedor for this useful post.
|
|