Merge "Updated NanoSVG to latest version (22 April 2019)" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / third-party / nanosvg / nanosvgrast.h
1 /*
2  * Copyright (c) 2013-14 Mikko Mononen memon@inside.org
3  *
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.
7  *
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:
11  *
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.
19  *
20  * The polygon rasterization is heavily based on stb_truetype rasterizer
21  * by Sean Barrett - http://nothings.org/
22  *
23  */
24
25 #ifndef NANOSVGRAST_H
26 #define NANOSVGRAST_H
27
28 #include "nanosvg.h"
29
30 typedef struct NSVGrasterizer NSVGrasterizer;
31
32 /* Example Usage:
33   // Load SVG
34   NSVGimage* image;
35   image = nsvgParseFromFile("test.svg", "px", 96);
36
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);
41   // Rasterize
42   nsvgRasterize(rast, image, 0,0,1, img, w, h, w*4);
43 */
44
45 // Allocated rasterizer context.
46 NSVGrasterizer* nsvgCreateRasterizer();
47
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);
60
61 // Deletes rasterizer context.
62 void nsvgDeleteRasterizer(NSVGrasterizer*);
63
64
65 #endif // NANOSVGRAST_H
66
67 /**
68  * In the original software, The nanosvgrast implementation was followed here.
69  * We have moved the implementation to nanosvgrast.cc.
70  */