Rank: Advanced Member
Groups: Guest
Joined: 10/12/2015(UTC) Posts: 44
|
I'm trying to make the case to our company that we should use your SDK instead of NeoDynamic ImageDraw SDK. But first I need to reproduce the basic text functions found in their library. Can you someone explain why the text in this example is not at the bottom? I'm trying to figure out how to mimic their options of: BottomCenter, BottomLeft, BottomRight, MiddleCenter, MiddleLeft, MiddleRight TopCenter, TopLeft, TopRight Code:
public static byte[] GetText(string txt, int width, int height) {
using (var bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb, RgbColor.Green))
using (var graphics = bitmap.GetAdvancedGraphics())
using (var customFont = new CustomFontRegistry()) {
var font = graphics.CreateFont("Courier New", 58);
var bounded = new BoundedText(txt, font, new System.Drawing.Rectangle(0, 0, width, height));
bounded.Brush = new SolidBrush(RgbColor.Blue);
bounded.Alignment = TextAlignment.Bottom;
graphics.DrawText(bounded);
return imageToByteArray(bitmap);
}
}
|
|
|
|
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)
|
Graphics Mill doesn't support the vertical alignment. Even so, we plan to implement it in the future versions (Aurigma Bug #0022275). The description of the TextAlignment enumeration misleads. The SDK supports the drawing of vertical text and the TextAlignment.Top and TextAlignment.Bottom values specify the alignment of vertical text only: Currently, you can implement the vertical alignment using the GetBlackBox method: Code:public static byte[] GetText(string txt, int width, int height)
{
using (var bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb, RgbColor.Green))
using (var graphics = bitmap.GetAdvancedGraphics())
using (var customFont = new CustomFontRegistry())
{
var font = graphics.CreateFont("Courier New", 58);
var bounded = new BoundedText(txt, font, new System.Drawing.RectangleF(0, 0, width, height));
bounded.Brush = new SolidBrush(RgbColor.Blue);
var blackBox = bounded.GetBlackBox();
//Bottom
bounded.Rectangle = new System.Drawing.RectangleF(0, height - blackBox.Height, width, height);
//Center
//bounded.Rectangle = new System.Drawing.RectangleF(0, (height - blackBox.Height) / 2, width, height);
graphics.DrawText(bounded);
return imageToByteArray(bitmap);
}
}
A similar question was discussed here: Shrinking text and vertical alignment Edited by user Monday, May 29, 2017 3:40:26 AM(UTC)
| Reason: Not specified |
Best regards, Fedor Skvortsov
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.