clip paths are incorrect with transform
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 4.1k
- Forks
- 348
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 3
Description
I'm trying to render tiles of the full SVG. It works fine for many files but breaks for files with clip paths. Try the attached SVG with a modified version of the cairo example:
```
diff --git a/crates/c-api/examples/cairo/example.c b/crates/c-api/examples/cairo/example.c
index 23a3b45a..ab3bc558 100644
--- a/crates/c-api/examples/cairo/example.c
+++ b/crates/c-api/examples/cairo/example.c
@@ -29,6 +29,7 @@ int main(int argc, char **argv)
resvg_size size = resvg_get_image_size(tree);
int width = (int)size.width;
int height = (int)size.height;
+ height = 270;
cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
@@ -37,7 +38,9 @@ int main(int argc, char **argv)
unsigned char *surface_data = cairo_image_surface_get_data(surface);
- resvg_render(tree, resvg_transform_identity(), width, height, (char*)surface_data);
+ resvg_transform transform = resvg_transform_identity();
+ transform.f = -height * 3;
+ resvg_render(tree, transform, width, height, (char*)surface_data);
/* RGBA -> BGRA */
for (int i = 0; i < width * height * 4; i += 4)
```
```
make
LD_LIBRARY_PATH=../../../../target/debug ./example clipPath.svg clipPath.png
```
This still works if the offset is 0 or if the full height is used, but the combination of offset, crop, and clip path cause most of the image to disappear.


It seems to be an old bug (at least present in 0.33.0).
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with crates/c-api/examples/cairo/example.c, the modified transform, and the supplied clipPath.svg using the shown make and LD_LIBRARY_PATH commands. Start at the resvg_render entry point and trace transformed clip-path handling. Done means the cropped render preserves the clipped image when a nonzero transform offset is used.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, rust
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100