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


C++ rsvg_handle_render_cairo函数代码示例

本文整理汇总了C++中rsvg_handle_render_cairo函数的典型用法代码示例。如果您正苦于以下问题:C++ rsvg_handle_render_cairo函数的具体用法?C++ rsvg_handle_render_cairo怎么用?C++ rsvg_handle_render_cairo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: paint_background

static void paint_background (CairoDockModuleInstance *myApplet, cairo_t* pDrawingContext)
{
    if (myData.pSvgHandles[CLOCK_DROP_SHADOW] != NULL)
        rsvg_handle_render_cairo (myData.pSvgHandles[CLOCK_DROP_SHADOW], pDrawingContext);
    if (myData.pSvgHandles[CLOCK_FACE] != NULL)
        rsvg_handle_render_cairo (myData.pSvgHandles[CLOCK_FACE], pDrawingContext);
    if (myData.pSvgHandles[CLOCK_MARKS] != NULL)
        rsvg_handle_render_cairo (myData.pSvgHandles[CLOCK_MARKS], pDrawingContext);
}
开发者ID:BackupTheBerlios,项目名称:cairo-dock-svn,代码行数:9,代码来源:applet-theme.c

示例2: paint_foreground

static void paint_foreground (CairoDockModuleInstance *myApplet, cairo_t* pDrawingContext)
{
    if (myData.pSvgHandles[CLOCK_FACE_SHADOW] != NULL)
        rsvg_handle_render_cairo (myData.pSvgHandles[CLOCK_FACE_SHADOW], pDrawingContext);
    if (myData.pSvgHandles[CLOCK_GLASS] != NULL)
        rsvg_handle_render_cairo (myData.pSvgHandles[CLOCK_GLASS], pDrawingContext);
    if (myData.pSvgHandles[CLOCK_FRAME] != NULL)
        rsvg_handle_render_cairo (myData.pSvgHandles[CLOCK_FRAME], pDrawingContext);
}
开发者ID:BackupTheBerlios,项目名称:cairo-dock-svn,代码行数:9,代码来源:applet-theme.c

示例3: paint_second

static void paint_second (CairoDockModuleInstance *myApplet, cairo_t* pDrawingContext)
{
    double fShadowOffsetX = -0.75f;
    double fShadowOffsetY = 0.75f;
    cairo_save (pDrawingContext);
    cairo_translate(pDrawingContext, fShadowOffsetX, fShadowOffsetY);
    if (myData.pSvgHandles[CLOCK_SECOND_HAND_SHADOW] != NULL)
        rsvg_handle_render_cairo (myData.pSvgHandles[CLOCK_SECOND_HAND_SHADOW], pDrawingContext);
    cairo_restore (pDrawingContext);
    if (myData.pSvgHandles[CLOCK_SECOND_HAND] != NULL)
        rsvg_handle_render_cairo (myData.pSvgHandles[CLOCK_SECOND_HAND], pDrawingContext);
}
开发者ID:BackupTheBerlios,项目名称:cairo-dock-svn,代码行数:12,代码来源:applet-theme.c

示例4: draw_map_svg

static void draw_map_svg(cairo_t * cr, guint width, guint height, guint i, guint j) {
  
  cairo_save (cr);
  cairo_translate (cr, j*70, i*70);
  rsvg_handle_render_cairo(tiles[map[i][j]], cr);
  if (map[i][j] == GREY_FLOOR) {
    cairo_translate (cr, 35/2, 35/2);
    cairo_set_source_rgba(cr, 0.7, 0.7, 0.7, 0.7);
    cairo_arc(cr, 35/2, 5+35/2, 18, 0, 2*M_PI);
    cairo_fill(cr);
    rsvg_handle_render_cairo(coin, cr);
  }
  cairo_restore (cr);
}
开发者ID:evfool,项目名称:eternal,代码行数:14,代码来源:eternal.c

示例5: graphic_render

/**
 * Renders the SVG, performing any necessary transformations.
 */
void graphic_render (Graphic* self, cairo_t* context) {
	cairo_matrix_t oldMatrix = {0};
	cairo_t* _tmp0_ = NULL;
	cairo_matrix_t _tmp1_ = {0};
	cairo_t* _tmp2_ = NULL;
	gint _tmp3_ = 0;
	gint _tmp4_ = 0;
	RsvgHandle* _tmp5_ = NULL;
	cairo_t* _tmp6_ = NULL;
	cairo_t* _tmp7_ = NULL;
	cairo_matrix_t _tmp8_ = {0};
	g_return_if_fail (self != NULL);
	g_return_if_fail (context != NULL);
	_tmp0_ = context;
	cairo_get_matrix (_tmp0_, &_tmp1_);
	oldMatrix = _tmp1_;
	_tmp2_ = context;
	_tmp3_ = self->priv->xCentre;
	_tmp4_ = self->priv->yCentre;
	cairo_translate (_tmp2_, (gdouble) (-_tmp3_), (gdouble) (-_tmp4_));
	_tmp5_ = self->priv->svgHandle;
	_tmp6_ = context;
	rsvg_handle_render_cairo (_tmp5_, _tmp6_);
	_tmp7_ = context;
	_tmp8_ = oldMatrix;
	cairo_set_matrix (_tmp7_, &_tmp8_);
}
开发者ID:MerelyAPseudonym,项目名称:SmartSim,代码行数:30,代码来源:graphic.c

示例6: draw

static void draw(GtkWidget *widget, cairo_t *cr) {
  if (rsvg == NULL) return;

  double window_width, window_height;
  window_width = widget->allocation.width;
  window_height = widget->allocation.height;

  RsvgDimensionData dimensions;
  rsvg_handle_get_dimensions(rsvg, &dimensions);
  unsigned int w, h;
  w = dimensions.width;
  h = dimensions.height;
  double aspect_ratio;
  aspect_ratio = 1.0 * w / h;

  double page_width, page_height;
  page_height = window_height - 8;
  page_width = page_height * aspect_ratio;
  if (page_width > window_width - 8) {
    page_width = window_width - 8;
    page_height = page_width / aspect_ratio;
  }
  double x = (window_width - page_width + 4.) / 2.;
  double y = (window_height - page_height + 4.) / 2.;

  cairo_rectangle(cr, x, y, page_width, page_height);
  cairo_set_source_rgb(cr, 1, 1, 1);
  cairo_fill(cr);

  cairo_translate(cr, x, y);
  cairo_scale(cr, page_width/w, page_height/h);
  rsvg_handle_render_cairo(rsvg, cr);
}
开发者ID:chinnurtb,项目名称:cassius,代码行数:33,代码来源:_svgview.c

示例7: test_render_crash

static void
test_render_crash (gconstpointer data)
{
    GFile *file = G_FILE (data);
    RsvgHandle *handle;
    GError *error = NULL;
    RsvgDimensionData dimensions;
    cairo_surface_t *surface;
    cairo_t *cr;

    handle = rsvg_handle_new_from_gfile_sync (file, RSVG_HANDLE_FLAGS_NONE, NULL, &error);
    g_assert_no_error (error);
    g_assert (handle != NULL);

    rsvg_handle_get_dimensions (handle, &dimensions);
    g_assert (dimensions.width > 0);
    g_assert (dimensions.height > 0);
    surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
					  dimensions.width, dimensions.height);
    cr = cairo_create (surface);
    g_assert (rsvg_handle_render_cairo (handle, cr));

    cairo_surface_destroy (surface);
    cairo_destroy (cr);

    g_object_unref (handle);
}
开发者ID:ImageMagick,项目名称:librsvg,代码行数:27,代码来源:render-crash.c

示例8: fill_image_buffer_from_file

static cairo_surface_t *
fill_image_buffer_from_file (cairo_t *cr, const char *filePath)
{
  GError *error = NULL;
  RsvgHandle *handle;
  cairo_surface_t *tmp_surface;
  cairo_t *tmp_cr;

  handle = rsvg_handle_new_from_file (filePath, &error);

  if (handle == NULL) {
    g_warning("rsvg_handle_new_from_file(\"%s\") failed: %s",
	      filePath, (error ? error->message : "unknown error"));
    if (error)
      g_error_free(error);
    return NULL;
  }

  tmp_surface = cairo_surface_create_similar (cairo_get_target (cr),
					      CAIRO_CONTENT_COLOR_ALPHA,
					      32, 32);
  tmp_cr = cairo_create (tmp_surface);
  rsvg_handle_render_cairo (handle, tmp_cr);
  cairo_destroy (tmp_cr);
  rsvg_handle_free (handle);
  return tmp_surface;
}
开发者ID:brion,项目名称:gnome-system-monitor,代码行数:27,代码来源:gsm_color_button.c

示例9: renderSvg

static void
renderSvg(CompScreen *s,
          SvgSource *source,
          SvgTexture *texture,
          float x1,
          float y1,
          float x2,
          float y2,
          int width,
          int height)
{
    float w = x2 - x1;
    float h = y2 - y1;

    cairo_save(texture->cr);

    cairo_set_operator(texture->cr, CAIRO_OPERATOR_SOURCE);
    cairo_set_source_rgba(texture->cr, 1.0, 1.0, 1.0, 0.0);
    cairo_paint(texture->cr);
    cairo_set_operator(texture->cr, CAIRO_OPERATOR_OVER);

    cairo_scale(texture->cr, 1.0 / w, 1.0 / h);

    cairo_scale(texture->cr,
                (double)width / source->dimension.width,
                (double)height / source->dimension.height);

    cairo_translate(texture->cr,
                    -x1 * source->dimension.width,
                    -y1 * source->dimension.height);

    rsvg_handle_render_cairo(source->svg, texture->cr);

    cairo_restore(texture->cr);
}
开发者ID:zmike,项目名称:compiz,代码行数:35,代码来源:svg.c

示例10: _rsvg_render_page

static const char *
_rsvg_render_page (const char *filename,
		   cairo_surface_t **surface_out)
{
    RsvgHandle *handle;
    RsvgDimensionData dimensions;
    GError *error = NULL;
    cairo_surface_t *surface;
    cairo_t *cr;
    cairo_status_t status;

    handle = rsvg_handle_new_from_file (filename, &error);
    if (handle == NULL)
	return error->message; /* XXX g_error_free */

    rsvg_handle_get_dimensions (handle, &dimensions);
    surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
					  dimensions.width,
					  dimensions.height);
    cr = cairo_create (surface);

    rsvg_handle_render_cairo (handle, cr);
    g_object_unref (handle);

    status = cairo_status (cr);
    cairo_destroy (cr);

    if (status) {
	cairo_surface_destroy (surface);
	return  cairo_status_to_string (status);
    }

    *surface_out = surface;
    return NULL;
}
开发者ID:Ashod,项目名称:WinCairoRequirements,代码行数:35,代码来源:any2ppm.c

示例11: gvloadimage_rsvg_cairo

static void gvloadimage_rsvg_cairo(GVJ_t * job, usershape_t *us, boxf b, boolean filled)
{
    RsvgHandle* rsvgh = gvloadimage_rsvg_load(job, us);

    cairo_t *cr = (cairo_t *) job->context; /* target context */
    cairo_surface_t *surface;	 /* source surface */

    if (rsvgh) {
        cairo_save(cr);

       	surface = cairo_svg_surface_create(NUL_FILE, us->w, us->h); 

	cairo_surface_reference(surface);

        cairo_set_source_surface(cr, surface, 0, 0);

        cairo_translate(cr, ROUND(b.LL.x), ROUND(-b.UR.y));
        cairo_scale(cr, (b.UR.x - b.LL.x) / us->w,
                       (b.UR.y - b.LL.y) / us->h);

	rsvg_handle_render_cairo(rsvgh, cr);

        cairo_paint (cr);
        cairo_restore(cr);
    }
}
开发者ID:ekoontz,项目名称:graphviz,代码行数:26,代码来源:gvloadimage_rsvg.c

示例12: QSizeF

QImage SVGCairoRSVGBackend::renderToImage(const QSize& imageSize,
                                          const QRectF& region) const
{
    const auto svgSize = QSizeF(getSize());

    const auto zoomX = 1.0 / region.width();
    const auto zoomY = 1.0 / region.height();

    const auto resX = imageSize.width() / svgSize.width();
    const auto resY = imageSize.height() / svgSize.height();

    const auto topLeft =
        QPointF{region.x() * svgSize.width(), region.y() * svgSize.height()};

    auto image = QImage{imageSize, QImage::Format_ARGB32_Premultiplied};
    image.fill(Qt::transparent);
    auto surface = CairoSurfacePtr{
        cairo_image_surface_create_for_data(image.bits(), CAIRO_FORMAT_ARGB32,
                                            image.width(), image.height(),
                                            4 * image.width())};
    auto context = CairoPtr{cairo_create(surface.get())};

    cairo_scale(context.get(), zoomX * resX, zoomY * resY);
    cairo_translate(context.get(), -topLeft.x(), -topLeft.y());

    const std::lock_guard<std::mutex> lock(_impl->renderMutex);
    rsvg_handle_render_cairo(_impl->svg.get(), context.get());

    return image;
}
开发者ID:BlueBrain,项目名称:Tide,代码行数:30,代码来源:SVGCairoRSVGBackend.cpp

示例13: svgSize

QImage SVGCairoRSVGBackend::renderToImage(const QSize& imageSize,
                                          const QRectF& region) const
{
    const QSizeF svgSize(getSize());

    const qreal zoomX = 1.0 / region.width();
    const qreal zoomY = 1.0 / region.height();

    const qreal resX = imageSize.width() / svgSize.width();
    const qreal resY = imageSize.height() / svgSize.height();

    const QPointF topLeft(region.x() * svgSize.width(),
                          region.y() * svgSize.height());

    QImage image(imageSize, QImage::Format_ARGB32);
    image.fill(Qt::white);
    CairoSurfacePtr surface(
        cairo_image_surface_create_for_data(image.bits(), CAIRO_FORMAT_ARGB32,
                                            image.width(), image.height(),
                                            4 * image.width()));
    CairoPtr context(cairo_create(surface.get()));

    cairo_scale(context.get(), zoomX * resX, zoomY * resY);
    cairo_translate(context.get(), -topLeft.x(), -topLeft.y());

    const std::lock_guard<std::mutex> lock(_impl->renderMutex);
    rsvg_handle_render_cairo(_impl->svg.get(), context.get());

    return image;
}
开发者ID:ppodhajski,项目名称:Tide,代码行数:30,代码来源:SVGCairoRSVGBackend.cpp

示例14: svg2pdf

int svg2pdf(const char *svg_filename, const char *pdf_filename) {
	RsvgHandle *svg_handle;
	RsvgDimensionData dimension_data;
	cairo_surface_t *surface;
	cairo_t *cr;
	
	rsvg_set_default_dpi(72.0);
	svg_handle = rsvg_handle_new_from_file(svg_filename, NULL);
	if(svg_handle == NULL) {
		return 0;
	}
	rsvg_handle_set_dpi(svg_handle, 72.0);
	rsvg_handle_get_dimensions(svg_handle, &dimension_data);
	surface = cairo_pdf_surface_create(pdf_filename, dimension_data.width, dimension_data.height);
	if(cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS) {
		return 0;
	}
	cr = cairo_create(surface);
	if(cairo_status(cr) != CAIRO_STATUS_SUCCESS) {
		return 0;
	}
	if(!rsvg_handle_render_cairo(svg_handle, cr)) {
		return 0;
	}
	
	cairo_show_page(cr);
	
	cairo_surface_destroy(surface);
	cairo_destroy(cr);
	g_object_unref(svg_handle);
	
	return 1;
}
开发者ID:IngoHeimbach,项目名称:CalPage,代码行数:33,代码来源:svg2pdf.c

示例15: cairo_save

void
SvgWindow::renderSvg (SvgSource  *source,
		      SvgTexture &texture,
		      CompSize   size,
		      float      x1,
		      float      y1,
		      float      x2,
		      float      y2)
{
    float w = x2 - x1;
    float h = y2 - y1;

    cairo_save (texture.cr);

    cairo_set_operator (texture.cr, CAIRO_OPERATOR_SOURCE);
    cairo_set_source_rgba (texture.cr, 1.0, 1.0, 1.0, 0.0);
    cairo_paint (texture.cr);
    cairo_set_operator (texture.cr, CAIRO_OPERATOR_OVER);

    cairo_scale (texture.cr, 1.0 / w, 1.0 / h);

    cairo_scale (texture.cr,
		 (double) size.width () / source->dimension.width,
		 (double) size.height () / source->dimension.height);

    cairo_translate (texture.cr,
		     -x1 * source->dimension.width,
		     -y1 * source->dimension.height);

    rsvg_handle_render_cairo (source->svg, texture.cr);

    cairo_restore (texture.cr);
}
开发者ID:CannedFish,项目名称:deepin-compiz,代码行数:33,代码来源:imgsvg.cpp


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