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

Cannot parse some SVG's tile by tile #55

Closed
erentknn opened this issue Jul 7, 2021 · 15 comments
Closed

Cannot parse some SVG's tile by tile #55

erentknn opened this issue Jul 7, 2021 · 15 comments
Labels
bug Something isn't working

Comments

@erentknn
Copy link

erentknn commented Jul 7, 2021

I have two SVG's. One is smaller (12k x 7k) other one is bigger (28k x 32k) I can parse the smaller one tile by tile with no problem. But with other one I get Access Violation error. I triple checked the code and cannot find any problem. Here is a sample code to reproduce it:

std::vector<std::vector<float>> tileParamList; // coordinates from the json file
const int width = 1024;
const int height = 1024;
auto svgImage = lunasvg::Document::loadFromData(svgStr);

for (int i = 0; i < tileParamList.size(); i++)
{
	lunasvg::Bitmap bitmap{ width, height };
	lunasvg::Matrix matrix{ 1, 0, 0, 1, -tileParamList[i][0], -tileParamList[i][1] };
	
	svgImage->render(bitmap, matrix); <----------- HERE

	auto res = cv::Mat(height, width, CV_8UC4);
	res.data = bitmap.data();
	cv::cvtColor(res, res, CV_RGBA2GRAY);
	res = res > 0;
}

SVG and tileList can be found here: broken.zip
And other SVG can be found here (One that works correctly. Note: First few iterations might be blank image.): notbroken.zip

@sammycage sammycage added the bug Something isn't working label Jul 7, 2021
@sammycage
Copy link
Owner

sammycage commented Jul 7, 2021

short overflow in plutovg 🤯🤯🤯

@sammycage
Copy link
Owner

@erentknn Did you have access to cairo library?

@erentknn
Copy link
Author

erentknn commented Jul 7, 2021

@sammycage No, I never used it before.

@sammycage
Copy link
Owner

@erentknn Are you using Linux or Windows?

@erentknn
Copy link
Author

erentknn commented Jul 7, 2021

@sammycage Windows.

@sammycage
Copy link
Owner

sammycage commented Jul 7, 2021

OK.. I will try to replace plutovg with Blend2D. It is very fast compare to other renderer.

@erentknn
Copy link
Author

erentknn commented Jul 7, 2021

Short overflow in plutovg 🤯🤯🤯

BTW, isn't it easier to fix the short overflow rather than replacing the all library?

@sammycage
Copy link
Owner

sammycage commented Jul 7, 2021

The problem is from freetype code inside PlutoVG... This makes it more difficult for me to fix.

@sammycage
Copy link
Owner

sammycage commented Jul 7, 2021

Let me explain the problem to you.

FT_Outline can only handle maximum of 32,767 points. But the svg file you provided has only just one path element that contains 175,537 points.

@erentknn
Copy link
Author

erentknn commented Jul 7, 2021

Wow. That's a lot of points. Thank you for the explanation. Is there anything I can do for help?

@sammycage
Copy link
Owner

sammycage commented Jul 7, 2021

Is the SVG file manually generated?

Is there anything I can do for help?

Try decrease the number of points by increasing the number of path elements with less points.

@erentknn
Copy link
Author

erentknn commented Jul 7, 2021

Yes, I am creating SVG from the contours found earlier.

Try decrease the number of points by increasing the number of path elements with less points.

I will try this.

@sammycage sammycage reopened this Jul 7, 2021
@sammycage
Copy link
Owner

Yes, I am creating SVG from the contours found earlier.

If you need my help, please let me know.

@erentknn
Copy link
Author

erentknn commented Jul 9, 2021

I split the path into multiple paths but result was not the same as before on both SVG's. Probably because of contours that are on multiple tiles breaks something. So I guess I have to wait your fix on issue 🤷‍♂️

@sammycage
Copy link
Owner

sammycage commented Jul 10, 2021

This is the blend2d binding lunasvg-blend2d.zip

I will fix this issue later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants