LCP CA correction now usable on more RAW types
see issue 1421
This commit is contained in:
@@ -172,10 +172,22 @@ void ImageData::extractInfo () {
|
|||||||
focal_len = exif->getTag ("FocalLength")->toDouble ();
|
focal_len = exif->getTag ("FocalLength")->toDouble ();
|
||||||
if (exif->getTag ("FocalLengthIn35mmFilm"))
|
if (exif->getTag ("FocalLengthIn35mmFilm"))
|
||||||
focal_len35mm = exif->getTag ("FocalLengthIn35mmFilm")->toDouble ();
|
focal_len35mm = exif->getTag ("FocalLengthIn35mmFilm")->toDouble ();
|
||||||
rtexif::Tag* pDst=exif->getTag("SubjectDistance"); // EXIF, set by Adobe. MakerNote ones are scattered and partly encrypted
|
|
||||||
|
// Focus distance from EXIF or XMP. MakerNote ones are scattered and partly encrypted
|
||||||
|
int num=-3, denom=-3;
|
||||||
|
|
||||||
|
// First try, offical EXIF. Set by Adobe on some DNGs
|
||||||
|
rtexif::Tag* pDst=exif->getTag("SubjectDistance");
|
||||||
if (pDst) {
|
if (pDst) {
|
||||||
int num, denom;
|
int num, denom;
|
||||||
pDst->toRational(num,denom);
|
pDst->toRational(num,denom);
|
||||||
|
} else {
|
||||||
|
// Second try, XMP data
|
||||||
|
char sXMPVal[64];
|
||||||
|
if (root->getXMPTagValue("aux:ApproximateFocusDistance",sXMPVal)) { sscanf(sXMPVal,"%d/%d",&num,&denom); }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (num!=-3) {
|
||||||
if ((denom==1 && num>=10000) || num<0 || denom<0)
|
if ((denom==1 && num>=10000) || num<0 || denom<0)
|
||||||
focus_dist=10000; // infinity
|
focus_dist=10000; // infinity
|
||||||
else if (denom>0) {
|
else if (denom>0) {
|
||||||
|
@@ -213,6 +213,51 @@ Tag* TagDirectory::findTag (const char* name) const {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Searches a simple value, as either attribute or element
|
||||||
|
// only for simple values, not for entries with special chars or free text
|
||||||
|
bool TagDirectory::getXMPTagValue(const char* name, char* value) const {
|
||||||
|
*value=0;
|
||||||
|
|
||||||
|
if (!getTag("ApplicationNotes")) return false;
|
||||||
|
char *sXMP = (char*)getTag("ApplicationNotes")->getValue();
|
||||||
|
|
||||||
|
// Check for full word
|
||||||
|
char *pos=sXMP;
|
||||||
|
|
||||||
|
bool found=false;
|
||||||
|
do {
|
||||||
|
pos=strstr(pos,name);
|
||||||
|
if (pos) {
|
||||||
|
char nextChar=*(pos+strlen(name));
|
||||||
|
if (nextChar==' ' || nextChar=='>' || nextChar=='=')
|
||||||
|
found=true;
|
||||||
|
else
|
||||||
|
pos+=strlen(name);
|
||||||
|
}
|
||||||
|
} while (pos && !found);
|
||||||
|
if (!found) return false;
|
||||||
|
|
||||||
|
char *posTag =strchr(pos,'>');
|
||||||
|
char *posAttr=strchr(pos,'"');
|
||||||
|
|
||||||
|
if (!posTag && !posAttr) return false;
|
||||||
|
|
||||||
|
if (posTag && (!posAttr || posTag<posAttr)) {
|
||||||
|
// Tag
|
||||||
|
pos=strchr(posTag+1,'<');
|
||||||
|
strncpy(value,posTag+1,pos-posTag-1);
|
||||||
|
value[pos-posTag-1]=0;
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
if (posAttr && (!posTag || posAttr<posTag)) {
|
||||||
|
// Attribute
|
||||||
|
pos=strchr(posAttr+1,'"');
|
||||||
|
strncpy(value,posAttr+1,pos-posAttr-1);
|
||||||
|
value[pos-posAttr-1]=0;
|
||||||
|
return true;
|
||||||
|
} else return false;
|
||||||
|
}
|
||||||
|
|
||||||
void TagDirectory::keepTag (int ID) {
|
void TagDirectory::keepTag (int ID) {
|
||||||
for (size_t i=0; i<tags.size(); i++)
|
for (size_t i=0; i<tags.size(); i++)
|
||||||
if (tags[i]->getID()==ID) tags[i]->setKeep(true);
|
if (tags[i]->getID()==ID) tags[i]->setKeep(true);
|
||||||
|
@@ -83,6 +83,7 @@ class TagDirectory {
|
|||||||
virtual Tag* getTag (const char* name) const;
|
virtual Tag* getTag (const char* name) const;
|
||||||
virtual Tag* getTag (int ID) const;
|
virtual Tag* getTag (int ID) const;
|
||||||
virtual Tag* findTag (const char* name) const;
|
virtual Tag* findTag (const char* name) const;
|
||||||
|
bool getXMPTagValue(const char* name, char* value) const;
|
||||||
|
|
||||||
void keepTag (int ID);
|
void keepTag (int ID);
|
||||||
virtual void addTag (Tag* a);
|
virtual void addTag (Tag* a);
|
||||||
|
Reference in New Issue
Block a user