我正在使用potrace从bmp图像生成svg图像。生成的图像在Illustrator中可以正常显示,但是当我尝试在iPad上使用SVGKit对其进行显示时,它将加载空白图像。

SVGKit适用于我用Illustrator创建的svg图像。

为简化起见,我创建了带有简单黑线的bmp图像。

这是Illustrator生成的(SVGKit确实显示了此正确):

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
 width="1024px" height="768px" viewBox="0 0 1024 768" enable-background="new 0 0 1024 768" xml:space="preserve">
    <g>
        <g>
            <path fill-rule="evenodd" clip-rule="evenodd" fill="#FFFFFF" d="M1,0c341,0,682.001,0,1023,0c0,255.995,0,512.006,0,768
        c-341.333,0-682.667,0-1024,0C0,513,0,258,0,3C-0.086,1.581-0.165,0.168,1,0z M160,391c0,5.667,0,11.333,0,17
        c204.999,0,410,0,615,0c0-6.667,0-13.333,0-20c-204.661,0-409.337,0-614,0C159.835,388.168,159.914,389.581,160,391z"/>
            <path fill-rule="evenodd" clip-rule="evenodd" d="M161,388c204.663,0,409.339,0,614,0c0,6.667,0,13.333,0,20
        c-205,0-410.001,0-615,0c0-5.667,0-11.333,0-17C159.914,389.581,159.835,388.168,161,388z"/>
        </g>
    </g>
</svg>

这是potrace生成的内容(SVGKit不能正确显示,但Illustrator可以显示):
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="1024.000000pt" height="768.000000pt" viewBox="0 0 1024.000000 768.000000" preserveAspectRatio="xMidYMid meet">
    <metadata>
    Created by -protrace define- -version define-, written by Peter Selinger 2001-2011
    </metadata>
    <g transform="translate(0.000000,768.000000) scale(0.100000,-0.100000)" fill="#000000" stroke="none">
        <path d="M1600 3700 l0 -100 3075 0 3075 0 0 100 0 100 -3075 0 -3075 0 0 -100z"/>
    </g>
</svg>

因此,据我所知,标题之间存在一些差异,但是即使我在Potrace的结果中使用Illustrator结果中的标题完全相同,SVGKit仍然无法显示它。

因为SVGKit无法显示,所以potrace的结果有什么错误/不同?

最佳答案

这是转换。 SVGKit的核心版本不支持转换。

我的实验分支(最终将合并到内核中)对转换具有良好的支持-它包括Matrix,Translate ...我不确定Scale(如果丢失,只需几分钟即可添加-如果您这样做搜索“矩阵”,我想您会很快找到代码。

注意:此分支更改了加载SVG的语法。这要简单得多,但是您必须调用其他类(SVGKImage)。页面底部自述文件中的完整说明:

https://github.com/adamgit/SVGKit/tree/transforms

09-28 09:34