Page 1 of 1

Sample for DrawingVisual (trying to avoid Bitmap images)

Posted: Mon May 02, 2011 5:06 am
by euregon
Hi,

can you please point me to a sample using DrawingVisual instead of Bitmap images for an Image?

Thanks a lot.

I tried the following code, but the image isn't recocniced in the designer:

Code: Select all

   public class MyDrawing
    {
        private DrawingVisual _drawing = null;

        public DrawingVisual Drawing 
        {
            get { return _drawing; }            
        }

        public int ID
        {
            get { return 17; }
        }

        public MyDrawing()
        {
            _drawing = new DrawingVisual();
            using (DrawingContext dc = Drawing.RenderOpen())
            {
                // The body
                dc.DrawGeometry(Brushes.Blue, null, Geometry.Parse(
                                @"M 240,250
                            C 200,375 200,250 175,200
                            C 100,400 100,250 100,200
                            C 0,350 0,250 30,130
                            C 75,0 100,0 150,0
                            C 200,0 250,0 250,150 Z"));
                // Left eye
                dc.DrawEllipse(Brushes.Black, new Pen(Brushes.White, 10),
                new Point(95, 95), 15, 15);
                // Right eye
                dc.DrawEllipse(Brushes.Black, new Pen(Brushes.White, 10),
                new Point(170, 105), 15, 15);
                // The mouth
                Pen p = new Pen(Brushes.Black, 10);
                p.StartLineCap = PenLineCap.Round;
                p.EndLineCap = PenLineCap.Round;
                dc.DrawLine(p, new Point(75, 160), new Point(175, 150));
            }
        }
    }

Sample for DrawingVisual (trying to avoid Bitmap images)

Posted: Mon May 02, 2011 6:28 am
by euregon

Sample for DrawingVisual (trying to avoid Bitmap images)

Posted: Mon May 02, 2011 7:46 am
by Anton Lozovskiy
Hello,

We create an example for you, please see.

Thank you.

Sample for DrawingVisual (trying to avoid Bitmap images)

Posted: Mon May 02, 2011 9:14 am
by euregon
Hi AntonLoz,

thank you for your code.

I noticed in your example, you are using RenderTargetBitmap for offline rendering. This will create a Bitmap resource?

By using Image1.ObjectToDraw = myDrawing; in the BeforePrintEvent in the report, i got the DrawingVisual
as pure vector graphic in the designer an preview.

I was hoping that the PDF export will keep the DrawingVisual as vector graphics.

However i could only export it with a JPEG image inside.

Is there any other trick we can keep the image as vector? Can Stimulsoft use EMF/WMF images in the
report as vector or convert a DrawingVisual to a EMF/WMF inside the report system?

Sample for DrawingVisual (trying to avoid Bitmap images)

Posted: Tue May 03, 2011 7:25 am
by Jan
Hello,
I noticed in your example, you are using RenderTargetBitmap for offline rendering. This will create a Bitmap resource?

By using Image1.ObjectToDraw = myDrawing; in the BeforePrintEvent in the report, i got the DrawingVisual
as pure vector graphic in the designer an preview.

I was hoping that the PDF export will keep the DrawingVisual as vector graphics.

However i could only export it with a JPEG image inside.
Its correct. At this moment export to pdf ca use only png or jpeg images.
Is there any other trick we can keep the image as vector? Can Stimulsoft use EMF/WMF images in the
report as vector or convert a DrawingVisual to a EMF/WMF inside the report system?
Sorry this is not possible now. This is very complex task and we don't plan release this feature in near future. At this moment exist only one way to export vector images to pdf file - though rich text object. Pdf export use special methodic to convert rich text object (including images in it) to vector primitives of pdf.

Thank you.

Sample for DrawingVisual (trying to avoid Bitmap images)

Posted: Tue May 03, 2011 8:06 am
by euregon
Jan wrote:
Sorry this is not possible now. This is very complex task and we don't plan release this feature in near future. At this moment exist only one way to export vector images to pdf file - though rich text object. Pdf export use special methodic to convert rich text object (including images in it) to vector primitives of pdf.

Thank you.
Hello Jan,

indeed it's very complex to render WPF vector graphic to PDF as vectors :)

As you can see our grapic objects are quite simple. So the rich text might be a nice simple way.

Can you point me to an example with the rich text object?

Thank you.

Sample for DrawingVisual (trying to avoid Bitmap images)

Posted: Thu May 05, 2011 5:48 am
by Alex K.
Hello,

Unfortunately, it is not possible.
This is a very narrowly specific feature which is very rarely demanded. Therefore, at this moment, we do not have plans to implement it.

Thank you.