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


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

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


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

示例1: Composite

void Composite(Magick::Image& canv_img, const Magick::Image& obj_img, FrameThemeObj& fto)
{
    Magick::Image img;
    Rect mdPlc = fto.Placement();
    Point sz   = mdPlc.Size();
    ZoomImage(img, obj_img, sz.x, sz.y);

    // сначала скопируем маску в изображение,
    // которое накладываем, используя опять же composite(CopyOpacityCompositeOp)
    // 1 включаем прозрачность
    img.matte(true);
    // 2 копируем прозрачность с рамки
    img.composite(VFrameImg(fto), 0, 0, MagickLib::CopyOpacityCompositeOp);

    // 3 накладываем результат c альфа-блэндингом (OverCompositeOp)
    canv_img.composite(FrameImg(fto), mdPlc.lft, mdPlc.top, MagickLib::OverCompositeOp);
    canv_img.composite(img, mdPlc.lft, mdPlc.top, MagickLib::OverCompositeOp);
}
开发者ID:cargabsj175,项目名称:bombono-dvd,代码行数:18,代码来源:mtheme.cpp

示例2: onInput

  void AdjustLuminance::onInput(InputImageInfo info, Magick::Image img) {
    std::vector<std::pair < Magick::Color, size_t>> histogram;
    Magick::colorHistogram(&histogram, img);
    Magick::Image original = img;
    /* gamma correction rules:
     * http://www.imagemagick.org/Usage/transform/#evaluate_pow
     * 
     *  updatedColor = color ^ (1 / gamma)
     *  gamma = 1 / log(color, updatedColor)
     *  gamma = 1 / (log(updatedColor) / log(color))
     * 
     * We can't compute gamma just from current and target luminance, 
     * but we can estimate it. 
     * 
     * We can compute expected luminance after gamma 
     * correction from image histogram, it is relatively fast. 
     * So we iterate gamma estimation ten times. Results are relatively good.
     */
    double gamma = 1.0;
    double targetLuminance = info.luminanceChange + info.luminance;
    double expectedLuminance = info.luminance;

    for (int iteration = 0; iteration < 10; iteration++) {

      gamma *= 1 / (
        std::log(Magick::Color::scaleQuantumToDouble(targetLuminance)) /
        std::log(Magick::Color::scaleQuantumToDouble(expectedLuminance)));

      expectedLuminance = ComputeLuminance::computeLuminance(histogram, gamma);

      *verboseOutput << QString("%1 iteration %2 changing gamma to %3 (expected luminance: %4, target %5, abs(diff) %6)")
        .arg(info.file.filePath())
        .arg(iteration)
        .arg(gamma)
        .arg(expectedLuminance)
        .arg(targetLuminance)
        .arg(std::abs(expectedLuminance - targetLuminance))
        << endl;
    }

    img.gamma(gamma);
    if (debugView) {
      original.transform(
        Magick::Geometry(original.columns(), original.rows()),
        Magick::Geometry(original.columns() / 2, original.rows())
        );
      img.composite(original, 0, 0, Magick::DissolveCompositeOp);
    }
    //img.brightnessContrast(brighnessChange, /* contrast */0.0);
    emit input(info, img);
  }
开发者ID:Karry,项目名称:TimeLapse,代码行数:51,代码来源:pipeline_deflicker.cpp

示例3: masked

// returns a masked version of given image where every pixel
// above / below a given value ( in quantum range ) gets transparent
Magick::Image masked( bool below, double value, Magick::Image img )
{
    Magick::Image mask = img;
    mask.type( Magick::GrayscaleMatteType );
    mask.normalize();
    double v = below ? value : 1-value;
    mask.threshold( v*MaxRGB );
    if( below )
        mask.negate();
    mask.type( Magick::TrueColorMatteType );
    mask.transparent( "black" );

    Magick::Image masked = img;
    masked.composite( mask, Magick::CenterGravity, Magick::CopyOpacityCompositeOp );
    return masked;
}
开发者ID:manuel-koch,项目名称:rawstack,代码行数:18,代码来源:ufrawworker.cpp

示例4: LayerToImage

/** layerToImage
  *
  * Converts a layer into an ImageMagick Image
  */
int HandlerUtils::LayerToImage(const Map& map, const Layer& layer, std::vector<Magick::Image>& tiles,
                               Magick::Image& image)
{
    for (unsigned int i = 0; i < map.GetHeight(); i++)
    {
        for (unsigned int j = 0; j < map.GetWidth(); j++)
        {
            int index = i * map.GetWidth() + j;
            int tile = layer[index];
            if (tile == -1)
                continue;
            image.composite(tiles[tile], j * map.GetTileWidth(), i * map.GetTileHeight(), Magick::AtopCompositeOp);
        }
    }

    return 0;
}
开发者ID:TricksterGuy,项目名称:TileMapEditor,代码行数:21,代码来源:HandlerUtils.cpp

示例5: operator

		void operator()(Magick::Image& img) const {
			Magick::Image old = img;
			img = Magick::Image(old.size(), "black");
			img.composite(old, 0, 0, Magick::OverCompositeOp);
			img.composite(old, 0, 0, Magick::CopyOpacityCompositeOp);
		}
开发者ID:nsimplex,项目名称:ktech,代码行数:6,代码来源:image_operations.hpp

示例6: main

int main (int argc, char *argv[])
{
  MSG_db1_data db1;
  char *format;
  char *image_overlay = 0;
  float gfactor;

  if (argc > 1)
  {
    if (!strcmp(argv[1], "-V"))
    {
      std::cout << argv[0] << " " << PACKAGE_STRING << std::endl;
      return 0;
    }
  }

  if (argc < 5)
  {
    std::cerr << "Usage: " << argv[0] << " directory channel format"
              << " scale [overlay image]" << std::endl;
    std::cerr << "Example: " << argv[0]
              << " dati IR_120 gif 0.1 SEVIRI_OVERLAY.pgm" << std::endl;
    return -1;
  }

  format = strdup(argv[3]);
  gfactor = atof(argv[4]);

  if (argc > 5)
    image_overlay = strdup(argv[5]);
  
  db1.open(argv[1]);
  if (! db1.has_channel(argv[2]))
  {
    std::cerr << "Exit: this channel is not present." << std::endl;
    return -1;
  }

  db1.set_channel(argv[2]);

  if (! db1.is_data_ok( ))
  {
    std::cerr << "Exit: Data Open Error." << std::endl;
    return -1;
  }

  char outname[PATH_MAX];
  snprintf(outname, PATH_MAX, "%s_%s_%s.%s", db1.get_INFO_satellite_name( ),
           db1.get_channel_INFO_name( ),
           db1.get_INFO_schedule_start( ), format);
  for (int i = 0; i < (int) strlen(outname); i ++)
  {
    if (outname[i] == '/') outname[i] = '-';
    if (outname[i] == ' ') outname[i] = '_';
    if (outname[i] == ':') outname[i] = '-';
  }

  Magick::Image *image = new Magick::Image(db1.get_INFO_image_pixels( ),
                                           db1.get_INFO_image_lines( ),
                                           "I", Magick::ShortPixel,
                                           db1.get_RAW_data( ));
  image->normalize( );

  if (! db1.get_INFO_schedule_northsouth( )) image->rotate(180.0);

  if (image_overlay)
  {
    Magick::Image overlay;
    overlay.read("SEVIRI_OVERLAY.pgm");
    image->composite(overlay, 0, 0, Magick::PlusCompositeOp);
  }

  Magick::Geometry geom((int) ((float) db1.get_INFO_image_pixels( )*gfactor),
                        (int) ((float) db1.get_INFO_image_lines( )*gfactor));
  image->scale(geom);

  image->write(outname);

  db1.close( );
  return 0;
}
开发者ID:ARPA-SIMC,项目名称:meteosatlib,代码行数:81,代码来源:db1_to_image.cpp

示例7: main


//.........这里部分代码省略.........
        std::cerr << "No such file(s)." << std::endl;
        return 1;
    }

    int nsegments = globbuf.gl_pathc;

    MSG_header *header;
    MSG_data *msgdat;

    header = new MSG_header[nsegments];
    msgdat = new MSG_data[nsegments];

    for (int i = 0; i < nsegments; i ++)
    {
        std::ifstream hrit(globbuf.gl_pathv[i+1],
                           (std::ios::binary | std::ios::in));
        if (hrit.fail())
        {
            std::cerr << "Cannot open input hrit file "
                      << globbuf.gl_pathv[i+1] << std::endl;
            return 1;
        }
        header[i].read_from(hrit);
        msgdat[i].read_from(hrit, header[i]);
        hrit.close( );
        std::cout << header[i];
    }

    globfree(&globbuf);

    if (header[0].segment_id->data_field_format == MSG_NO_FORMAT)
    {
        std::cout << "Product dumped in binary format." << std::endl;
        return 0;
    }

    int totalsegs = header[0].segment_id->planned_end_segment_sequence_number;
    int *segsindexes = new int[totalsegs];

    for (int i = 0; i < totalsegs; i ++)
        segsindexes[i] = -1;

    for (int i = 0; i < nsegments; i ++)
        segsindexes[header[i].segment_id->sequence_number-1] = i;

    filename = resolution;
    filename = filename + "-" + productid1 + "-" + productid2 + "-" +
               timing;
    if (format)
        filename = filename + "." + format;
    else
        filename = filename + ".jpg";

    int npix = header[0].image_structure->number_of_columns;
    int nlin = header[0].image_structure->number_of_lines;
    size_t npixperseg = npix*nlin;

    size_t total_size = totalsegs*npixperseg;
    MSG_SAMPLE *pixels = new MSG_SAMPLE[total_size];
    memset(pixels, 0, total_size*sizeof(MSG_SAMPLE));
    size_t pos = 0;
    for (int i = 0; i < totalsegs; i ++)
    {
        if (segsindexes[i] >= 0)
            memcpy(pixels+pos, msgdat[segsindexes[i]].image->data,
                   npixperseg*sizeof(MSG_SAMPLE));
        pos += npixperseg;
    }

    Magick::Image *image = new Magick::Image(npix, nlin*totalsegs,
            "I", Magick::ShortPixel, pixels);
    if (normalize) image->normalize( );
    image->rotate(180.0);
    if (header[0].segment_id->spectral_channel_id < 12)
    {
        if (do_overlay)
        {
            Magick::Image overlay;
            overlay.read(overlay_image);
            image->composite(overlay, 0, 0, Magick::PlusCompositeOp);
        }
    }

    if (geometry < 1.0)
    {
        Magick::Geometry geom((int) ((float) npix*geometry),
                              (int) ((float) nlin*totalsegs*geometry));
        image->scale(geom);
    }

    image->write(filename);

    delete image;

    delete [ ] pixels;
    delete [ ] header;
    delete [ ] msgdat;
    delete [ ] segsindexes;
    return 0;
}
开发者ID:ARPA-SIMC,项目名称:meteosatlib,代码行数:101,代码来源:XRIT2Image.cpp


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