Browse Source

Added interface to raster only one shape

master
Macoy Madson 2 months ago
parent
commit
7229f59adc
  1. 22
      src/nanosvgrast.h

22
src/nanosvgrast.h

@ -65,6 +65,11 @@ void nsvgRasterize(NSVGrasterizer* r,
NSVGimage* image, float tx, float ty, float scale,
unsigned char* dst, int w, int h, int stride);
// Use shapeFilter to only rasterize a single shape. NULL to disable
void nsvgRasterizeEx(NSVGrasterizer* r,
NSVGimage* image, NSVGshape* shapeFilter, float tx, float ty, float scale,
unsigned char* dst, int w, int h, int stride);
// Deletes rasterizer context.
void nsvgDeleteRasterizer(NSVGrasterizer*);
@ -1365,9 +1370,9 @@ static void dumpEdges(NSVGrasterizer* r, const char* name)
}
*/
void nsvgRasterize(NSVGrasterizer* r,
NSVGimage* image, float tx, float ty, float scale,
unsigned char* dst, int w, int h, int stride)
void nsvgRasterizeEx(NSVGrasterizer* r,
NSVGimage* image, NSVGshape* shapeFilter, float tx, float ty, float scale,
unsigned char* dst, int w, int h, int stride)
{
NSVGshape *shape = NULL;
NSVGedge *e = NULL;
@ -1392,6 +1397,9 @@ void nsvgRasterize(NSVGrasterizer* r,
if (!(shape->flags & NSVG_FLAGS_VISIBLE))
continue;
if (shapeFilter && shape != shapeFilter)
continue;
if (shape->fill.type != NSVG_PAINT_NONE) {
nsvg__resetPool(r);
r->freelist = NULL;
@ -1454,6 +1462,14 @@ void nsvgRasterize(NSVGrasterizer* r,
r->stride = 0;
}
void nsvgRasterize(NSVGrasterizer* r,
NSVGimage* image, float tx, float ty, float scale,
unsigned char* dst, int w, int h, int stride)
{
nsvgRasterizeEx(r, image, NULL, tx, ty, scale,
dst, w, h, stride);
}
#endif // NANOSVGRAST_IMPLEMENTATION
#endif // NANOSVGRAST_H

Loading…
Cancel
Save