首页 > 解决方案 > 如何在 blazor 中放大和裁剪 SVG 到特定坐标

问题描述

我在我的方法中从用户那里得到坐标 a1,y1,x2,y2,rotationangle,outputwidth 和 outputheight。我需要使用这些坐标裁剪 svg 但在裁剪之前我需要在这些坐标上放大 svg 然后裁剪

在此处输入图像描述

     `double width = xaxis2 - xaxis1; double height = yaxis2 - yaxis1;              
            Rectangle CropArea = new Rectangle(

               Convert.ToInt32(xaxis1),
                   Convert.ToInt32(yaxis1),
                   Convert.ToInt32(width),
                   Convert.ToInt32(height)
                    );
            Bitmap originalImage = new Bitmap(filePath);
            using (Bitmap bitMap = new Bitmap(CropArea.Width, 
                   CropArea.Height))
            {

                using (Graphics g = Graphics.FromImage(bitMap))
                {
                    g.DrawImage(originalImage, new Rectangle(0, 0, 
                 bitMap.Width, bitMap.Height), CropArea, GraphicsUnit.Pixel);
                }
            }`

标签: c#imagesvgbitmapblazor

解决方案


推荐阅读