summaryrefslogtreecommitdiff
path: root/src/lib/ratio.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-09-03 23:34:32 +0100
committerCarl Hetherington <cth@carlh.net>2014-09-03 23:34:32 +0100
commit4a33cfc3b4c51d4e047879051d70ae56ec8ee6e1 (patch)
treef0d60dd160db8f0b9efd3c3ab2d8581d1b4d7401 /src/lib/ratio.cc
parent5db632783b3eba64d39538d1f29ccfe26adaaf19 (diff)
Put the right 'actual' ratio in DCP titles even with no-stretch and no-scale.
Diffstat (limited to 'src/lib/ratio.cc')
-rw-r--r--src/lib/ratio.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/lib/ratio.cc b/src/lib/ratio.cc
index 4a5b39a22..554d3c36c 100644
--- a/src/lib/ratio.cc
+++ b/src/lib/ratio.cc
@@ -56,3 +56,20 @@ Ratio::from_id (string i)
return *j;
}
+
+/** @return Ratio corresponding to a given fractional ratio (+/- 0.01), or 0 */
+Ratio const *
+Ratio::from_ratio (float r)
+{
+ vector<Ratio const *>::iterator j = _ratios.begin ();
+ while (j != _ratios.end() && fabs ((*j)->ratio() - r) > 0.01) {
+ ++j;
+ }
+
+ if (j == _ratios.end ()) {
+ return 0;
+ }
+
+ return *j;
+}
+