2016-01-09 75 views
0

我使用不支持SVG文件viewBox参数一个C#库,但没有它,我把我的图片切断,因为他们不能正确缩放,下面详细介绍......SVG编辑只显示XAML中SVG图像文件的一半?

我想在移动应用程序中使用一些SVG文件,使用xamarin表单平台和nuget插件。该插件的支持非常有限,所以我不得不手动更改svg文件。当产生了Google+图像具有以下第一个标签,但是,当我使用这个文件,我得到了以下错误消息:

<svg id="Capa_1" data-name="Capa 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><title>Google_Round</title>< 

的System.Exception:无效的参数,以上下文创建 在CoreGraphics.CGContext .set_Handle(IntPtr value)[0x00010]位于/Users/builder/data/lanes/2377/73229919/source/maccore/src/CoreGraphics/CGContext.cs:161 at CoreGraphics.CGContext..ctor(IntPtr handle,Boolean owns )在CorelDR语句中设置/Users/builder/data/lanes/2377/73229919/source/maccore/src/CoreGraphics/CGContext.cs:141 中的[0x00006] CoreGraphics.CGBitmapContext..ctor(IntPtr data,nint width,nint height,nint bitsPerComponent,nint bytesPerRow,CoreGrap hics.CGColorSpace colorSpace,CGImageAlphaInfo bitmapInfo)[/ PHP,尺寸大小,双刻度,布尔透明度)[0x0005c]在:0 在SVG.Forms.Plugin.iOS.SvgImageRenderer.OnElementChanged(Xamarin.Forms.Platform.iOS.ElementChangedEventArgs`1 E)[0x0010f]在:0

如果我将第一个标记更改为已知工作示例中第一个标记的副本,则我具有以下SVG文件。

<?xml version="1.0"?> 
<svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" height="300" width="300" version="1.1" fill-opacity="0"> xml:space="preserve"> 
     <path fill="#54534A" d="M2204.344,4414.691v-122.67h81.643h81.642l-1.237,6.804c-0.619,3.505-1.649,10.515-2.474,15.462l-1.443,8.659 
      h-61.438h-61.644v38.141v38.141h54.635h54.635v16.493v16.494h-54.635h-54.635v36.079v36.08h60.613h60.407l1.443,10.515 
      c0.825,5.979,2.062,13.401,2.68,16.493l1.237,5.979h-80.818h-80.612V4414.691z"/> 
    <!-- Various Strokes omitted --> 
    </g> 
    </svg> 

这给了我下面的显示,否则会是一个完整的G +图标。我认为这是因为我丢失了文件中的viewBox信息。我还能如何包含这些信息以确保我的svg能够适当扩展,而不会导致插件失败? Icon Comparison

回答

1

在路径中设置属性Stretch="Uniform"并通过边距控制此路径。