Fix #4532, Fix #4533 : Pentax HDR/PEF and 16/24 bits float support

This commit is contained in:
Hombre
2018-05-06 17:14:44 +02:00
parent a6f82d0212
commit ec2181f7ff
10 changed files with 103 additions and 40 deletions

View File

@@ -463,22 +463,34 @@ Tag* TagDirectory::findTag (const char* name, bool lookUpward) const
return t;
}
Tag* foundTag = nullptr;
int tagDistance = 10000;
for (auto tag : tags) {
if (tag->isDirectory()) {
TagDirectory *dir;
int i = 0;
// Find the shortest path to that tag
while ((dir = tag->getDirectory(i)) != nullptr) {
TagDirectory *dir = tag->getDirectory();
Tag* t = dir->findTag (name);
if (t) {
return t;
int currTagDistance = t->getDistanceFrom(this);
if (currTagDistance < tagDistance) {
tagDistance = currTagDistance;
foundTag = t;
}
}
++i;
}
}
}
if (foundTag) {
return foundTag;
}
if (lookUpward && parent) {
Tag* t = parent->findTagUpward(name);
@@ -1420,6 +1432,20 @@ Tag::~Tag ()
}
}
int Tag::getDistanceFrom(const TagDirectory *root)
{
int i = 0;
TagDirectory *currTagDir = parent;
while (currTagDir != nullptr && currTagDir != root) {
++i;
if (parent->getParent() == currTagDir) {
break;
}
currTagDir = parent->getParent();
}
return i;
}
void Tag::setInt (int v, int ofs, TagType astype)
{

View File

@@ -281,15 +281,15 @@ public:
}
// read/write value
int toInt (int ofs = 0, TagType astype = INVALID) const;
void fromInt (int v);
double toDouble (int ofs = 0) const;
double* toDoubleArray (int ofs = 0) const;
void toRational (int& num, int& denom, int ofs = 0) const;
void toString (char* buffer, int ofs = 0) const;
void fromString (const char* v, int size = -1);
void setInt (int v, int ofs = 0, TagType astype = LONG);
int toInt (int ofs = 0, TagType astype = INVALID) const;
void fromInt (int v);
double toDouble (int ofs = 0) const;
double* toDoubleArray (int ofs = 0) const;
void toRational (int& num, int& denom, int ofs = 0) const;
void toString (char* buffer, int ofs = 0) const;
void fromString (const char* v, int size = -1);
void setInt (int v, int ofs = 0, TagType astype = LONG);
int getDistanceFrom (const TagDirectory *root);
// additional getter/setter for more comfortable use
std::string valueToString ();