2 * Copyright (c) 2013-14 Mikko Mononen memon@inside.org
4 * This software is provided 'as-is', without any express or implied
5 * warranty. In no event will the authors be held liable for any damages
6 * arising from the use of this software.
8 * Permission is granted to anyone to use this software for any purpose,
9 * including commercial applications, and to alter it and redistribute it
10 * freely, subject to the following restrictions:
12 * 1. The origin of this software must not be misrepresented; you must not
13 * claim that you wrote the original software. If you use this software
14 * in a product, an acknowledgment in the product documentation would be
15 * appreciated but is not required.
16 * 2. Altered source versions must be plainly marked as such, and must not be
17 * misrepresented as being the original software.
18 * 3. This notice may not be removed or altered from any source distribution.
20 * The polygon rasterization is heavily based on stb_truetype rasterizer
21 * by Sean Barrett - http://nothings.org/
30 typedef struct NSVGrasterizer NSVGrasterizer;
35 image = nsvgParseFromFile("test.svg", "px", 96);
37 // Create rasterizer (can be used to render multiple images).
38 struct NSVGrasterizer* rast = nsvgCreateRasterizer();
39 // Allocate memory for image
40 unsigned char* img = malloc(w*h*4);
42 nsvgRasterize(rast, image, 0,0,1, img, w, h, w*4);
45 // Allocated rasterizer context.
46 NSVGrasterizer* nsvgCreateRasterizer();
48 // Rasterizes SVG image, returns RGBA image (non-premultiplied alpha)
49 // r - pointer to rasterizer context
50 // image - pointer to image to rasterize
51 // tx,ty - image offset (applied after scaling)
52 // scale - image scale
53 // dst - pointer to destination image data, 4 bytes per pixel (RGBA)
54 // w - width of the image to render
55 // h - height of the image to render
56 // stride - number of bytes per scaleline in the destination buffer
57 void nsvgRasterize(NSVGrasterizer* r,
58 NSVGimage* image, float tx, float ty, float scale,
59 unsigned char* dst, int w, int h, int stride);
61 // Deletes rasterizer context.
62 void nsvgDeleteRasterizer(NSVGrasterizer*);
65 #endif // NANOSVGRAST_H
68 * In the original software, The nanosvgrast implementation was followed here.
69 * We have moved the implementation to nanosvgrast.cc.