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

insert SVG file to data buffer #190

Open
OriBibi opened this issue Dec 19, 2020 · 3 comments
Open

insert SVG file to data buffer #190

OriBibi opened this issue Dec 19, 2020 · 3 comments

Comments

@OriBibi
Copy link

OriBibi commented Dec 19, 2020

After I got svg file(I hope it's ok the way I did it..) I want to convert the NSVGimage* to some buffer (like grayscale).

char* someSVGstring="<svg width=\"720\" height=\"576\"><text x='0' y='15' fill='red'>I love SVG Too!"</text></svg>";
struct NSVGimage* Image;
Image = nsvgParse(someSVGstring, "px", 96.0f);

//now, insert Image  to buffer

I dont need to show the picture, all I want is to get the image in buffer. can you help me to do that?

@darealshinji
Copy link
Contributor

I was also thinking about storing NSVG struct data in a buffer and use that instead of an embedded SVG file in cases where I need embedded vector graphics.
Here's something I came up with (storing the NSVG data in a file however): https://gist.github.com/darealshinji/b857c8690e6919888300979d950ec15d
But it's messy and loading the data from the file doesn't work. Maybe you can make something out of it.

@oehhar
Copy link
Contributor

oehhar commented Jan 18, 2021

To convert the parsed svg to an raster image, an example rasterizer is availaibe in the file "nanosvgrast.h".

For a usage example, you may look to the git project TkSVG

Hope this helps,
Harald

@darealshinji
Copy link
Contributor

example2.c is a good starting point: https://github.com/memononen/nanosvg/blob/master/example/example2.c

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

3 participants