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

Rasterization errors on small details #503

Open
Azervu opened this issue Feb 7, 2022 · 4 comments
Open

Rasterization errors on small details #503

Azervu opened this issue Feb 7, 2022 · 4 comments

Comments

@Azervu
Copy link

Azervu commented Feb 7, 2022

This test image has some rasterization issues

<?xml version="1.0" encoding="UTF-8"?>
<svg width="15" height="15" version="1.1" viewBox="0 0 15 15" xmlns="http://www.w3.org/2000/svg">
 <path d="m3.875 1v2.875h-2.875v1.25h2.875v2.875h1.25v-2.875h2.875v-1.25h-2.875v-2.875z" fill="#ff0" stop-color="#000000"/>
 <path d="m7.5 7.5h5v5h-5z" fill="none" stop-color="#000000" stroke="#f00" stroke-linecap="square"/>
</svg>

Result(scale up x8):

test_resvg

Inkscape for comparison:
test_inkscape

@RazrFalcon
Copy link
Collaborator

Seems like a tiny-skia/Skia bug to me.

This is how Skia itself renders it:

image

A bit different, but still not quite right.

You can actually mitigate it by removing stroke-linecap="square"

I will keep this bug open, but it has nothing to do with resvg, bug rather with tiny-skia. See linebender/tiny-skia#44

@Azervu
Copy link
Author

Azervu commented Feb 7, 2022

Can confirm the workaround works on the red one, the yellow one hovever turned out to be an aliasing issue.

Edit: issue linebender/tiny-skia#8 would fix this

@RazrFalcon
Copy link
Collaborator

Are you sure it relates to analytical anti-aliasing? In Skia, it triggered only in specific cases and I'm not sure it affects your case.

@Azervu
Copy link
Author

Azervu commented Feb 8, 2022

The issue is the path intersecting the sampling points

<svg xmlns="http://www.w3.org/2000/svg" width="23" height="13">
	<path d="M3.876 1v2.876H1v1.248h2.876V8h1.248V5.124H8V3.876H5.124V1z" fill="#f00"/>
	<path d="M10.875 5v2.875H8v1.25h2.875V12h1.25V9.125H15v-1.25h-2.875V5z" fill="#ff0"/>
	<path d="M17.874 1v2.874H15v1.252h2.874V8h1.252V5.126H22V3.874h-2.874V1z" fill="#0f0"/>
</svg>

test
The red cross is slightly smaller, the green slightly larger.

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