This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

Notification

Icon
Error

Options
Go to last post Go to first unread
dfreire  
#1 Posted : Monday, March 2, 2015 8:00:17 AM(UTC)
dfreire

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

Fedor  
#2 Posted : Tuesday, March 3, 2015 9:51:32 AM(UTC)
Fedor

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)
Hello,

Please check the following samples:

http://www.graphicsmill..../modify-and-merge-layers

http://www.graphicsmill....be-photoshop/curved-text

In short you need to set the correct DPI to get it work.

If it is still unclear how to achieve the desired result please post a complete source code.

Best regards,

Fedor Skvortsov

thanks 1 user thanked Fedor for this useful post.
dfreire on 3/5/2015(UTC)
dfreire  
#3 Posted : Thursday, March 5, 2015 6:42:38 AM(UTC)
dfreire

Rank: Newbie

Groups: Guest
Joined: 2/27/2015(UTC)
Posts: 8

Thanks: 2 times
Thanks Fedor, it was exactly the DPI that was missing!
dfreire  
#4 Posted : Wednesday, March 11, 2015 11:45:54 AM(UTC)
dfreire

Rank: Newbie

Groups: Guest
Joined: 2/27/2015(UTC)
Posts: 8

Thanks: 2 times
Hi Fedor,

How are you? I still have some problems rendering text, duo to Ascent and Descent properties, which cannot be set on the font measuring property.

These are the frame properties:

http://puu.sh/gw9yA/6d03945098.png

These are the object properties on graphics.CreateFont~

http://puu.sh/gw7CC/b639ebe053.png

The final result diference is quite clear..

Rendered: http://puu.sh/gwa2C/19f769fa09.jpg

Original: http://puu.sh/gwa7R/eee87130bd.jpg

How can i fix this?

Thanks

Fedor  
#5 Posted : Wednesday, March 11, 2015 7:12:45 PM(UTC)
Fedor

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)
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

dfreire  
#6 Posted : Thursday, March 12, 2015 11:10:08 AM(UTC)
dfreire

Rank: Newbie

Groups: Guest
Joined: 2/27/2015(UTC)
Posts: 8

Thanks: 2 times
Users browsing this topic
Guest
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.