Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Issue with bitmap cropping when exporting via SvgExporter (Read 652 times)
Dducky
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 14
Joined: Oct 17th, 2022
Issue with bitmap cropping when exporting via SvgExporter
Dec 29th, 2022 at 5:13am
Print Post  
The issue related with bitmap cropping when exporting via SvgExporter.
The code:
Code
Select All
// Set the position to the origin.
            // Its just an example node that draw a bitmap.
            // This node doesn't have 'RenderTransform' or 'RotationAngle'.
            // It will render correctly.
            var testImageNodeBounds = Bounds with { X = 0, Y = 0 };
            var testImageNode = new SvgNode()
            {
                Image = bitmapImage,
                Transparent = true,
                Bounds = testImageNodeBounds,
                TextBrush = Brushes.LightBlue,
            };
            testImageNode.Text = $"Bounds: {testImageNodeBounds} \n " +
                $"Rotation is: {testImageNode.RotationAngle} \n " +
                $"Render transform is: \n {testImageNode.RenderTransform}";

            // This is the real one.
            // We are trying to draw an image that have a 'RotationAngle' and 'RenderTransform'.
            // It will be cropped.
            var realImageNode = new SvgNode()
            {
                Image = bitmapImage,
                Transparent = true,
                RenderTransform = RenderTransform,
                RotationAngle = RotationAngle,
                Bounds = Bounds,
                Text = $"Bounds: {Bounds} \n Rotation is: {RotationAngle} \n Render transform is: \n {RenderTransform}",
                TextBrush = Brushes.LightBlue,
            };

            printDiagram.Items.Add(testImageNode);
            printDiagram.Items.Add(realImageNode); 



I also tried to export into stream/file but anyways its cropped:
Code
Select All
var svgExporter = new SvgExporter()
        {
            SetClipPaths = true,
        };
        var svgStream = new MemoryStream();
        svgExporter.Export(atsDiagramControl, svgStream);
        svgStream.Seek(0, SeekOrigin.Begin);
        svgExporter.Export(atsDiagramControl, "testSvg.svg");
        svgStream.Seek(0, SeekOrigin.Begin); 



Attachments:
1) See the diagram that we expect while exporting.
2) The resulting SVG after export (by SvgExporter). For some reason cannot upload the resulting SVG, I am attaching the file that I posted on the file hosting: https://dropmefiles.com/sQFCB
  

ExpectedDiagram.png ( 102 KB | 26 Downloads )
ExpectedDiagram.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3153
Joined: Oct 19th, 2005
Re: Issue with bitmap cropping when exporting via SvgExporter
Reply #1 - Jan 2nd, 2023 at 5:56am
Print Post  
This is not showing cropped bitmaps in our test, please post your exact values:

Code
Select All
var bitmapImage = Utilities.LoadImage("59547975.jpg");

var node1 = new SvgNode()
{
	Image = bitmapImage,
	Transparent = true,
	RotationAngle = -130,
	Bounds = new Rect(50, 50, 250, 200),
	TextBrush = Brushes.LightBlue,
};

var node2 = new SvgNode()
{
	Image = bitmapImage,
	Transparent = true,
	//RenderTransform = new TranslateTransform(-50, 20),
	//RenderTransform = new ScaleTransform(2, 2),
	RotationAngle = 30,
	Bounds = new Rect(330, 50, 200, 250),
	TextBrush = Brushes.LightBlue,
};

diagram.Items.Add(node1);
diagram.Items.Add(node2);

var svgExporter = new SvgExporter()
{
	SetClipPaths = true,
};
svgExporter.Export(diagram, "testSvg.svg"); 





Also RenderTransform is set internally by the control to match Bounds and RotationAngle, you shouldn't be able to override it unless assigning to it last after those properties.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint