[英]TranscoderException when converting svg to image using Batik
[英]Batik - put SVG on top of image
我有一個圖像文件(jpg等)和一些svg繪圖(從站點復制的svg標記,如Java String)。 svg繪圖與圖像文件具有相同的分辨率。 我想將svg繪圖放在圖像上方,並將其另存為一個文件。 我的方法引以為傲,但我並不為此感到驕傲,但可以起作用:
我希望能夠一步將svg圖紙放在圖像上。
使用SVG模式可以解決您的問題。
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="200" height="200">
<defs>
<pattern id="image" x="0" y="0" patternUnits="userSpaceOnUse" height="200" width="200">
<image x="0" y="0" width="200" height="200"
xlink:href="http://cdn.sstatic.net/stackexchange/img/logos/so/so-logo.png"/>
</pattern>
</defs>
<rect width="200" height="200" fill="url(#image)"/>
<circle cx="100" cy="100" r="50"/>
</svg>
小提琴在這里提供 。
我通過蠟染光柵化器將SVG拉到上方,並且光柵化正確。
更新資料
如評論中所述,您也可以將圖像直接包含在SVG中,而無需使用模式。
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="200" height="200">
<image x="0" y="0" width="200" height="200"
xlink:href="http://cdn.sstatic.net/stackexchange/img/logos/so/so-logo.png"/>
<circle cx="100" cy="100" r="50"/>
</svg>
小提琴在這里提供 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.