#935: Fixed ExposureTime pretty-print function.

v0.27.3
Andreas Huggel 10 years ago
parent e628f8e057
commit 02d6f8460a

@ -2463,22 +2463,23 @@ namespace Exiv2 {
std::ostream& print0x829a(std::ostream& os, const Value& value, const ExifData*) std::ostream& print0x829a(std::ostream& os, const Value& value, const ExifData*)
{ {
Rational t = value.toRational(); if (value.count() == 0) return os;
if (t.first > 1 && t.second > 1 && t.second >= t.first) { if (value.typeId() != unsignedRational) return os << "(" << value << ")";
t.second = static_cast<uint32_t>(
static_cast<float>(t.second) / t.first + 0.5); URational t = value.toRational();
t.first = 1; if (t.first == 0 || t.second == 0) {
os << "(" << t << ")";
} }
if (t.second > 1 && t.second < t.first) { else if (t.second == t.first) {
t.first = static_cast<uint32_t>( os << "1 s";
static_cast<float>(t.first) / t.second + 0.5);
t.second = 1;
} }
if (t.second == 1) { else if (t.second % t.first == 0) {
os << t.first << " s"; t.second = t.second / t.first;
t.first = 1;
os << t << " s";
} }
else { else {
os << t.first << "/" << t.second << " s"; os << static_cast<float>(t.first) / t.second << " s";
} }
return os; return os;
} }

Loading…
Cancel
Save