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


C++ Image::attribute方法代码示例

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


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

示例1: getComment

string convert::getComment( const string &image ) { 
  #ifdef HAVE_MAGICK
  Magick::Image img;
  try { 
    img.read( image );
    return img.attribute("comment");
  } catch ( Magick::Exception &ex ) { 
    cerr << " convert::getComment( " << image << " ): ERROR:" << ex.what() << endl;
    return "";
  }
  #else // ! HAVE_MAGICK
  return "";
  #endif // HAVE_MAGICK
}
开发者ID:jonathanverner,项目名称:picasafuse,代码行数:14,代码来源:convert.cpp

示例2: imageCaptured

  void TimeLapseCapture::imageCaptured(QString format, Magick::Blob blob, Magick::Geometry sizeHint) {
    bool readRawFromFile = false;

    QString framePath = output.path() + QDir::separator()
      + leadingZeros(capturedCnt, FRAME_FILE_LEADING_ZEROS) + "_" + leadingZeros(capturedSubsequence, 2);

    if (format == "RGB") {
      if (storeRawImages) {
        // store RAW RGB data in PPM format
        QString pgmHeader = QString("P6\n%1 %2\n255\n").arg(sizeHint.width()).arg(sizeHint.height());
        std::string headerStr = pgmHeader.toStdString();
        const char *headerBytes = headerStr.c_str();
        size_t headerLen = strlen(headerBytes);

        if (shutterSpdAlg != NULL && capturedSubsequence == 0) {
          Magick::Image capturedImage;
          capturedImage.read(blob, sizeHint, 8, "RGB");
          shutterSpdAlg->update(capturedImage);
        }

        framePath += ".ppm";
        QFile file(framePath);
        file.open(QIODevice::WriteOnly);
        file.write(headerBytes, headerLen);
        file.write((char*) blob.data(), blob.length());
        file.close();
      } else {
        // convert RGB data to JPEG
        Magick::Image capturedImage;
        capturedImage.read(blob, sizeHint, 8, "RGB");

        if (shutterSpdAlg != NULL && capturedSubsequence == 0) {
          shutterSpdAlg->update(capturedImage);
        }

        QDateTime now = QDateTime::currentDateTime();
        QString exifDateTime = now.toString("yyyy:MM:dd HH:mm:ss");\

        // ImageMagick don't support writing of exif data
        // TODO: setup exif timestamp correctly
        capturedImage.attribute("EXIF:DateTime", exifDateTime.toStdString());
        //capturedImage.defineValue("EXIF", "DateTime", exifDateTime.toStdString());

        capturedImage.compressType(Magick::JPEGCompression);
        capturedImage.magick("JPEG");
        framePath += ".jpeg";
        capturedImage.write(framePath.toStdString());

      }
    } else {

      if (shutterSpdAlg != NULL && capturedSubsequence == 0) {
        try {
          Magick::Image capturedImage;
          capturedImage.read(blob, format.toStdString());
          shutterSpdAlg->update(capturedImage);
        } catch (const std::exception &e) {
          err << "Failed to decode captured image (" << format << "): " << QString::fromUtf8(e.what()) << endl;
          readRawFromFile = true;
        }
      }

      // store other formats in device specific format 
      framePath += "." + format;
      QFile file(framePath);
      file.open(QIODevice::WriteOnly);
      file.write((char*) blob.data(), blob.length());
      file.close();

      if (readRawFromFile && shutterSpdAlg != NULL && capturedSubsequence == 0) {
        /* I don't understand ImageMagick correctly, but it fails with reading RAW files
         * from memory blob, but reading from file works (sometimes). 
         * Maybe, it don't support delegating (dcraw, ufraw...) with memory data...
         */
        try {
          Magick::Image capturedImage;
          capturedImage.read(framePath.toStdString());
          shutterSpdAlg->update(capturedImage);
        } catch (const std::exception &e) {
          err << "Failed to decode captured image (" << framePath << "): " << QString::fromUtf8(e.what()) << endl;
        }
      }
    }

    verboseOutput << "Captured frame saved to " << framePath << endl;

    capturedSubsequence++;
  }
开发者ID:Karry,项目名称:TimeLapse,代码行数:88,代码来源:timelapse_capture.cpp


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