/* Freetype GL - A C OpenGL Freetype engine * * Distributed under the OSI-approved BSD 2-Clause License. See accompanying * file `LICENSE` for more details. */ #include #include #include #include #include "edtaa3func.h" double * make_distance_mapd( double *data, unsigned int width, unsigned int height ) { short * xdist = (short *) malloc( width * height * sizeof(short) ); short * ydist = (short *) malloc( width * height * sizeof(short) ); double * gx = (double *) calloc( width * height, sizeof(double) ); double * gy = (double *) calloc( width * height, sizeof(double) ); double * outside = (double *) calloc( width * height, sizeof(double) ); double * inside = (double *) calloc( width * height, sizeof(double) ); double vmin = DBL_MAX; unsigned int i; // Compute outside = edtaa3(bitmap); % Transform background (0's) computegradient( data, width, height, gx, gy); edtaa3(data, gx, gy, width, height, xdist, ydist, outside); for( i=0; i +vmin) outside[i] = +vmin; data[i] = (outside[i]+vmin)/(2*vmin); } free( xdist ); free( ydist ); free( gx ); free( gy ); free( outside ); free( inside ); return data; } unsigned char * make_distance_mapb( unsigned char *img, unsigned int width, unsigned int height ) { double * data = (double *) calloc( width * height, sizeof(double) ); unsigned char *out = (unsigned char *) malloc( width * height * sizeof(unsigned char) ); unsigned int i; // find minimimum and maximum values double img_min = DBL_MAX; double img_max = DBL_MIN; for( i=0; i img_max) img_max = v; if (v < img_min) img_min = v; } // Map values from 0 - 255 to 0.0 - 1.0 for( i=0; i