Rank: Newbie
Groups: Member
Joined: 2/27/2015(UTC) Posts: 8
Thanks: 2 times
|
Hello, I'm parsing the PSD and i'm trying to generate a bitmap from the parsed metadata. I'm having no problems with the raster images, for text is being quite dificult to render equally to the PSD, as in size, position and style. This is the original psd: http://puu.sh/gjmik/6c0a6e008a.pngThis is the rendered image: http://puu.sh/gjmjI/703ecc7288.pngThe intention of this approach is to save the psd metadata to the database, display the metadata on the browser, allowing the client to change a few the font size, font name, position and style. This is the code i'm using: Code: var bitmap = new Bitmap(_width, _height, PixelFormat.Format16bppAgrayscale);
using (var graphics = bitmap.GetAdvancedGraphics())
{
foreach (var imageElement in ImageElements)
{
Stream stream = new MemoryStream(imageElement.Image);
var raster = (Bitmap)Image.FromStream(stream);
var rectangle = new Rectangle(imageElement.PositionX, imageElement.PositionY,
imageElement.Width, imageElement.Height);
bitmap.Draw(raster, rectangle,
Aurigma.GraphicsMill.Transforms.CombineMode.Alpha, 1.0f,
Aurigma.GraphicsMill.Transforms.ResizeInterpolationMode.High);
}
foreach (var textElement in TextElements)
{
var brusher = new SolidBrush(System.Drawing.Color.White);
if (FontRegistry.Installed.Contains(textElement.FontName))
{
var font = FontRegistry.Installed.CreateFont(textElement.FontName, textElement.FontSize, graphics.DpiX, graphics.DpiY);
font.FauxBold = textElement.IsBold;
font.FauxItalic = textElement.IsItalic;
var text = new PlainText(textElement.Text, font, brusher) {Underline = textElement.IsUnderline};
int y = textElement.PositionY - (int)text.GetBlackBox().Top;
text.Position = new PointF(textElement.PositionX, y);
graphics.DrawText(text);
}
}
}
bitmap.Save(@"d:\renderedImage.png", new PngSettings());
Many thanks Edited by moderator Monday, March 2, 2015 9:42:47 AM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Member, Administration, Moderator Joined: 7/28/2003(UTC) Posts: 1,660
Thanks: 5 times Was thanked: 76 time(s) in 74 post(s)
|
|
Best regards, Fedor Skvortsov
|
1 user thanked Fedor for this useful post.
|
|
|
Rank: Newbie
Groups: Member
Joined: 2/27/2015(UTC) Posts: 8
Thanks: 2 times
|
Thanks Fedor, it was exactly the DPI that was missing!
|
|
|
|
Rank: Newbie
Groups: Member
Joined: 2/27/2015(UTC) Posts: 8
Thanks: 2 times
|
|
|
|
|
Rank: Advanced Member
Groups: Member, Administration, Moderator Joined: 7/28/2003(UTC) Posts: 1,660
Thanks: 5 times Was thanked: 76 time(s) in 74 post(s)
|
Hi, The provided links are broken: Quote:Website is offline No cached version of this page is available. Could you submit a case and attach the provided images? Edited by user Wednesday, March 11, 2015 8:53:09 PM(UTC)
| Reason: Not specified |
Best regards, Fedor Skvortsov
|
|
|
|
Rank: Newbie
Groups: Member
Joined: 2/27/2015(UTC) Posts: 8
Thanks: 2 times
|
|
|
|
|
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.