Comments (18)
@erentknn With the latest commit you can now do this 7a175d4
Bitmap bitmap{width, height};
Matrix matrix{1, 0, 0, 1, -x, -y};
document->render(bitmap, matrix);
Hope that this will solve this problem.
from lunasvg.
sure, svg.zip
from lunasvg.
Here it is, for explanation x and y are the original coordinates in the original image (think like I have 40k x 40k image and this is a small piece in it) and I am shifting to that coordinates so I can render the right place. It's the same as in svgImage->translate(). But I provided this in the svg file for you so probably those are, shifting coordinates, unnecessary now. I hope that has been explanatory.
const auto svgStrPtr = new char[svgStr.length() + 1];
svgStrPtr[svgStr.length()] = '\0';
strcpy(svgStrPtr, svgStr.c_str());
nsvgImage = nsvgParse(svgStrPtr, "px", 96.0f);
auto rast = nsvgCreateRasterizer(); // Create rasterizer
auto img = static_cast<unsigned char*>(malloc(widthCalc * heightCalc * 4));
nsvgRasterize(rast, nsvgImage, -x, -y, 1, img, widthCalc, heightCalc, widthCalc * 4);
auto res = cv::Mat(heightCalc, widthCalc, CV_8UC4);
res.data = img;
cv::cvtColor(res, res, CV_RGBA2GRAY);
res = res > 0;
nsvgDeleteRasterizer(rast);
free(img);
from lunasvg.
Thanks. I will work on it this weekend.
from lunasvg.
Please can you give me the SVG file
from lunasvg.
sure, svg.zip
from lunasvg.
oops, sorry. fixed it now: svg.zip
from lunasvg.
With nanosvg I could do this with no overhead.
Please can you give me the nanosvg example code so that I can fully understand what you are trying to do.
from lunasvg.
@erentknn if you are still having issues. Please let me know
from lunasvg.
Hey @sammycage, thank you for quick response. but unfortunately it's still not working. I am using the same code as above.
from lunasvg.
Sample code
auto document = Document::loadFromData("a.svg");
document->translate(-50, -50);
Before :
After :
from lunasvg.
But I provided this in the svg file for you so probably those are, shifting coordinates, unnecessary now.
Please make sure that you are not using the modified file
from lunasvg.
I think I explained the problem wrong. Translating works OK. What I am trying to do is sliding over the SVG Image, with nanosvg in my first output is like this:
Second image is the tagged area (approximately):
Like this, I want to loop on the whole SVG tile by tile.
BTW after your modification I can't get any output. Just blank image.
from lunasvg.
@erentknn Did you mean Scaling?
from lunasvg.
@erentknn is the height and width in lunasvg::Bitmap bitmap = svgImage->renderToBitmap(width, height)
different from the one in the file.
from lunasvg.
However I want to process this normally big (7k x 7k) image tile by tile.
Now I understand what you are trying to do
Use Document::render
instead
Example :
Bitmap bitmap{width, height};
document->translate(-x, -y);
document->render(bitmap);
from lunasvg.
@erentknn is the height and width in
lunasvg::Bitmap bitmap = svgImage->renderToBitmap(width, height)
different from the one in the file.
Yes, width and height are 1024.
Now I understand what you are trying to do
Use
Document::render
insteadExample :
Bitmap bitmap{width, height}; document->translate(-x, -y); document->render(bitmap);
Now I can render the first tile correctly. But after that it's blank image again.
from lunasvg.
THANK YOU, It worked as expected.
from lunasvg.
Related Issues (20)
- 'Tiger' renders with the wrong colours? HOT 4
- Memory leak? HOT 2
- Colour format/conversion clarification. HOT 1
- Unable to rotate image with rotate or scale HOT 3
- Performance issue when used from ImGui as a SVG font loader HOT 10
- Taking Pull requests? SVG2ICO example. HOT 7
- Black box instead of image HOT 2
- Optional C++ version of plutovg HOT 3
- Is there chance that c6cad06 checking is braking the library HOT 7
- stack-buffer-overflow has occurred when running program svgpng in function gray_split_cubic at plutovg-ft-raster.c
- Floating point exception has occurred when running program svgpng in function blend_transformed_tiled_argb at plutovg-blend.c
- SEGV has occurred when running program svgpng in function lunasvg::Bitmap::clear at lunasvg.cpp
- C wrapper functions
- Render svg element HOT 14
- Local transformations and high-level function capable of simplifying some tasks HOT 2
- Local transformation and internal SVG element access - Element Box attributes HOT 5
- Local transformation and internal SVG element access - Text object attributes
- Local transformation and internal SVG element access - Element translation HOT 2
- Vulnerability Discovery HOT 1
- Unexpected PNG conversion from SVG file format HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lunasvg.