Rank: Newbie
Groups: Guest
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.png This is the rendered image: http://puu.sh/gjmjI/703ecc7288.png The 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
|