unsigned sqrti(unsigned num)
{
- unsigned result = num;
- while(result*result>num)
- {
- unsigned diff = result*result-num;
- if(diff<result)
- break;
-
- result -= (diff+result)/(result*2);
- }
+ unsigned result = (num>0xFFFF ? 0xFFFF : 0x100);
+ while(result && result*result>=result+num)
+ result -= (result*result+result-num)/(result*2);
return result;
}
}
}
- return sqrti(closest)*0x7F/range;
+ return sqrti(closest*0x3F01)/range;
}
int create_distance_field(const FT_Bitmap *bmp, Image *image, unsigned scale, unsigned margin)