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


C++ cairo_matrix_init_scale函数代码示例

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


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

示例1: _cairo_type3_glyph_surface_create

cairo_surface_t *
_cairo_type3_glyph_surface_create (cairo_scaled_font_t	 		 *scaled_font,
				   cairo_output_stream_t 		 *stream,
				   cairo_type3_glyph_surface_emit_image_t emit_image,
				   cairo_scaled_font_subsets_t 		 *font_subsets)
{
    cairo_type3_glyph_surface_t *surface;
    cairo_matrix_t invert_y_axis;

    surface = malloc (sizeof (cairo_type3_glyph_surface_t));
    if (surface == NULL)
	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));

    _cairo_surface_init (&surface->base, &cairo_type3_glyph_surface_backend,
			 CAIRO_CONTENT_COLOR_ALPHA);

    surface->scaled_font = scaled_font;
    surface->stream = stream;
    surface->emit_image = emit_image;

    /* Setup the transform from the user-font device space to Type 3
     * font space. The Type 3 font space is defined by the FontMatrix
     * entry in the Type 3 dictionary. In the PDF backend this is an
     * identity matrix. */
    surface->cairo_to_pdf = scaled_font->scale_inverse;
    cairo_matrix_init_scale (&invert_y_axis, 1, -1);
    cairo_matrix_multiply (&surface->cairo_to_pdf, &surface->cairo_to_pdf, &invert_y_axis);

    _cairo_pdf_operators_init (&surface->pdf_operators,
			       surface->stream,
			       &surface->cairo_to_pdf,
			       font_subsets);

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

示例2: cairo_matrix_init_scale

	cairo_surface_t* Win32UIBinding::ScaleCairoSurface(
		cairo_surface_t* oldSurface, int newWidth, int newHeight)
	{
		cairo_matrix_t scaleMatrix;
		cairo_matrix_init_scale(&scaleMatrix,
			(double) cairo_image_surface_get_width(oldSurface) / (double) newWidth,
			(double) cairo_image_surface_get_height(oldSurface) / (double) newHeight);

		cairo_pattern_t* surfacePattern = cairo_pattern_create_for_surface(oldSurface);
		cairo_pattern_set_matrix(surfacePattern, &scaleMatrix);
		cairo_pattern_set_filter(surfacePattern, CAIRO_FILTER_BEST);

		cairo_surface_t* newSurface = cairo_surface_create_similar(
			oldSurface, CAIRO_CONTENT_COLOR_ALPHA, newWidth, newHeight);
		cairo_t* cr = cairo_create(newSurface);
		cairo_set_source(cr, surfacePattern);

		/* To avoid getting the edge pixels blended with 0 alpha, which would 
		 * occur with the default EXTEND_NONE. Use EXTEND_PAD for 1.2 or newer (2) */
		cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REFLECT);

		 /* Replace the destination with the source instead of overlaying */
		cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);

		/* Do the actual drawing */
		cairo_paint(cr);
		cairo_destroy(cr);

		return newSurface;
	 }
开发者ID:JamesHayton,项目名称:titanium_desktop,代码行数:30,代码来源:win32_ui_binding.cpp

示例3: redraw_command

static void
redraw_command(I7Node *self, double width, double height)
{
	I7_NODE_USE_PRIVATE;
	cairo_matrix_t matrix;
	char *path;
	
	/* Calculate the scale for the pattern gradients */
	cairo_matrix_init_scale(&matrix, 0.5 / width, 1.0 / height);
	cairo_pattern_set_matrix(priv->node_pattern[NODE_UNPLAYED_UNBLESSED], &matrix);
	cairo_pattern_set_matrix(priv->node_pattern[NODE_UNPLAYED_BLESSED], &matrix);
	cairo_pattern_set_matrix(priv->node_pattern[NODE_PLAYED_UNBLESSED], &matrix);
	cairo_pattern_set_matrix(priv->node_pattern[NODE_PLAYED_BLESSED], &matrix);

	/* Draw the text background */
	path = g_strdup_printf(
	    "M %.1f -%.1f "              /* Move-to (w/2, -h/2) */
		"a %.1f,%.1f 0 0,1 0,%.1f "  /* Arc r=(h/2, h/2) rot=0 large=0 dir=1 rel-to (0, h) */
		"h -%.1f "                   /* Horizontal-line-rel-to (-w) */
		"a %.1f,%.1f 0 0,1 0,-%.1f " /* Arc r=(h/2, h/2) rot=0 large=0 dir=1 rel-to (0, -h) */
		"Z",                         /* Close-path */
		width / 2, height / 2,
	    height / 2, height / 2, height,
	    width,
	    height / 2, height / 2, height);
	g_object_set(priv->command_shape_item, "data", path, NULL);
	g_free(path);

	priv->command_width = width;
	priv->command_height = height;
}
开发者ID:sffej,项目名称:gnome-inform7,代码行数:31,代码来源:node.c

示例4: m_font

FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, float size, bool bold, bool oblique)
    : m_font(0)
    , m_size(size)
    , m_fontFace(fontFace)
    , m_scaledFont(0)
    , m_syntheticBold(bold)
    , m_syntheticOblique(oblique)
    , m_useGDI(false)
{
   cairo_matrix_t fontMatrix;
   cairo_matrix_init_scale(&fontMatrix, size, size);
   cairo_matrix_t ctm;
   cairo_matrix_init_identity(&ctm);
   cairo_font_options_t* options = cairo_font_options_create();

   // We force antialiasing and disable hinting to provide consistent
   // typographic qualities for custom fonts on all platforms.
#if PLATFORM(APOLLO)
   // In Apollo use the anti-aliasing mode selected by the user. See bug 2404418.
   cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_DEFAULT);
#else
   cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE);
   cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_GRAY);
#endif

   m_scaledFont = cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options);
   cairo_font_options_destroy(options);
}
开发者ID:UIKit0,项目名称:WebkitAIR,代码行数:28,代码来源:FontPlatformDataCairoWin.cpp

示例5: m_font

FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, float size, bool bold, bool oblique)
    : m_font(0)
    , m_size(size)
    , m_orientation(Horizontal)
    , m_textOrientation(TextOrientationVerticalRight)
    , m_widthVariant(RegularWidth)
    , m_scaledFont(0)
    , m_isColorBitmapFont(false)
    , m_syntheticBold(bold)
    , m_syntheticOblique(oblique)
    , m_useGDI(false)
{
   cairo_matrix_t fontMatrix;
   cairo_matrix_init_scale(&fontMatrix, size, size);
   cairo_matrix_t ctm;
   cairo_matrix_init_identity(&ctm);
   cairo_font_options_t* options = cairo_font_options_create();

   // We force antialiasing and disable hinting to provide consistent
   // typographic qualities for custom fonts on all platforms.
   cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE);
   cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_GRAY);

   m_scaledFont = cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options);
   cairo_font_options_destroy(options);
}
开发者ID:0omega,项目名称:platform_external_webkit,代码行数:26,代码来源:FontPlatformDataCairoWin.cpp

示例6: redraw_label

static void
redraw_label(I7Node *self, double width, double height)
{
	I7_NODE_USE_PRIVATE;
	cairo_matrix_t matrix;
	char *path;

	/* Calculate the scale for the pattern gradient */
	cairo_matrix_init_scale(&matrix, 0.5 / width, -1.0 / height);
	cairo_pattern_set_matrix(priv->label_pattern, &matrix);
	
	path = g_strdup_printf(
	    "M %.1f,%.1f "                   /* Move-to (w/2+h, h/2) */
		"a %.1f,%.1f 0 0,0 -%.1f,-%.1f " /* Arc r=(h, h) rot=0 large=0 dir=0 rel-to (-h, -h) */
		"h -%.1f "                       /* Horizontal-line-rel-to (-w) */
		"a %.1f,%.1f 0 0,0 -%.1f,%.1f "  /* Arc r=(h, h) rot=0 large=0 dir=0 rel-to (-h, h) */
		"Z",
		width / 2 + height, height / 2,
		height, height, height, height,
		width,			                       
		height, height, height, height);
	g_object_set(priv->label_shape_item,
		"data", path,
		"visibility", GOO_CANVAS_ITEM_VISIBLE,
		NULL);
	g_free(path);

	priv->label_width = width;
	priv->label_height = height;
}
开发者ID:sffej,项目名称:gnome-inform7,代码行数:30,代码来源:node.c

示例7: m_font

FontPlatformData::FontPlatformData(GDIObject<HFONT> font, cairo_font_face_t* fontFace, float size, bool bold, bool oblique)
    : m_font(SharedGDIObject<HFONT>::create(WTFMove(font)))
    , m_size(size)
    , m_syntheticOblique(oblique)
{
    cairo_matrix_t fontMatrix;
    cairo_matrix_init_scale(&fontMatrix, size, size);
    cairo_matrix_t ctm;
    cairo_matrix_init_identity(&ctm);
    cairo_font_options_t* options = cairo_font_options_create();

    // We force antialiasing and disable hinting to provide consistent
    // typographic qualities for custom fonts on all platforms.
    cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE);
    cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_BEST);

    if (syntheticOblique()) {
        static const float syntheticObliqueSkew = -tanf(14 * acosf(0) / 90);
        cairo_matrix_t skew = {1, 0, syntheticObliqueSkew, 1, 0, 0};
        cairo_matrix_multiply(&fontMatrix, &skew, &fontMatrix);
    }

    m_scaledFont = adoptRef(cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options));
    cairo_font_options_destroy(options);
}
开发者ID:eocanha,项目名称:webkit,代码行数:25,代码来源:FontPlatformDataCairoWin.cpp

示例8: font_fc

    explicit font_fc(cairo_t* cairo, FcPattern* pattern, double offset, double dpi_x, double dpi_y) : font(cairo, offset), m_pattern(pattern) {
      cairo_matrix_t fm;
      cairo_matrix_t ctm;
      cairo_matrix_init_scale(&fm, size(dpi_x), size(dpi_y));
      cairo_get_matrix(m_cairo, &ctm);

      auto fontface = cairo_ft_font_face_create_for_pattern(m_pattern);
      auto opts = cairo_font_options_create();
      m_scaled = cairo_scaled_font_create(fontface, &fm, &ctm, opts);
      cairo_font_options_destroy(opts);
      cairo_font_face_destroy(fontface);

      auto status = cairo_scaled_font_status(m_scaled);
      if (status != CAIRO_STATUS_SUCCESS) {
        throw application_error(sstream() << "cairo_scaled_font_create(): " << cairo_status_to_string(status));
      }

      auto lock = make_unique<utils::ft_face_lock>(m_scaled);
      auto face = static_cast<FT_Face>(*lock);

      if (FT_Select_Charmap(face, FT_ENCODING_UNICODE) == FT_Err_Ok) {
        return;
      } else if (FT_Select_Charmap(face, FT_ENCODING_BIG5) == FT_Err_Ok) {
        return;
      } else if (FT_Select_Charmap(face, FT_ENCODING_SJIS) == FT_Err_Ok) {
        return;
      }

      lock.reset();
    }
开发者ID:JBouron,项目名称:polybar,代码行数:30,代码来源:font.hpp

示例9: gnm_soi_draw_cairo

static void
gnm_soi_draw_cairo (SheetObject const *so, cairo_t *cr,
		    double width, double height)
{
	GdkPixbuf *pixbuf;
	GOImage *img;
	cairo_pattern_t *cr_pattern;
	int w, h;
	cairo_matrix_t cr_matrix;

	pixbuf = soi_get_pixbuf (SHEET_OBJECT_IMAGE (so), 1.);
	if (!pixbuf || width == 0. || height == 0.)
		return;
	cairo_save (cr);
	img = go_image_new_from_pixbuf (pixbuf);
	cr_pattern = go_image_create_cairo_pattern (img);

	w = gdk_pixbuf_get_width  (pixbuf);
	h = gdk_pixbuf_get_height (pixbuf);
	cairo_matrix_init_scale (&cr_matrix,
				 w / width,
				 h / height);
	cairo_pattern_set_matrix (cr_pattern, &cr_matrix);
	cairo_rectangle (cr, 0., 0., width, height);
	cairo_set_source (cr, cr_pattern);
	cairo_fill (cr);
	/*
	 * We need to unset the source before we destroy the pattern.
	 * cairo_restore will do that.  See #632439.
	 */
	cairo_restore (cr);
	cairo_pattern_destroy (cr_pattern);
	g_object_unref (img);
	g_object_unref (pixbuf);
}
开发者ID:arcean,项目名称:gnumeric-for-maemo-5,代码行数:35,代码来源:sheet-object-image.c

示例10: locker

void wxGISDisplay::DrawRaster(cairo_surface_t *surface, const OGREnvelope& Envelope, bool bDrawEnvelope)
{
	wxCriticalSectionLocker locker(m_CritSect);

    cairo_pattern_t *pattern = cairo_pattern_create_for_surface (surface);
	cairo_matrix_t   matrix;
	cairo_matrix_init_scale (&matrix, m_dScale, -m_dScale);
	cairo_matrix_translate(&matrix, -Envelope.MinX, -Envelope.MaxY);
	cairo_pattern_set_matrix (pattern, &matrix);
	cairo_set_source (m_saLayerCaches[m_nCurrentLayer].pCairoContext, pattern);
	cairo_paint (m_saLayerCaches[m_nCurrentLayer].pCairoContext);

	if(bDrawEnvelope)
	{
        //TODO:
		//SetLineWidth( m_dLineWidth );
        //SetColor(m_FillColour);

        cairo_move_to(m_saLayerCaches[m_nCurrentLayer].pCairoContext, Envelope.MinX, Envelope.MinY);
		cairo_line_to(m_saLayerCaches[m_nCurrentLayer].pCairoContext, Envelope.MaxX, Envelope.MinY);
		cairo_line_to(m_saLayerCaches[m_nCurrentLayer].pCairoContext, Envelope.MaxX, Envelope.MaxY);
		cairo_line_to(m_saLayerCaches[m_nCurrentLayer].pCairoContext, Envelope.MinX, Envelope.MaxY);
		cairo_line_to(m_saLayerCaches[m_nCurrentLayer].pCairoContext, Envelope.MinX, Envelope.MinY);
		cairo_stroke (m_saLayerCaches[m_nCurrentLayer].pCairoContext);
	}

	cairo_pattern_destroy (pattern);
}
开发者ID:GimpoByte,项目名称:nextgismanager,代码行数:28,代码来源:gisdisplay.cpp

示例11: cairo_pattern_set_extend

bool GlyphLayerBitmap::render(
	cairo_t*       c,
	cairo_glyph_t* glyph,
	unsigned int   width,
	unsigned int   height
) {
	if(cairo_status(c) || !glyph || !_bitmap || cairo_pattern_status(_pattern)) return false;

	double bw = _bitmap->getSurfaceWidth();
	double bh = _bitmap->getSurfaceHeight();

	if(_repeatX > 1 || _repeatY > 1) cairo_pattern_set_extend(_pattern, CAIRO_EXTEND_REPEAT);
	
	else cairo_pattern_set_extend(_pattern, CAIRO_EXTEND_PAD);
	
	cairo_matrix_t matrix;

	cairo_matrix_init_scale(&matrix, bw / width * _repeatX, bh / height * _repeatY);
	cairo_pattern_set_matrix(_pattern, &matrix);

	cairo_set_source(c, _pattern);

	cairo_glyph_path(c, glyph, 1);
	cairo_fill(c);

	return true;
}
开发者ID:cubicool,项目名称:osgpango,代码行数:27,代码来源:Bitmap.cpp

示例12: draw_from_gradient

static cairo_surface_t *
draw_from_gradient (cairo_pattern_t *pattern)
{
  cairo_surface_t *surface;
  cairo_matrix_t matrix;
  cairo_t *cr;

  surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
                                        DEFAULT_SURFACE_SIZE, DEFAULT_SURFACE_SIZE);

  cr = cairo_create (surface);

  /* scale the gradient points to the user space coordinates */
  cairo_matrix_init_scale (&matrix,
                           1. / (double) DEFAULT_SURFACE_SIZE,
                           1. / (double) DEFAULT_SURFACE_SIZE);
  cairo_pattern_set_matrix (pattern, &matrix);

  cairo_arc (cr, DEFAULT_SURFACE_SIZE / 2., DEFAULT_SURFACE_SIZE / 2.,
             DEFAULT_RADIUS, 0., 2 * G_PI);

  cairo_set_source (cr, pattern);
  cairo_fill (cr);

  cairo_destroy (cr);

  return surface;
}
开发者ID:BoozzyAmdJin,项目名称:gtk-,代码行数:28,代码来源:gtknumerableicon.c

示例13: pattern_value_parse

static gboolean 
pattern_value_parse (GtkCssParser *parser,
                     GFile        *base,
                     GValue       *value)
{
  if (_gtk_css_parser_begins_with (parser, '-'))
    {
      g_value_unset (value);
      g_value_init (value, GTK_TYPE_GRADIENT);
      return gradient_value_parse (parser, base, value);
    }
  else
    {
      GError *error = NULL;
      gchar *path;
      GdkPixbuf *pixbuf;
      GFile *file;
      cairo_surface_t *surface;
      cairo_pattern_t *pattern;
      cairo_t *cr;
      cairo_matrix_t matrix;

      file = _gtk_css_parse_url (parser, base);
      if (file == NULL)
        return FALSE;

      path = g_file_get_path (file);
      g_object_unref (file);

      pixbuf = gdk_pixbuf_new_from_file (path, &error);
      g_free (path);
      if (pixbuf == NULL)
        {
          _gtk_css_parser_take_error (parser, error);
          return FALSE;
        }

      surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
                                            gdk_pixbuf_get_width (pixbuf),
                                            gdk_pixbuf_get_height (pixbuf));
      cr = cairo_create (surface);
      gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
      cairo_paint (cr);
      pattern = cairo_pattern_create_for_surface (surface);

      cairo_matrix_init_scale (&matrix,
                               gdk_pixbuf_get_width (pixbuf),
                               gdk_pixbuf_get_height (pixbuf));
      cairo_pattern_set_matrix (pattern, &matrix);

      cairo_surface_destroy (surface);
      cairo_destroy (cr);
      g_object_unref (pixbuf);

      g_value_take_boxed (value, pattern);
    }
  
  return TRUE;
}
开发者ID:nacho,项目名称:gtk-,代码行数:59,代码来源:gtkcssstringfuncs.c

示例14: _paint_page

static cairo_int_status_t
_paint_page (cairo_paginated_surface_t *surface)
{
    cairo_surface_t *analysis;
    cairo_surface_t *image;
    cairo_pattern_t *pattern;
    cairo_status_t status;

    analysis = _cairo_analysis_surface_create (surface->target,
					       surface->width, surface->height);
    if (analysis == NULL)
	return CAIRO_STATUS_NO_MEMORY;

    surface->backend->set_paginated_mode (surface->target, CAIRO_PAGINATED_MODE_ANALYZE);
    status = _cairo_meta_surface_replay (surface->meta, analysis);
    surface->backend->set_paginated_mode (surface->target, CAIRO_PAGINATED_MODE_RENDER);

    if (status || analysis->status) {
	if (status == CAIRO_STATUS_SUCCESS)
	    status = analysis->status;
	cairo_surface_destroy (analysis);
	return status;
    }

    if (_cairo_analysis_surface_has_unsupported (analysis))
    {
	double x_scale = surface->base.x_fallback_resolution / 72.0;
	double y_scale = surface->base.y_fallback_resolution / 72.0;
	cairo_matrix_t matrix;

	image = _cairo_paginated_surface_create_image_surface (surface,
							       surface->width  * x_scale,
							       surface->height * y_scale);
	_cairo_surface_set_device_scale (image, x_scale, y_scale);

	status = _cairo_meta_surface_replay (surface->meta, image);
	if (status)
	    goto CLEANUP_IMAGE;

	pattern = cairo_pattern_create_for_surface (image);
	cairo_matrix_init_scale (&matrix, x_scale, y_scale);
	cairo_pattern_set_matrix (pattern, &matrix);

	status = _cairo_surface_paint (surface->target, CAIRO_OPERATOR_SOURCE, pattern);

	cairo_pattern_destroy (pattern);

     CLEANUP_IMAGE:
	cairo_surface_destroy (image);
    }
    else
    {
	status = _cairo_meta_surface_replay (surface->meta, surface->target);
    }

    cairo_surface_destroy (analysis);

    return status;
}
开发者ID:achellies,项目名称:ISeeBrowser,代码行数:59,代码来源:cairo-paginated-surface.c

示例15: _doc_page_get_matrix

static void _doc_page_get_matrix (CtkDocPage *self,
                                  gdouble scale,
                                  gint rotation,
                                  cairo_matrix_t *ctm)
{
    cairo_matrix_init_scale (ctm, scale, scale);
    cairo_matrix_rotate (ctm, rotation * G_PI / 180.0);
}
开发者ID:tomnotcat,项目名称:clue,代码行数:8,代码来源:ctkdocpage.c


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