Page 1 of 1

Incorrect display of numerical exif parameters

Posted: Wed Nov 02, 2005 6:17 am
by Alexey Lubkin
1. Exposure time is always looks like "10/600", but should "1/60" instead (BTW, I have my own function written (in C++), which makes this job.)
2. Focal length is always looks like "50.0000". Why not just "50" ?
3. "F-Number" tag returns something like "F2.8", but should "2.8" instead.
4. The <Size> tag returns size in bytes in the way like "1189701", which is too heavy to read. The string like "1 189 701" would be much better.

Re: Incorrect display of numerical exif parameters

Posted: Wed Nov 02, 2005 12:12 pm
by xnview
Alexey Lubkin wrote:1. Exposure time is always looks like "10/600", but should "1/60" instead (BTW, I have my own function written (in C++), which makes this job.)
2. Focal length is always looks like "50.0000". Why not just "50" ?
Could you send me a sample with such fields?
3. "F-Number" tag returns something like "F2.8", but should "2.8" instead.
Ok

4. The <Size> tag returns size in bytes in the way like "1189701", which is too heavy to read. The string like "1 189 701" would be much better.
Perhaps it would be good to customize size like date??

Re: Incorrect display of numerical exif parameters

Posted: Wed Nov 02, 2005 1:07 pm
by Alexey Lubkin
xnview wrote:Could you send me a sample with such fields?
I've sent a sample by the email.
xnview wrote:Perhaps it would be good to customize size like date??
I think it's not so important. Everybody probably should accept number formatting like that: "1 234 567".

Re: Incorrect display of numerical exif parameters

Posted: Wed Nov 02, 2005 1:08 pm
by Alexey Lubkin
Alexey Lubkin wrote:1. Exposure time is always looks like "10/600", but should "1/60" instead (BTW, I have my own function written (in C++), which makes this job.)
Here is it (MathCancel() - is the function)

Code: Select all

#include <stdio.h>
#include <string>
using namespace std;

void MathCancel(int& p, int& q)
{
  int pp=p,qq=q;
  int tt = pp%qq;
  while(tt)
  {
    pp = qq;
    qq = tt;
    tt = pp%qq;
  }
  p = p / qq;
  q = q / qq;
}

string inttostr(const int x)
{
  char buf[32];
  sprintf(buf,"%d",x);
  return buf;
}
string GetString(const int p, const int q)
{
  string tmp("");
  if(q!=1) tmp = "/" + inttostr(q);
  return inttostr(p)+tmp;
}

int main()
{
  int p=10,q=600;
  printf("%d/%d = ",p,q);
  MathCancel(p,q);
  printf("%s\n",GetString(p,q).c_str());
  return 0;
}

Re: Incorrect display of numerical exif parameters

Posted: Wed Nov 02, 2005 7:51 pm
by xnview
Alexey Lubkin wrote:Here is it (MathCancel() - is the function)
Thanks

Code: Select all

string inttostr(const int x)
{
  char buf[32];
  sprintf(buf,"%d",x);
  return buf;
}
Very dangerous, must be static char buf[32];

Re: Incorrect display of numerical exif parameters

Posted: Thu Nov 03, 2005 7:42 am
by Victor Snezhko
xnview wrote:
Alexey Lubkin wrote:Here is it (MathCancel() - is the function)
Thanks

Code: Select all

string inttostr(const int x)
{
  char buf[32];
  sprintf(buf,"%d",x);
  return buf;
}
Very dangerous, must be static char buf[32];
Hmm, but the return type is std::string!
For clarity I would write "return string(buf);"

Re: Incorrect display of numerical exif parameters

Posted: Thu Nov 03, 2005 8:07 am
by xnview
Victor Snezhko wrote:
xnview wrote:
Alexey Lubkin wrote:Here is it (MathCancel() - is the function)
Thanks

Code: Select all

string inttostr(const int x)
{
  char buf[32];
  sprintf(buf,"%d",x);
  return buf;
}
Very dangerous, must be static char buf[32];
Hmm, but the return type is std::string!
For clarity I would write "return string(buf);"
Oh sorry i haven't seen string as return value :-)

Re: Incorrect display of numerical exif parameters

Posted: Thu Feb 02, 2006 8:10 pm
by Alexey Lubkin
I've just installed the 1.83 RC3 and found that
Alexey Lubkin wrote:1. Exposure time is always looks like "10/600", but should "1/60" instead (BTW, I have my own function written (in C++), which makes this job.)
3. "F-Number" tag returns something like "F2.8", but should "2.8" instead.
is now fixed. Thanks! :)
Alexey Lubkin wrote: 2. Focal length is always looks like "50.0000". Why not just "50" ?
4. The <Size> tag returns size in bytes in the way like "1189701", which is too heavy to read. The string like "1 189 701" would be much better.
And this is still not :(

Posted: Thu Feb 02, 2006 8:55 pm
by Alexey Lubkin
Here is the code for doing that

Code: Select all

#include <iostream>
#include <string>

using namespace std;

string ShowNumber(string s)
{
  int i;
  bool enough = false;
  while( !enough && (s.length()>0) && ((i=s.find_last_of("0. "))==s.length()-1) )
  {
    enough = s[i]=='.';
    s.erase(s.length()-1);
  };
  return s;
}

string FormatNumber(string s)
{
  if(s.length()==0) return string("0");
  int i, start = 1+((s.length()+2)%3), count = (s.length()-1)/3;
  for(i=0; i<count; i++)
    s.insert(4*i+start," ");
  return s;
}

int main()
{
  string number = "50.0000";
  cout << "<" << number << "> = <" << ShowNumber(number) << ">\n";

  string filesize = "1234567";
  cout << "<" << filesize << "> = <" << FormatNumber(filesize) << ">\n";

  return 0;
}
And here is the sample output

Code: Select all

<50.0000> = <50>
<1234567> = <1 234 567>