Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to calculate viewboxWH (width/height) after loading svg image #133

Open
carloBarazzetta opened this issue Jan 26, 2025 · 1 comment

Comments

@carloBarazzetta
Copy link

Hello, at 6 Jan 2025 I need to change my code of Image32SVGFactory from:
vbox := fSvgReader.RootElement.GetViewbox;
to
vbox := fSvgReader.RootElement.viewboxWH;
because GetViewbox was removed from source of Img32.SVG.Reader, but it is also mentioned in a comment line... ;-)

Now the problem is that, after loading an svg file RootElement.viewboxWH is not initialized, so I need to make a change to source code of Img32.SVG.Reader adding a new public method "CalcViewBoxOfRootElement" like this:

procedure TSvgReader.CalcViewBoxOfRootElement;
begin
  fRootElement.viewboxWH.Width := fRootElement.elRectWH.width.GetValue(defaultSvgWidth, 0);
  fRootElement.viewboxWH.height := fRootElement.elRectWH.height.GetValue(defaultSvgHeight, 0);
end;

Or something else that give me a chance to read the viewbox size, after loading file stream or source stream...
Thanks....
Carlo

@AngusJohnson
Copy link
Owner

Hi Carlo.

I don't understand the problem you're describing, so it'd help if you provided and example.

fRootElement.viewboxWH should be assigned via the Viewbox_Attrib procedure which is called whenever an SVG element's viewbox attribute is encountered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants