使用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>
小提琴可用here。
我通过蜡染光栅将上面的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>
小提琴可用here。
为什么你认为一个模式是必要的?为什么不直接使用''标签包含图像? –
@RobertLongson这会更简单,并且应该同样适用。感谢您的评论,我会更新我的答案。 –
完美!非常感谢! – qba