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


C++ RefPtr::set_source方法代码示例

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


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

示例1: first_draw

	bool MainWindow::first_draw(const Cairo::RefPtr<Cairo::Context>& cr)
	{
		Gtk::Allocation allocation = m_first.get_allocation();
		cr->set_source_rgba(0, 0, 0, 1);
		cr->rectangle(0, 0, allocation.get_width(), allocation.get_height());
		cr->fill();

		if(m_png)
		{
			cr->set_source(m_png, 0, 0);
			cr->paint();
		}

		return true;
	}
开发者ID:rph-pl,项目名称:wavelet-stego,代码行数:15,代码来源:main_window.cpp

示例2: compositeLayers

//! Composited all layers into the first layer
void Renderer::compositeLayers(CairoLayer layers[]) const
{
	Cairo::RefPtr<Cairo::Context> cr = layers[0].cr;

	cr->save();

	for (int i = 1; i < LAYER_NUM; i++) {
		layers[i].surface->flush();
		cr->set_source(layers[i].surface, 0.0, 0.0);
		cr->paint();
		layers[i].clear();
	}

	cr->restore();
}
开发者ID:jorik041,项目名称:alacarte,代码行数:16,代码来源:renderer.cpp

示例3: on_expose_event

      virtual bool on_expose_event(GdkEventExpose* event) {
        Glib::RefPtr<Gdk::Window> window = get_window();

        if (!window || !m_surface)
          return true;

        Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
        cr->rectangle(event->area.x, event->area.y, event->area.width, event->area.height);
        cr->clip();

        cr->set_source(m_surface, 0, 0);
        cr->paint();

        return true;
      }
开发者ID:bjorn,项目名称:graal-gonstruct,代码行数:15,代码来源:tiles_display.hpp

示例4: on_draw

  bool on_draw(const Cairo::RefPtr<Cairo::Context>& c) {
    Gtk::Allocation allocation = get_allocation();
    const int width = allocation.get_width();
    const int height = allocation.get_height();

    RefPtr<ImageSurface> img = gm.get_surface();
    double s = get_scale();
    if (s < 1.0)
      c->scale(s,s);
    c->set_source_rgb(0, 0, 0);
    c->paint();
    c->set_source(img, 0, 0);
    c->paint();

    return true;
  }
开发者ID:jtxx000,项目名称:grainmap,代码行数:16,代码来源:graingui.cpp

示例5: drawInnerShadow

void ItemView::drawInnerShadow(const Cairo::RefPtr<Cairo::Context>& cr, const int width, const int height)
{
    cr->set_antialias(Cairo::ANTIALIAS_DEFAULT);

    const int SIZE = height * 0.1;
    const double ALPHA = 0.2;
    const int x = TIME_WIDTH - SIZE;
    const int y = 0;

    Cairo::RefPtr<Cairo::LinearGradient> linearGradient = Cairo::LinearGradient::create(x, y, x + SIZE, y);
    linearGradient->add_color_stop_rgba(0, 0.00, 0.00, 0.00, 0.0);
    linearGradient->add_color_stop_rgba(1, 0.00, 0.00, 0.00, ALPHA);

    cr->set_source(linearGradient);
    cr->rectangle(x, y, SIZE, height);
    cr->fill();
}
开发者ID:pzagawa,项目名称:myagenda,代码行数:17,代码来源:NoteItemView.cpp

示例6: on_draw

bool ImageDrawable::on_draw(const Cairo::RefPtr<Cairo::Context> &cr) {
	Gtk::Allocation allocation = get_allocation();

	//cout << "draw " << awidth << "x" << aheight << endl;

	auto surface = Cairo::ImageSurface::create(Cairo::Format::FORMAT_RGB24, allocation.get_width(), allocation.get_height());
	auto cr2 = Cairo::Context::create(surface);
	copyCairoClip(cr, cr2);
	drawImage(cr2, allocation);

	//auto start = chrono::steady_clock::now();
	cr->set_source(surface, 0, 0);
	cr->paint();
	//auto stop = chrono::steady_clock::now();
	//cout << "copy " << chrono::duration_cast<chrono::milliseconds>(stop - start).count() << "ms" << endl;

	return true;
}
开发者ID:lp0,项目名称:fiv,代码行数:18,代码来源:ImageDrawable.cpp

示例7: copy

void CairoPlugin::copy()
{
    if (m_init) {
        init();
    }

    if (m_need) {
        Cairo::RefPtr < Cairo::Context > ctx = Cairo::Context::create(m_store);

        ctx->save();
        ctx->set_source(m_img, 0.0, 0.0);
        ctx->paint();
        ctx->restore();

        m_need = false;
        m_copydone = true;
    }
}
开发者ID:alsabadel,项目名称:vle,代码行数:18,代码来源:CairoPlugin.cpp

示例8: Draw

void CardWidget::Draw(Cairo::RefPtr<Cairo::Context> cr, int x, int y)
{
	bool highlight = highlightOnHover && isMouseInArea;
	Cairo::RefPtr<Cairo::ImageSurface> image = PrefSlots::getImagesStorage().GetCardImage(card);
	cr->save();
	cr->translate(x, y);
	cr->scale(1.0 * width / image->get_width(), 1.0 * height / image->get_height());
	cr->rectangle(0, 0, image->get_width(), image->get_height());
	cr->clip();
	if( highlight ) {
		cr->save();
		cr->set_source_rgb(0.1, 0.8, 0.1);
		cr->paint();
		cr->restore();
	}
	cr->set_source(image, 0, 0);
	cr->paint_with_alpha( highlight ? 0.7 : 1.0 );
	cr->restore();
}
开发者ID:eshavlyugin,项目名称:Preferans,代码行数:19,代码来源:CardWidget.cpp

示例9: postprocess

  /** Post-process files. Only valid for PNGs. */
  void postprocess()
  {
    printf("Post-processing PNG files, resizing to %fx%f\n", maxwidth, maxheight);
    struct dirent *d;
    DIR *output_dir = opendir(outdir.c_str());
    while ((d = readdir(output_dir)) != NULL) {
      if (fnmatch("*.png", d->d_name, FNM_PATHNAME | FNM_PERIOD) == 0) {
	infile = outdir + "/" + d->d_name;
	Cairo::RefPtr<Cairo::ImageSurface> imgs = Cairo::ImageSurface::create_from_png(infile);
	if ( (imgs->get_height() != maxheight) || (imgs->get_width() != maxwidth)) {
	  // need to re-create
	  char *tmpout = strdup((outdir + "/tmpXXXXXX").c_str());
	  FILE *f = fdopen(mkstemp(tmpout), "w");
	  outfile = tmpout;
	  free(tmpout);

	  Cairo::RefPtr<Cairo::ImageSurface> outs = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32,
										(int)ceilf(maxwidth),
										(int)ceilf(maxheight));
	  double tx = (maxwidth  - imgs->get_width()) / 2.0;
	  double ty = (maxheight - imgs->get_height()) / 2.0;
	  printf("Re-creating %s for post-processing, "
		 "resizing from %ix%i, tx=%f, ty=%f\n", infile.c_str(),
		 imgs->get_width(), imgs->get_height(), tx, ty);
	  Cairo::RefPtr<Cairo::Context> cc = Cairo::Context::create(outs);
	  if (white_bg) {
	    cc->set_source_rgb(1, 1, 1);
	    cc->paint();
	  }
	  cc->set_source(imgs, tx, ty);
	  cc->paint();
	  outs->write_to_png(&SkillGuiBatchRenderer::write_func, f);
	  imgs.clear();
	  cc.clear();
	  outs.clear();
	  fclose(f);
	  rename(outfile.c_str(), infile.c_str());
	}
      }
    }
    closedir(output_dir);
  }
开发者ID:,项目名称:,代码行数:43,代码来源:

示例10:

bool level_editor::tileset_display::on_expose_event(GdkEventExpose* event) {
  Glib::RefPtr<Gdk::Window> window = get_window();

  if (!window || !m_surface)
    return true;

  Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
  cr->rectangle(event->area.x, event->area.y, event->area.width, event->area.height);
  cr->clip();

  cr->set_source(m_surface, 0, 0);
  cr->paint();

  // Show selection rectangle when we are selecting
  if (m_selecting
      || ((m_select_x != m_select_end_x || m_select_y != m_select_end_y)
          && m_preferences.sticky_tile_selection)) {
    const int x = std::min(m_select_x, m_select_end_x) * m_tile_width;
    const int y = std::min(m_select_y, m_select_end_y) * m_tile_height;

    const int w = (std::abs(m_select_x - m_select_end_x))
                    * m_tile_width;
    const int h = (std::abs(m_select_y - m_select_end_y))
                    * m_tile_height;

    cr->save();
      cr->rectangle(x, y, w, h);
      // TODO: move selection color somewhere else (preferences?)
      cr->set_source_rgb(0.7, 1, 1);
      if (m_preferences.selection_background) {
        cr->stroke_preserve();
        cr->set_source_rgba(0.7, 1, 0, 0.2);
        cr->fill();
      } else {
        cr->stroke();
      }
    cr->restore();
  }

  return true;
}
开发者ID:bjorn,项目名称:graal-gonstruct,代码行数:41,代码来源:tileset_display.cpp

示例11: DrawIcon

    void NodeSurface::DrawIcon( 
        Cairo::RefPtr<Cairo::Context> refCairo, 
        Cairo::RefPtr<Cairo::ImageSurface> refIconSurface,
        Glib::RefPtr<Gdk::Pixbuf> pixbufIcon,
        int x,
        int y )
    {
        refCairo->save();

        Cairo::RefPtr<Cairo::Context> refCairoIcon = Cairo::Context::create(refIconSurface);
        Gdk::Cairo::set_source_pixbuf( refCairoIcon, pixbufIcon, 0.0, 0.0 );
        refCairoIcon->paint();

        int width = pixbufIcon->get_width();
        int height = pixbufIcon->get_height();

        refCairo->set_source( refIconSurface, x - (width/2), y - (height/2) );
        refCairo->paint();

        refCairo->restore();
    }     
开发者ID:dougkelly88,项目名称:3rdparty,代码行数:21,代码来源:NodeSurface.cpp

示例12: icon

void NodeRenderer::icon(const Cairo::RefPtr<Cairo::Context>& cr, IconCache& cache)
{
	// path to icon not set
	if (s->icon.str().size() == 0 || s->icon_width == 0.0 || s->icon_height == 0.0)
		return;

	cr->save();

	Cairo::RefPtr<Cairo::ImageSurface> image = cache.getIcon(s->icon.str());
	double width = s->icon_width < 0 ? image->get_width() : s->icon_width;
	double height = s->icon_height < 0 ? image->get_height() : s->icon_height;
	double x0 = floor(location.x - width/2.0);
	double y0 = floor(location.y - height/2.0);
	cr->translate(x0, y0);
	cr->scale(width / image->get_width(),
			  height / image->get_height());
	cr->set_source(image, 0, 0);
	cr->paint();

	cr->restore();
}
开发者ID:DennisOSRM,项目名称:alacarte,代码行数:21,代码来源:node_renderer.cpp

示例13: on_draw

bool avatar::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
    Glib::RefPtr<Gtk::StyleContext> style = get_style_context();

    int w = get_allocated_width();
    int h = get_allocated_height();

    auto surface = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, w * get_scale_factor(), h * get_scale_factor());
    auto tmp_cr = Cairo::Context::create(surface);
    tmp_cr->scale(get_scale_factor(), get_scale_factor());

    // Render image
    Glib::RefPtr<Gdk::Pixbuf> pix = property_pixbuf();
    if (pix) {
        tmp_cr->save();
        double pw = pix->get_width();
        double ph = pix->get_height();
        tmp_cr->scale(w/pw, h/ph);
        Gdk::Cairo::set_source_pixbuf(tmp_cr, pix);
        tmp_cr->paint();
        tmp_cr->restore();
    }

    // Render the background
    tmp_cr->set_operator(Cairo::OPERATOR_DEST_ATOP);
    style->render_background(tmp_cr, 0, 0, w, h);

    // Change to default operator
    tmp_cr->set_operator(Cairo::OPERATOR_OVER);

    // Render frame
    style->render_frame(tmp_cr, 0, 0, w, h);

    // Render to the right surface
    cr->scale(1.0/get_scale_factor(), 1.0/get_scale_factor());
    cr->set_source(surface, 0, 0);
    cr->paint();

    return false;
}
开发者ID:crynale,项目名称:gTox,代码行数:39,代码来源:avatar.cpp

示例14: redrawWithoutChanges

void ImageWidget::redrawWithoutChanges(Cairo::RefPtr<Cairo::Context> cairo, unsigned width, unsigned height)
{
	if(_isInitialized) {
		cairo->set_source_rgb(1.0, 1.0, 1.0);
		cairo->set_line_width(1.0);
		cairo->rectangle(0, 0, width, height);
		cairo->fill();
		
		int
			destWidth = width - (int) floor(_leftBorderSize + _rightBorderSize),
			destHeight = height - (int) floor(_topBorderSize + _bottomBorderSize),
			sourceWidth = _imageSurface->get_width(),
			sourceHeight = _imageSurface->get_height();
		cairo->save();
		cairo->translate((int) round(_leftBorderSize), (int) round(_topBorderSize));
		cairo->scale((double) destWidth / (double) sourceWidth, (double) destHeight / (double) sourceHeight);
		Cairo::RefPtr<Cairo::SurfacePattern> pattern = Cairo::SurfacePattern::create(_imageSurface);
		pattern->set_filter(_cairoFilter);
		cairo->set_source(pattern);
		cairo->rectangle(0, 0, sourceWidth, sourceHeight);
		cairo->clip();
		cairo->paint();
		cairo->restore();
		cairo->set_source_rgb(0.0, 0.0, 0.0);
		cairo->rectangle(round(_leftBorderSize), round(_topBorderSize), destWidth, destHeight);
		cairo->stroke();

		if(_showColorScale)
			_colorScale->Draw(cairo);
		if(_showXYAxes)
		{
			_vertScale->Draw(cairo);
			_horiScale->Draw(cairo);
		}
		if(_plotTitle != 0)
			_plotTitle->Draw(cairo);
	}
}
开发者ID:pkgw,项目名称:aoflagger,代码行数:38,代码来源:imagewidget.cpp

示例15:

void
FourdThumbnailer::receive_frame(Cairo::RefPtr<Cairo::ImageSurface> img, gint64 pos)
{
  if (!m_buffer)
  {
    m_buffer = Cairo::ImageSurface::create(Cairo::FORMAT_RGB24,
                                           img->get_width() * 10,
                                           img->get_height());
  }

  Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(m_buffer);

  int slice_width = m_buffer->get_width() / m_slices;
  cr->rectangle((slice_width * m_count), 0,
                slice_width, m_buffer->get_height());
  cr->clip();

  cr->begin_new_path();
  cr->set_source(img, m_count * (m_buffer->get_width() - img->get_width()) / (m_slices-1), 0);
  cr->paint();

  m_count += 1;
}
开发者ID:Grumbel,项目名称:vidthumb,代码行数:23,代码来源:fourd_thumbnailer.cpp


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