linebender / resvg

An SVG rendering library.
Mozilla Public License 2.0
2.79k stars 225 forks source link

C render bounding box help #793

Closed jeff8j closed 3 months ago

jeff8j commented 3 months ago

I am trying to render just the bounding box with the C API

So far I can get the bounding box resvg_rect bbox; resvg_get_image_bbox(tree, &bbox)

and with that I have rect (width, height, x, y) I can render the correct width and height resvg_render(tree, transform, width, height, (char*)surface_data); but I cant figure out how to render starting at the x and y for the bounding box

I see in the .h file line 456 transform A root SVG transform. Can be used to position SVG inside the pixmap. through testing I found the transform.a = scale_x and the transform.d = scale_y

This page looks to show the transform documentation https://docs.rs/tiny-skia-path/0.11.4/tiny_skia_path/struct.Transform.html but I havent figured out what kx ky tx ty mean

Can someone help me figure out transform or tell me im doing it wrong lol Thank you

jeff8j commented 3 months ago

Update I think tx,ty must mean translate and I am assuming kx,ky = skew

RazrFalcon commented 3 months ago

Yes, sort of. But it's a bit more complex.

For a simple translate 1 0 0 1 X Y is enough.