gpt4 book ai didi

c++ - 有没有办法使用任何 Qt 库类从 SVG 数据中获取正确的边界矩形?

转载 作者:太空宇宙 更新时间:2023-11-04 14:00:21 25 4
gpt4 key购买 nike

如果 SVG 数据有一些像素位于 View 框之外,我如何获得也考虑这些像素的边界矩形。

一个典型的例子是这样的:

<svg id="L.T.S.P" width="100%" height="100%" viewBox="0 0 160 160" version="1.1" baseProfile="full" preserveAspectRatio="xMinYMin meet" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><title>layer</title>
<desc>My Picture</desc>
<ellipse cx="80" cy="80" rx="60" ry="60" fill="none" stroke="rgb(139, 69, 19)" stroke-width="2"/>
<text x="80" y="102" text-anchor="middle" font-family="Arial" font-size="48pt" fill="rgb(139, 69, 19)" stroke="rgb(139, 69, 19)" stroke-width="0.25" style="direction: ltr; unicode-bidi: bidi-override;">T</text>
<g id="port" transform="matrix (1.22e-017, -0.2, 0.2, 1.22e-017, -20, 100)"><polygon points="60,**180** 140,180 160,200 160,40 140,20 60,20 40,40 40,200" fill="none" stroke="rgb(139, 69, 19)" stroke-width="10"/>
<polyline points="60,60 140,60" fill="none" stroke="rgb(139, 69, 19)" stroke-width="10" stroke-dasharray=""/>
<polyline points="60,100 140,100" fill="none" stroke="rgb(139, 69, 19)" stroke-width="10" stroke-dasharray=""/>
<polyline points="60,140 140,140" fill="none" stroke="rgb(139, 69, 19)" stroke-width="10" stroke-dasharray=""/>
<polyline points="100,20 100,0" fill="none" stroke="rgb(139, 69, 19)" stroke-width="10" stroke-dasharray=""/>
</g>
<g id="inputTemperature" transform="matrix (-0.2, -2.45e-017, 2.45e-017, -0.2, 180, 100)"><polyline points="0,100 200,100 80,40" fill="none" stroke="rgb(255, 0, 0)" stroke-width="10" stroke-dasharray=""/>
<polyline points="80,160 200,100" fill="none" stroke="rgb(255, 0, 0)" stroke-width="10" stroke-dasharray=""/>
</g>
</svg>

最佳答案

您应该能够使用 QSvgRenderer获取最顶部元素 id 上的边界框(在本例中为“L.T.S.P”)。

关于c++ - 有没有办法使用任何 Qt 库类从 SVG 数据中获取正确的边界矩形?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19563145/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com