SVG scaling [SOLVED]
Posted
#1
(In Topic #1012)
Regular

Code (gambas)
- ' Method A = Sharp
- IconView1.Add(0, TmpDescription, Pic_A)
- ' Method B = Blurry
Code (gambas)
- 'Keep looking
- Exit 'For
- mainNode.NewAttribute("width", DesiredWidth)
- mainNode.NewAttribute("height", DesiredHeight)
- ' mainNode.NewAttribute("viewBox", "0 0 16 16")
- mainNode.NewAttribute("viewBox", "0 0 " & OrigWidth & " " & OrigHeight)
- ' mainNode.NewAttribute("viewBox", "-0.2 -0.2 " & OrigWidth & ".4 " & OrigHeight & "16.4")
- FixedSvg = doc.ToString()
- Return FixedSvg
Posted
Guru

What is the best way to properly scale an svg graphic for use in Gambas IconView?
Well, I have just spent about an hour and a half on this and came up with the following that uses a little less code. Note that line 24 is needed as for some reason a SVG image saved at 128,128 ends up at 160,160!
Code (gambas)
- ' Method A = Sharp
- IconView1.Add(0, TmpDescription, LoadSVG(FilePath, 256, 256))
- ' Method B = Blurry
- hSVG.Resize(iWidth, iHeight)
- hSVG.Save("/tmp/SVG.svg")
- Return pPic
<IMG src="https://www.cogier.com/gambas/SVG1.png">
</IMG>
Posted
Regular

It's a shame that using svgs in gambas is not a trivial task.
Posted
Guru

Here's a function to create a Picture object from an svgimage using it's Resize and Paint methods
Code (gambas)
PS. svgimage according to wiki is not great because qt svg methods are buggy.
/comp/gb.qt4/svgimage - Gambas Documentation
Posted
Regular

1 guest and 0 members have just viewed this.


