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


C++ cairo_matrix_invert函数代码示例

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


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

示例1: pattern

void cairo_context::add_image(agg::trans_affine const& tr, image_data_rgba8 & data, double opacity)
{
    cairo_pattern pattern(data);
    if (!tr.is_identity())
    {
        double m[6];
        tr.store_to(m);
        cairo_matrix_t cairo_matrix;
        cairo_matrix_init(&cairo_matrix,m[0],m[1],m[2],m[3],m[4],m[5]);
        cairo_matrix_invert(&cairo_matrix);
        pattern.set_matrix(cairo_matrix);
    }
    cairo_save(cairo_.get());
    cairo_set_source(cairo_.get(), const_cast<cairo_pattern_t*>(pattern.pattern()));
    cairo_paint_with_alpha(cairo_.get(), opacity);
    cairo_restore(cairo_.get());
    check_object_status_and_throw_exception(*this);
}
开发者ID:NavtechInc,项目名称:mapnik,代码行数:18,代码来源:cairo_context.cpp

示例2: grid_push_named_viewport

void
grid_push_named_viewport(grid_context_t *gr, 
                         const char *name, const grid_viewport_t *vp)
{
    double x = unit_to_npc(gr, 'x', vp->x);
    double y = unit_to_npc(gr, 'y', vp->y);
    double w = unit_to_npc(gr, 'x', vp->w);
    double h = unit_to_npc(gr, 'y', vp->h);

    cairo_matrix_t vp_mtx, temp_mtx;
    cairo_matrix_init(&vp_mtx, w, 0, 0, h, x, y);
    cairo_matrix_init(&temp_mtx, w, 0, 0, h, x, y);
    cairo_status_t status = cairo_matrix_invert(&temp_mtx);

    if (status == CAIRO_STATUS_SUCCESS) {
        grid_viewport_node_t *node = new_grid_viewport_node();
        cairo_matrix_multiply(node->npc_to_dev, &vp_mtx, gr->current_node->npc_to_dev);

        if (vp->has_ntv) {
            cairo_matrix_init(node->npc_to_ntv, vp->w_ntv, 0, 0, vp->h_ntv, 
                                                vp->x_ntv, vp->y_ntv);
        } else {
            // inherit native coordinates from parent
            cairo_matrix_multiply(node->npc_to_ntv, 
                                  &vp_mtx, gr->current_node->npc_to_ntv);
        }

        if (name) {
            node->name = malloc(strlen(name) + 1);
            strcpy(node->name, name);
        }

        if (gr->current_node->child) {
            gr->current_node->child->didi = node;
            node->gege = gr->current_node->child;
        }

        gr->current_node->child = node;
        node->parent = gr->current_node;
        gr->current_node = node;
    } else {
        fprintf(stderr, "Warning: can't create singular viewport\n");
    }
}
开发者ID:jotok,项目名称:griddle,代码行数:44,代码来源:griddle.c

示例3: _cairo_surface_wrapper_get_inverse_transform

static void
_cairo_surface_wrapper_get_inverse_transform (cairo_surface_wrapper_t *wrapper,
					      cairo_matrix_t *m)
{
    cairo_matrix_init_identity (m);

    if (! _cairo_matrix_is_identity (&wrapper->target->device_transform_inverse))
	cairo_matrix_multiply (m, &wrapper->target->device_transform_inverse, m);

    if (! _cairo_matrix_is_identity (&wrapper->transform)) {
	cairo_matrix_t inv;
	cairo_status_t status;

	inv = wrapper->transform;
	status = cairo_matrix_invert (&inv);
	assert (status == CAIRO_STATUS_SUCCESS);
	cairo_matrix_multiply (m, &inv, m);
    }
}
开发者ID:MiKTeX,项目名称:miktex,代码行数:19,代码来源:cairo-surface-wrapper.c

示例4: _cairo_surface_wrapper_set_inverse_transform

void
_cairo_surface_wrapper_set_inverse_transform (cairo_surface_wrapper_t *wrapper,
					      const cairo_matrix_t *transform)
{
    cairo_status_t status;

    if (transform == NULL || _cairo_matrix_is_identity (transform)) {
	cairo_matrix_init_identity (&wrapper->transform);

	wrapper->needs_transform =
	    _cairo_surface_wrapper_needs_device_transform (wrapper);
    } else {
	wrapper->transform = *transform;
	status = cairo_matrix_invert (&wrapper->transform);
	/* should always be invertible unless given pathological input */
	assert (status == CAIRO_STATUS_SUCCESS);

	wrapper->needs_transform = TRUE;
    }
}
开发者ID:igagis,项目名称:cairo,代码行数:20,代码来源:cairo-surface-wrapper.c

示例5: swfdec_text_render

static void
swfdec_text_render (SwfdecGraphic *graphic, cairo_t *cr, 
    const SwfdecColorTransform *trans)
{
  guint i;
  SwfdecColor color;
  SwfdecText *text = SWFDEC_TEXT (graphic);
  SwfdecColorTransform force_color;

  cairo_transform (cr, &text->transform);
  /* scale by bounds */
  for (i = 0; i < text->glyphs->len; i++) {
    SwfdecTextGlyph *glyph;
    SwfdecDraw *draw;
    cairo_matrix_t pos;

    glyph = &g_array_index (text->glyphs, SwfdecTextGlyph, i);

    draw = swfdec_font_get_glyph (glyph->font, glyph->glyph);
    if (draw == NULL) {
      SWFDEC_INFO ("failed getting glyph %d, maybe an empty glyph?", glyph->glyph);
      continue;
    }

    cairo_matrix_init_translate (&pos,
	glyph->x, glyph->y);
    cairo_matrix_scale (&pos, 
	(double) glyph->height / glyph->font->scale_factor,
	(double) glyph->height / glyph->font->scale_factor);
    cairo_save (cr);
    cairo_transform (cr, &pos);
    if (!cairo_matrix_invert (&pos)) {
      color = swfdec_color_apply_transform (glyph->color, trans);
      swfdec_color_transform_init_color (&force_color, color);
      swfdec_draw_paint (draw, cr, &force_color);
    } else {
      SWFDEC_ERROR ("non-invertible matrix!");
    }
    cairo_restore (cr);
  }
}
开发者ID:fengye,项目名称:swfdec,代码行数:41,代码来源:swfdec_text.c

示例6: _cairo_type3_glyph_surface_show_glyphs

static cairo_int_status_t
_cairo_type3_glyph_surface_show_glyphs (void		     *abstract_surface,
					cairo_operator_t      op,
					cairo_pattern_t	     *source,
					cairo_glyph_t        *glyphs,
					int		      num_glyphs,
					cairo_scaled_font_t  *scaled_font,
					int		     *remaining_glyphs)
{
    cairo_type3_glyph_surface_t *surface = abstract_surface;
    cairo_int_status_t status;
    cairo_scaled_font_t *font;
    cairo_matrix_t new_ctm, ctm_inverse;
    int i;

    for (i = 0; i < num_glyphs; i++)
	cairo_matrix_transform_point (&surface->cairo_to_pdf, &glyphs[i].x, &glyphs[i].y);

    /* We require the matrix to be invertable. */
    ctm_inverse = scaled_font->ctm;
    status = cairo_matrix_invert (&ctm_inverse);
    if (status)
	return CAIRO_INT_STATUS_IMAGE_FALLBACK;

    cairo_matrix_multiply (&new_ctm, &scaled_font->ctm, &ctm_inverse);
    font = cairo_scaled_font_create (scaled_font->font_face,
				     &scaled_font->font_matrix,
				     &new_ctm,
				     &scaled_font->options);

    status = _cairo_pdf_operators_show_text_glyphs (&surface->pdf_operators,
						    NULL, 0,
						    glyphs, num_glyphs,
						    NULL, 0,
						    FALSE,
						    font);

    cairo_scaled_font_destroy (font);

    return status;
}
开发者ID:jwmcglynn,项目名称:Gadgets,代码行数:41,代码来源:cairo-type3-glyph-surface.c

示例7: gnome_canvas_item_invoke_point

/* This routine invokes the point method of the item.  The argument x, y
 * should be in the parent's item-relative coordinate system.  This routine
 * applies the inverse of the item's transform, maintaining the affine
 * invariant. */
static GnomeCanvasItem *
gnome_canvas_item_invoke_point (GnomeCanvasItem *item,
                                gdouble x,
                                gdouble y,
                                gint cx,
                                gint cy)
{
	cairo_matrix_t inverse;

	/* Calculate x & y in item local coordinates */
	inverse = item->matrix;
	if (cairo_matrix_invert (&inverse) != CAIRO_STATUS_SUCCESS)
		return NULL;

	cairo_matrix_transform_point (&inverse, &x, &y);

	if (GNOME_CANVAS_ITEM_GET_CLASS (item)->point)
		return GNOME_CANVAS_ITEM_GET_CLASS (item)->point (item, x, y, cx, cy);

	return NULL;
}
开发者ID:UIKit0,项目名称:evolution,代码行数:25,代码来源:e-canvas.c

示例8: cairo_matrix_init

wxSVGRect wxSVGCanvasPathCairo::GetResultBBox(const wxCSSStyleDeclaration& style, const wxSVGMatrix* matrix) {
	if (matrix) {
		cairo_matrix_t m;
		cairo_matrix_init(&m, matrix->GetA(), matrix->GetB(), matrix->GetC(), matrix->GetD(),
				matrix->GetE(), matrix->GetF());
		cairo_matrix_invert(&m);
		cairo_set_matrix(m_cr, &m);
	}
	ApplyStrokeStyle(m_cr, style);
	double x1, y1, x2, y2;
	if (style.GetStrokeWidth() > 0)
		cairo_stroke_extents(m_cr, &x1, &y1, &x2, &y2);
	else
		cairo_fill_extents(m_cr, &x1, &y1, &x2, &y2);
	if (matrix) {
		cairo_matrix_t mat;
		cairo_matrix_init(&mat, 1, 0, 0, 1, 0, 0);
		cairo_set_matrix(m_cr, &mat);
	}
	return wxSVGRect(x1, y1, x2 - x1, y2 - y1);
}
开发者ID:jfiguinha,项目名称:Regards,代码行数:21,代码来源:SVGCanvasPathCairo.cpp

示例9: test_scaled_font_render_glyph

static cairo_status_t
test_scaled_font_render_glyph (cairo_scaled_font_t  *scaled_font,
			       unsigned long         glyph,
			       cairo_t              *cr,
			       cairo_text_extents_t *metrics)
{
    test_scaled_font_glyph_t *glyphs = cairo_font_face_get_user_data (cairo_scaled_font_get_font_face (scaled_font),
								      &test_font_face_glyphs_key);
    int i;
    unsigned char *data;
    cairo_surface_t *image;
    cairo_pattern_t *pattern;
    cairo_matrix_t matrix;
    uint8_t byte;

    /* FIXME: We simply crash on out-of-bound glyph indices */

    metrics->x_advance = (glyphs[glyph].width + 1) / 8.0;

    image = cairo_image_surface_create (CAIRO_FORMAT_A1, glyphs[glyph].width, 8);
    data = cairo_image_surface_get_data (image);
    for (i = 0; i < 8; i++) {
	byte = glyphs[glyph].data[i];
	*data = CAIRO_BITSWAP8_IF_LITTLE_ENDIAN (byte);
	data += cairo_image_surface_get_stride (image);
    }

    pattern = cairo_pattern_create_for_surface (image);
    cairo_matrix_init_identity (&matrix);
    cairo_matrix_scale (&matrix, 1.0/8.0, 1.0/8.0);
    cairo_matrix_translate (&matrix, 0, -8);
    cairo_matrix_invert (&matrix);
    cairo_pattern_set_matrix (pattern, &matrix);
    cairo_set_source (cr, pattern);
    cairo_mask (cr, pattern);
    cairo_pattern_destroy (pattern);
    cairo_surface_destroy (image);

    return CAIRO_STATUS_SUCCESS;
}
开发者ID:AliYousuf,项目名称:cairo,代码行数:40,代码来源:user-font-mask.c

示例10: platformDestroy

cairo_pattern_t* Gradient::platformGradient(float globalAlpha)
{
    if (m_gradient && m_platformGradientAlpha == globalAlpha)
        return m_gradient;

    platformDestroy();
    m_platformGradientAlpha = globalAlpha;

    if (m_radial)
        m_gradient = cairo_pattern_create_radial(m_p0.x(), m_p0.y(), m_r0, m_p1.x(), m_p1.y(), m_r1);
    else
        m_gradient = cairo_pattern_create_linear(m_p0.x(), m_p0.y(), m_p1.x(), m_p1.y());

    Vector<ColorStop>::iterator stopIterator = m_stops.begin();
    while (stopIterator != m_stops.end()) {
        cairo_pattern_add_color_stop_rgba(m_gradient, stopIterator->stop,
                                          stopIterator->red, stopIterator->green, stopIterator->blue,
                                          stopIterator->alpha * globalAlpha);
        ++stopIterator;
    }

    switch (m_spreadMethod) {
    case SpreadMethodPad:
        cairo_pattern_set_extend(m_gradient, CAIRO_EXTEND_PAD);
        break;
    case SpreadMethodReflect:
        cairo_pattern_set_extend(m_gradient, CAIRO_EXTEND_REFLECT);
        break;
    case SpreadMethodRepeat:
        cairo_pattern_set_extend(m_gradient, CAIRO_EXTEND_REPEAT);
        break;
    }

    cairo_matrix_t matrix = m_gradientSpaceTransformation;
    cairo_matrix_invert(&matrix);
    cairo_pattern_set_matrix(m_gradient, &matrix);

    return m_gradient;
}
开发者ID:CannedFish,项目名称:deepin-webkit,代码行数:39,代码来源:GradientCairo.cpp

示例11: _cairo_surface_wrapper_mask

cairo_status_t
_cairo_surface_wrapper_mask (cairo_surface_wrapper_t *wrapper,
			     cairo_operator_t	 op,
			     const cairo_pattern_t *source,
			     const cairo_pattern_t *mask,
			     const cairo_clip_t	    *clip)
{
    cairo_status_t status;
    cairo_clip_t *dev_clip;
    cairo_pattern_union_t source_copy;
    cairo_pattern_union_t mask_copy;

    if (unlikely (wrapper->target->status))
	return wrapper->target->status;

    dev_clip = _cairo_surface_wrapper_get_clip (wrapper, clip);
    if (_cairo_clip_is_all_clipped (dev_clip))
	return (cairo_status_t)CAIRO_INT_STATUS_NOTHING_TO_DO;

    if (wrapper->needs_transform) {
	cairo_matrix_t m;

	_cairo_surface_wrapper_get_transform (wrapper, &m);

	status = cairo_matrix_invert (&m);
	assert (status == CAIRO_STATUS_SUCCESS);

	_copy_transformed_pattern (&source_copy.base, source, &m);
	source = &source_copy.base;

	_copy_transformed_pattern (&mask_copy.base, mask, &m);
	mask = &mask_copy.base;
    }

    status = _cairo_surface_mask (wrapper->target, op, source, mask, dev_clip);

    _cairo_clip_destroy (dev_clip);
    return status;
}
开发者ID:igagis,项目名称:cairo,代码行数:39,代码来源:cairo-surface-wrapper.c

示例12: updateMatrix

void QCairoPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s)
{
    double w, h;
    cairo_surface_t *image;
    QImage img=pixmap.toImage().convertToFormat(QImage::Format_ARGB32);


    if (!img.isNull()) {
        cairo_format_t imgformat=CAIRO_FORMAT_ARGB32;

        updateMatrix();

        image = cairo_image_surface_create_for_data(img.bits(), imgformat, img.width(), img.height(), img.bytesPerLine());
        w = img.width();
        h = img.height();

        cairo_matrix_t cm;
        cairo_matrix_init_identity(&cm);
        cairo_matrix_translate (&cm, s.x(), s.y());
        cairo_matrix_invert(&cm);

        cairo_pattern_t* brush=cairo_pattern_create_for_surface(image);
        cairo_pattern_set_matrix(brush, &cm);
        cairo_pattern_set_extend(brush, CAIRO_EXTEND_REPEAT);

        cairo_rectangle(cr, r.x(), r.y(), r.width(), r.height());
        cairo_set_source(cr, brush);
        cairo_fill_preserve(cr);
        cairo_set_source_rgba(cr, 0,0,0,0);
        cairo_set_line_width(cr, 0.0);
        cairo_stroke(cr);
        //cairo_fill(cr);

        //cairo_set_source_surface (cr, image, 0, 0);
        //cairo_paint(cr);
        releasePattern(brush);
        updateMatrix();
    }
}
开发者ID:jkriege2,项目名称:cairoQPaintDevice,代码行数:39,代码来源:qcairopaintengine.cpp

示例13: cgDrawImage

void cgDrawImage(cairo_t *cr, int x, int y, int width, int height, cairo_surface_t *img_surface, int img_w, int img_h) {
    if (img_surface && img_w>0 && img_h>0 && width>0 && height>0) {
        cairo_save(cr);
            cairo_matrix_t cm;
            cairo_matrix_init_identity(&cm);
            cairo_matrix_translate (&cm, x, y);
            if (width!=img_w || height!=img_h) cairo_matrix_scale(&cm, float(width)/float(img_w), float(height)/float(img_h));
            cairo_matrix_invert(&cm);

            cairo_pattern_t* brush=cairo_pattern_create_for_surface(img_surface);
            cairo_pattern_set_matrix(brush, &cm);
            cairo_pattern_set_extend(brush, CAIRO_EXTEND_NONE);

            cairo_rectangle(cr, x, y, width, height);
            cairo_set_source(cr, brush);
            cairo_fill_preserve(cr);
            cairo_set_source_rgba(cr, 0,0,0,0);
            cairo_set_line_width(cr, 0.0);
            cairo_stroke(cr);
            cairo_pattern_destroy(brush);
        cairo_restore(cr);
    }
}
开发者ID:jkriege2,项目名称:rpi_webradio,代码行数:23,代码来源:cgbasics.cpp

示例14: _adg_get_map

static gboolean
_adg_get_map(GtkWidget *widget, gboolean local_space,
             cairo_matrix_t *map, cairo_matrix_t *inverted)
{
    AdgGtkAreaPrivate *data = adg_gtk_area_get_instance_private((AdgGtkArea *) widget);
    AdgEntity *entity = (AdgEntity *) data->canvas;

    if (entity == NULL)
        return FALSE;

    if (local_space) {
        adg_matrix_copy(map, adg_entity_get_local_map(entity));

        /* The inverted map is subject to the global matrix */
        adg_matrix_copy(inverted, adg_entity_get_global_matrix(entity));
        adg_matrix_transform(inverted, map, ADG_TRANSFORM_BEFORE);
    } else {
        adg_matrix_copy(map, adg_entity_get_global_map(entity));
        adg_matrix_copy(inverted, map);
    }

    return cairo_matrix_invert(inverted) == CAIRO_STATUS_SUCCESS;
}
开发者ID:ntd,项目名称:adg,代码行数:23,代码来源:adg-gtk-area.c

示例15: gimp_display_shell_rotate_update_transform

void
gimp_display_shell_rotate_update_transform (GimpDisplayShell *shell)
{
  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));

  g_free (shell->rotate_transform);
  g_free (shell->rotate_untransform);

  if (shell->rotate_angle != 0.0 && gimp_display_get_image (shell->display))
    {
      gint    image_width, image_height;
      gdouble cx, cy;

      shell->rotate_transform   = g_new (cairo_matrix_t, 1);
      shell->rotate_untransform = g_new (cairo_matrix_t, 1);

      gimp_display_shell_scale_get_image_size (shell,
                                               &image_width, &image_height);

      cx = -shell->offset_x + image_width  / 2;
      cy = -shell->offset_y + image_height / 2;

      cairo_matrix_init_translate (shell->rotate_transform, cx, cy);
      cairo_matrix_rotate (shell->rotate_transform,
                           shell->rotate_angle / 180.0 * G_PI);
      cairo_matrix_translate (shell->rotate_transform, -cx, -cy);

      *shell->rotate_untransform = *shell->rotate_transform;
      cairo_matrix_invert (shell->rotate_untransform);
    }
  else
    {
      shell->rotate_transform   = NULL;
      shell->rotate_untransform = NULL;
    }
}
开发者ID:Natella,项目名称:gimp,代码行数:36,代码来源:gimpdisplayshell-rotate.c


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