forked from rougier/freetype-gl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
distance-field.h
67 lines (60 loc) · 1.39 KB
/
distance-field.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* Freetype GL - A C OpenGL Freetype engine
*
* Distributed under the OSI-approved BSD 2-Clause License. See accompanying
* file `LICENSE` for more details.
*/
#ifndef __DISTANCE_FIELD_H__
#define __DISTANCE_FIELD_H__
#ifdef __cplusplus
extern "C" {
namespace ftgl {
#endif
/**
* @file shader.h
* @author Nicolas Rougier ([email protected])
*
* @defgroup distance-field Distance Field
*
* Functions to calculate signed distance fields for bitmaps.
*
* <b>Example Usage</b>:
* @code
* #include "distance-field.h"
*
* int main( int arrgc, char *argv[] )
* {
* int width = 512;
* int height = 512;
* unsigned char *image = create_greyscale_image(width, height);
*
* image = make_distance_map( image, width, height );
*
* return 0;
* }
* @endcode
*
* @{
*/
/**
* Create a distance file from the given image.
*
* @param img A greyscale image.
* @param width The width of the given image.
* @param height The height of the given image.
*
* @return A newly allocated distance field. This image must
* be freed after usage.
*
*/
double *
make_distance_mapd( double *img,
unsigned int width, unsigned int height );
unsigned char *
make_distance_mapb( unsigned char *img,
unsigned int width, unsigned int height );
/** @} */
#ifdef __cplusplus
}
}
#endif
#endif /* __DISTANCE_FIELD_H__ */