当前位置: 首页>>代码示例>>C++>>正文


C++ const_iterator::toFloat方法代码示例

本文整理汇总了C++中exiv2::exifdata::const_iterator::toFloat方法的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator::toFloat方法的具体用法?C++ const_iterator::toFloat怎么用?C++ const_iterator::toFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在exiv2::exifdata::const_iterator的用法示例。


在下文中一共展示了const_iterator::toFloat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

 const double getExiv2ValueDouble(Exiv2::ExifData& exifData, Exiv2::ExifData::const_iterator it)
 {
     if(it!=exifData.end() && it->count())
     {
         return it->toFloat();
     }
     return 0;
 };
开发者ID:ndevenish,项目名称:Hugin,代码行数:8,代码来源:Exiv2Helper.cpp

示例2: readexiv

void ImageResolution::readexiv(char const *fn) {
  Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fn);
  if (!image.get())
    return;

  image->readMetadata();
  Exiv2::ExifData &exifData = image->exifData();
  if (exifData.empty())
    return;

  Exiv2::ExifData::const_iterator end = exifData.end();
  bool havex = false;
  bool havey = false;
  bool haveunit = false;
  int unit;
  for (Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i) {
    if (ok_)
      break;
    if (i->tag()==0x011a) {
      // X Resolution
      x_ = i->toFloat();
      havex = true;
    } else if (i->tag()==0x011b) {
      // Y Resolution
      y_ = i->toFloat();
      havey = true;
    } else if (i->tag()==0x0128) {
      unit = i->toLong();
    }
    ok_ = havex && havey && haveunit;
  }
  if (haveunit) {
    if (unit==3) {
      x_ *= 2.54;
      y_ *= 2.54;
    }
  }
  ok_ = havex && havey;
}
开发者ID:Spin0za,项目名称:inkscape,代码行数:39,代码来源:image-resolution.cpp

示例3: readTags

QVariantMap QgsExifTools::readTags( const QString &imagePath )
{
  std::unique_ptr< Exiv2::Image > image( Exiv2::ImageFactory::open( imagePath.toStdString() ) );
  if ( !image )
    return QVariantMap();

  image->readMetadata();
  Exiv2::ExifData &exifData = image->exifData();
  if ( exifData.empty() )
  {
    return QVariantMap();
  }

  QVariantMap res;
  Exiv2::ExifData::const_iterator end = exifData.end();
  for ( Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i )
  {
    const QString key = QString::fromStdString( i->key() );
    QVariant val;
    switch ( i->typeId() )
    {
      case Exiv2::asciiString:
      case Exiv2::string:
      case Exiv2::comment:
      case Exiv2::directory:
      case Exiv2::xmpText:
        val = QString::fromStdString( i->toString() );
        break;

      case Exiv2::unsignedLong:
      case Exiv2::signedLong:
        val = QVariant::fromValue( i->toLong() );
        break;

      case Exiv2::tiffDouble:
      case Exiv2::tiffFloat:
        val = QVariant::fromValue( i->toFloat() );
        break;

      case Exiv2::unsignedShort:
      case Exiv2::signedShort:
        val = QVariant::fromValue( static_cast< int >( i->toLong() ) );
        break;

      case Exiv2::unsignedRational:
      case Exiv2::signedRational:
      case Exiv2::unsignedByte:
      case Exiv2::signedByte:
      case Exiv2::undefined:
      case Exiv2::tiffIfd:
      case Exiv2::date:
      case Exiv2::time:
      case Exiv2::xmpAlt:
      case Exiv2::xmpBag:
      case Exiv2::xmpSeq:
      case Exiv2::langAlt:
      case Exiv2::invalidTypeId:
      case Exiv2::lastTypeId:
        val = QString::fromStdString( i->toString() );
        break;

    }

    res.insert( key, val );
  }
  return res;
}
开发者ID:AlisterH,项目名称:Quantum-GIS,代码行数:67,代码来源:qgsexiftools.cpp

示例4: from_file

void exif_data::from_file(const std::string& filename)
{
    reset();
    try
    {
        Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(filename);
        image->readMetadata();
        Exiv2::ExifData &exif_data = image->exifData();

        // if data is empty
        if (exif_data.empty()) return;

        // Exiv2 iterator in read-only
        Exiv2::ExifData::const_iterator it = exif_data.end();
        if ((it = exif_data.findKey(Exiv2::ExifKey("Exif.Photo.ExposureTime"))) != exif_data.end())
        {
            exposure_time_ = it->toFloat();
        }
        else if ((it = exif_data.findKey(Exiv2::ExifKey("Exif.Photo.ShutterSpeedValue"))) != exif_data.end())
        {
            long num = 1;
            long div = 1;
            float tmp = std::exp(std::log(2.0f) * it->toFloat());
            if (tmp > 1)
            {
                div = static_cast<long>(tmp + 0.5f);
            }
            else
            {
                num = static_cast<long>(1.0f/tmp + 0.5f);
            }
            exposure_time_ = static_cast<float>(num)/div;
        }


        if ((it = exif_data.findKey(Exiv2::ExifKey("Exif.Photo.FNumber"))) != exif_data.end())
        {
            f_number_ = it->toFloat();
        }
        else if ((it = exif_data.findKey(Exiv2::ExifKey("Exif.Photo.ApertureValue"))) != exif_data.end())
        {
            f_number_ = static_cast<float>(expf(logf(2.0f) * it->toFloat() / 2.f));
        }
        // some cameras/lens DO print the fnum but with value 0, and this is not allowed for ev computation purposes.
        if (f_number_ == 0.0f)
        {
            f_number_ = INVALID_VALUE;
        }

        //if iso is found use that value, otherwise assume a value of iso=100. (again, some cameras do not print iso in exif).
        if ((it = exif_data.findKey(Exiv2::ExifKey("Exif.Photo.ISOSpeedRatings"))) != exif_data.end())
        {
            iso_speed_ = it->toFloat();
        }

        if ((it = exif_data.findKey(Exiv2::ExifKey("Exif.Photo.ExposureBiasValue"))) != exif_data.end())
        {
            ev_compensation_ = it->toFloat();
        }
    }
    catch (Exiv2::AnyError& e)
    {
        return;
    }
}
开发者ID:LuminanceHDR,项目名称:LibHDR,代码行数:65,代码来源:exif_data.cpp


注:本文中的exiv2::exifdata::const_iterator::toFloat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。