diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-11-11 00:04:02 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-11-11 00:04:02 +0000 |
| commit | 58f0530b1687673ea6e24a083063c3fdf2bff0b2 (patch) | |
| tree | 1f76acad0a2877e527c936f754dde16eaf2d768e /src/lib/ratio.cc | |
| parent | 985a83ffbf251db481150221914ef74fbfe549b2 (diff) | |
Hand-apply 80562fe5dce5fd625da583ca6f7c2833f9db8754 from master (remove default scale and use a scale guessed from the content's size and sample aspect ratio).
Diffstat (limited to 'src/lib/ratio.cc')
| -rw-r--r-- | src/lib/ratio.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/lib/ratio.cc b/src/lib/ratio.cc index fc36415c5..bc83ae87c 100644 --- a/src/lib/ratio.cc +++ b/src/lib/ratio.cc @@ -73,3 +73,19 @@ Ratio::from_ratio (float r) return *j; } +Ratio const * +Ratio::nearest_from_ratio (float r) +{ + Ratio const * nearest = 0; + float distance = FLT_MAX; + + for (vector<Ratio const *>::iterator i = _ratios.begin (); i != _ratios.end(); ++i) { + float const d = fabs ((*i)->ratio() - r); + if (d < distance) { + distance = d; + nearest = *i; + } + } + + return nearest; +} |
