• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ cairo_format_stride_for_width函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: render

void render() {
	draw_fill(ctx, rgba(0,0,0,127));

	int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, window->width);
	cairo_surface_t * surface = cairo_image_surface_create_for_data(ctx->buffer, CAIRO_FORMAT_ARGB32, window->width, window->height, stride);
	cairo_t * cr = cairo_create(surface);

	cairo_set_line_width (cr, 6);

	cairo_rectangle (cr, 12, 12, 232, 70);
	cairo_new_sub_path (cr); cairo_arc (cr, 64, 64, 40, 0, 2*M_PI);
	cairo_new_sub_path (cr); cairo_arc_negative (cr, 192, 64, 40, 0, -2*M_PI);

	cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
	cairo_set_source_rgb (cr, 0, 0.7, 0); cairo_fill_preserve (cr);
	cairo_set_source_rgb (cr, 0, 0, 0); cairo_stroke (cr);

	cairo_translate (cr, 0, 128);
	cairo_rectangle (cr, 12, 12, 232, 70);
	cairo_new_sub_path (cr); cairo_arc (cr, 64, 64, 40, 0, 2*M_PI);
	cairo_new_sub_path (cr); cairo_arc_negative (cr, 192, 64, 40, 0, -2*M_PI);

	cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING);
	cairo_set_source_rgb (cr, 0, 0, 0.9); cairo_fill_preserve (cr);
	cairo_set_source_rgb (cr, 0, 0, 0); cairo_stroke (cr);

	cairo_surface_flush(surface);
	cairo_destroy(cr);
	cairo_surface_flush(surface);
	cairo_surface_destroy(surface);
}
开发者ID:Atomication,项目名称:toaruos,代码行数:31,代码来源:cairo-demo.c


示例2: create_stipple

inline static cairo_pattern_t *
create_stipple (const char *color_name, guchar stipple_data[])
{
	cairo_surface_t *surface;
	cairo_pattern_t *pattern;
	GdkColor color;
	int stride;
	const int width = 8; 
	const int height = 8;

	gdk_color_parse (color_name, &color);
/*	stipple_data[2] = stipple_data[14] = color.red >> 8;
	stipple_data[1] = stipple_data[13] = color.green >> 8;
	stipple_data[0] = stipple_data[12] = color.blue >> 8;
*/
	stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, width);
	g_assert (stride>0);
	NG_DEBUG ("stride = %i", stride);
	surface = cairo_image_surface_create_for_data (stipple_data,
	                                               CAIRO_FORMAT_ARGB32,
	                                               width, height, stride);
	pattern = cairo_pattern_create_for_surface (surface);
	cairo_surface_destroy (surface);
	cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);

	return pattern;
}
开发者ID:baboofei,项目名称:oregano,代码行数:27,代码来源:rubberband.c


示例3: cairo_destroy

cairo_t* gui_screen_t::getGraphics() {

	// get buffer
	auto bufferInfo = canvas->getBuffer();
	if (bufferInfo.buffer == 0) {
		return 0;
	}

	bufferSize.width = bufferInfo.width;
	bufferSize.height = bufferInfo.height;

	// get the surface ready and go:
	if (existingSurface == 0 || existingSurfaceBuffer != bufferInfo.buffer) {
		if (existingContext != 0) {
			cairo_destroy(existingContext);
		}

		existingSurface = cairo_image_surface_create_for_data((uint8_t*) bufferInfo.buffer, CAIRO_FORMAT_ARGB32, bufferInfo.width, bufferInfo.height,
				cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, bufferInfo.width));
		existingSurfaceBuffer = bufferInfo.buffer;
		existingContext = cairo_create(existingSurface);
	}

	return existingContext;
}
开发者ID:maxdev1,项目名称:ghost,代码行数:25,代码来源:gui_screen.cpp


示例4: display_text_draw

static void
display_text_draw(struct font_freetype_text *text, struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct point *p)
{
	int i,x,y,stride;
	struct font_freetype_glyph *g, **gp;
	struct color transparent={0x0,0x0,0x0,0x0};

	gp=text->glyph;
	i=text->glyph_count;
	x=p->x << 6;
	y=p->y << 6;
	while (i-- > 0)
	{
		g=*gp++;
		if (g->w && g->h && bg ) {
			unsigned char *shadow;
			stride=cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, g->w+2);
			shadow=g_malloc(stride*(g->h+2));
			gr->freetype_methods.get_shadow(g, shadow, stride, &bg->c, &transparent);
			draw_rgb_image_buffer(gr->cairo, g->w+2, g->h+2, ((x+g->x)>>6)-1, ((y+g->y)>>6)-1, stride, shadow);
			g_free(shadow);
		}
		x+=g->dx;
		y+=g->dy;
	}
开发者ID:metalstrolch,项目名称:navit,代码行数:25,代码来源:graphics_gtk_drawing_area.c


示例5: cairo_image_surface_create_for_data

/**
 * cairo_image_surface_create_for_data:
 * @data: a pointer to a buffer supplied by the application in which
 *     to write contents. This pointer must be suitably aligned for any
 *     kind of variable, (for example, a pointer returned by malloc).
 * @format: the format of pixels in the buffer
 * @width: the width of the image to be stored in the buffer
 * @height: the height of the image to be stored in the buffer
 * @stride: the number of bytes between the start of rows in the
 *     buffer as allocated. This value should always be computed by
 *     cairo_format_stride_for_width() before allocating the data
 *     buffer.
 *
 * Creates an image surface for the provided pixel data. The output
 * buffer must be kept around until the #cairo_surface_t is destroyed
 * or cairo_surface_finish() is called on the surface.  The initial
 * contents of @data will be used as the initial image contents; you
 * must explicitly clear the buffer, using, for example,
 * cairo_rectangle() and cairo_fill() if you want it cleared.
 *
 * Note that the stride may be larger than
 * width*bytes_per_pixel to provide proper alignment for each pixel
 * and row. This alignment is required to allow high-performance rendering
 * within cairo. The correct way to obtain a legal stride value is to
 * call cairo_format_stride_for_width() with the desired format and
 * maximum image width value, and the use the resulting stride value
 * to allocate the data and to create the image surface. See
 * cairo_format_stride_for_width() for example code.
 *
 * Return value: a pointer to the newly created surface. The caller
 * owns the surface and should call cairo_surface_destroy() when done
 * with it.
 *
 * This function always returns a valid pointer, but it will return a
 * pointer to a "nil" surface in the case of an error such as out of
 * memory or an invalid stride value. In case of invalid stride value
 * the error status of the returned surface will be
 * %CAIRO_STATUS_INVALID_STRIDE.  You can use
 * cairo_surface_status() to check for this.
 *
 * See cairo_surface_set_user_data() for a means of attaching a
 * destroy-notification fallback to the surface if necessary.
 **/
cairo_surface_t *
cairo_image_surface_create_for_data (unsigned char     *data,
                                     cairo_format_t	format,
                                     int		width,
                                     int		height,
                                     int		stride)
{
    pixman_format_code_t pixman_format;
    int minstride;

    if (! CAIRO_FORMAT_VALID (format))
        return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));

    if ((stride & (CAIRO_STRIDE_ALIGNMENT-1)) != 0)
        return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_STRIDE));

    minstride = cairo_format_stride_for_width (format, width);
    if (stride < 0) {
        if (stride > -minstride) {
            return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_STRIDE));
        }
    } else {
        if (stride < minstride) {
            return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_STRIDE));
        }
    }

    pixman_format = _cairo_format_to_pixman_format_code (format);

    return _cairo_image_surface_create_with_pixman_format (data, pixman_format,
            width, height, stride);
}
开发者ID:emuikernel,项目名称:EAWebKit,代码行数:75,代码来源:cairo-image-surface.c


示例6: radeon_surface_create_internal

static cairo_surface_t *
radeon_surface_create_internal (cairo_drm_device_t *device,
				cairo_format_t format,
				int width, int height)
{
    radeon_surface_t *surface;
    cairo_status_t status;

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

    radeon_surface_init (surface, device, format, width, height);

    if (width && height) {
	surface->base.stride =
	    cairo_format_stride_for_width (surface->base.format, width);

	surface->base.bo = radeon_bo_create (to_radeon_device (&device->base),
					     surface->base.stride * height,
					     RADEON_GEM_DOMAIN_GTT);

	if (unlikely (surface->base.bo == NULL)) {
	    status = _cairo_drm_surface_finish (&surface->base);
	    free (surface);
	    return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
	}
    }

    return &surface->base.base;
}
开发者ID:1833183060,项目名称:wke,代码行数:31,代码来源:cairo-drm-radeon-surface.c


示例7: CairoGet

void CairoGet(ImageBuffer& b, Size isz, cairo_surface_t *surface, cairo_surface_t *alpha_surface)
{
	cairo_surface_flush(surface);
	byte *a = (byte *)cairo_image_surface_get_data(surface);
	int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, isz.cx);
	RGBA *t = b;
	byte *aa = NULL;
	if(alpha_surface) {
		cairo_surface_flush(alpha_surface);
		aa = (byte *)cairo_image_surface_get_data(alpha_surface);
	}
	for(int yy = 0; yy < isz.cy; yy++) {
		RGBA *s = (RGBA *)a;
		RGBA *e = s + isz.cx;
		if(aa) {
			RGBA *ss = (RGBA *)aa;
			while(s < e) {
				*t = *s++;
				(t++)->a = (ss++)->r;
			}
			aa += stride;
		}
		else
			while(s < e) {
				*t = *s++;
				(t++)->a = 255;
			}
		a += stride;
	}
}
开发者ID:dreamsxin,项目名称:ultimatepp,代码行数:30,代码来源:GtkDrawImage.cpp


示例8: draw

static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
    const cairo_test_context_t *ctx = cairo_test_get_context (cr);
    cairo_format_t format = CAIRO_FORMAT_ARGB32;
    cairo_t *cr_src;
    cairo_surface_t *png, *src;
    uint8_t *data;
    int stride;

    png = cairo_test_create_surface_from_png (ctx, png_filename);

    stride = cairo_format_stride_for_width (format, width) + 12;
    data = xcalloc (stride, height);
    src = cairo_image_surface_create_for_data (data, format,
					       width, height, stride);

    cr_src = cairo_create (src);
    cairo_set_source_surface (cr_src, png, 0, 0);
    cairo_paint (cr_src);
    cairo_destroy (cr_src);

    cairo_set_source_surface (cr, src, 0, 0);
    cairo_paint (cr);

    cairo_surface_destroy (png);

    cairo_surface_finish (src);
    cairo_surface_destroy (src);

    free (data);

    return CAIRO_TEST_SUCCESS;
}
开发者ID:AZed,项目名称:cairo,代码行数:34,代码来源:stride-12-image.c


示例9: stbi_load_from_memory

	RenderImageCairo::RenderImageCairo(void* data, size_t len)
	{
		int x, y, n;
		stbi_buffer_ = stbi_load_from_memory((const stbi_uc*)data, len, &x, &y, &n, 4);
		Color* pColorBegin = (Color*)stbi_buffer_;
		for (int i = 0; i < x*y; i++)
		{
			Color* pColor = pColorBegin + i;
			Color origin = *pColor;
			uint8 a = ColorGetA(origin);
			uint8 r = ColorGetB(origin);
			uint8 g = ColorGetG(origin);
			uint8 b = ColorGetR(origin);
			if (a < 255) {
				*pColor = ColorSetARGB(a, r*a/255, g*a/255, b*a/255);
			}
			else {
				*pColor = ColorSetARGB(a, r, g, b);
			}
		}

		size_.SetSize(x, y);

		cairo_format_t format = CAIRO_FORMAT_ARGB32;
		int stride = cairo_format_stride_for_width(format, x);
		image_surface_ = cairo_image_surface_create_for_data(stbi_buffer_, format, x, y, stride);
	}
开发者ID:staring,项目名称:DuiFramework,代码行数:27,代码来源:render_image_cairo.cpp


示例10: _cairo_boilerplate_image16_create_similar

static cairo_surface_t *
_cairo_boilerplate_image16_create_similar (cairo_surface_t *other,
					   cairo_content_t content,
					   int width, int height)
{
    cairo_format_t format;
    cairo_surface_t *surface;
    int stride;
    void *ptr;

    switch (content) {
    case CAIRO_CONTENT_ALPHA: format = CAIRO_FORMAT_A8; break;
    case CAIRO_CONTENT_COLOR: format = CAIRO_FORMAT_RGB16_565; break;
    default:
    case CAIRO_CONTENT_COLOR_ALPHA: format = CAIRO_FORMAT_ARGB32; break;
    }

    stride = cairo_format_stride_for_width(format, width);
    ptr = malloc (stride* height);

    surface = cairo_image_surface_create_for_data (ptr, format,
						   width, height, stride);
    cairo_surface_set_user_data (surface, &key, ptr, free);

    return surface;
}
开发者ID:mrobinson,项目名称:cairo,代码行数:26,代码来源:cairo-boilerplate.c


示例11: intel_surface_create

static cairo_surface_t *
intel_surface_create (cairo_drm_device_t *device,
		      cairo_format_t format,
		      int width, int height)
{
    intel_surface_t *surface;
    cairo_status_t status;

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

    intel_surface_init (surface, &intel_surface_backend, device,
			format, width, height);

    if (width && height) {
	/* Vol I, p134: size restrictions for textures */
	width  = (width  + 3) & -4;
	height = (height + 1) & -2;
	surface->drm.stride =
	    cairo_format_stride_for_width (surface->drm.format, width);
	surface->drm.bo = &intel_bo_create (to_intel_device (&device->base),
					    surface->drm.stride * height,
					    surface->drm.stride * height,
					    TRUE, I915_TILING_NONE, surface->drm.stride)->base;
	if (surface->drm.bo == NULL) {
	    status = _cairo_drm_surface_finish (&surface->drm);
	    free (surface);
	    return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
	}
    }

    return &surface->drm.base;
}
开发者ID:499940913,项目名称:moon,代码行数:34,代码来源:cairo-drm-intel-surface.c


示例12: WriteImage

    void WriteImage(
            // source image data in RGB24 format
            uint8_t *srcData, int srcWidth, int srcHeight, 
            // offset
            int offsetX, int offsetY,
            // resize
            int tgtWidth, int tgtHeight)
    {
        typedef boost::shared_ptr<cairo_surface_t> SurfacePtr;

        cairo_save(ctx_);
        cairo_translate(ctx_, offsetX, offsetY);
        cairo_scale(ctx_, 
                static_cast<double>(tgtWidth)/srcWidth, 
                static_cast<double>(tgtHeight)/srcHeight);

        {
            int stride = cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, srcWidth);
            SurfacePtr srcSurface(
                    cairo_image_surface_create_for_data(
                        srcData, CAIRO_FORMAT_RGB24, srcWidth, srcHeight, stride),
                    cairo_surface_destroy);
            cairo_set_source_surface(ctx_, srcSurface.get(), 0, 0);
        }

        cairo_paint(ctx_);
        cairo_restore(ctx_);
    }
开发者ID:yeyan,项目名称:ffmpeg-screens,代码行数:28,代码来源:ImageBuilder.hpp


示例13: size_allocate_callback

static void size_allocate_callback(GtkWidget *widget, GtkAllocation *allocation, gpointer user_data)
{
  dt_iop_module_t *self = (dt_iop_module_t *)user_data;
  dt_iop_zonesystem_gui_data_t *g = (dt_iop_zonesystem_gui_data_t *)self->gui_data;

  if(g->image) cairo_surface_destroy(g->image);
  free(g->image_buffer);

  /* load the dt logo as a brackground */
  char filename[PATH_MAX] = { 0 };
  char datadir[PATH_MAX] = { 0 };
  char *logo;
  dt_logo_season_t season = get_logo_season();
  if(season != DT_LOGO_SEASON_NONE)
    logo = g_strdup_printf("%%s/pixmaps/idbutton-%d.svg", (int)season);
  else
    logo = g_strdup("%s/pixmaps/idbutton.svg");

  dt_loc_get_datadir(datadir, sizeof(datadir));
  snprintf(filename, sizeof(filename), logo, datadir);
  g_free(logo);
  RsvgHandle *svg = rsvg_handle_new_from_file(filename, NULL);
  if(svg)
  {
    cairo_surface_t *surface;
    cairo_t *cr;

    RsvgDimensionData dimension;
    rsvg_handle_get_dimensions(svg, &dimension);

    float svg_size = MAX(dimension.width, dimension.height);
    float final_size = MIN(allocation->width, allocation->height) * 0.75;
    float factor = final_size / svg_size;
    float final_width = dimension.width * factor * darktable.gui->ppd,
          final_height = dimension.height * factor * darktable.gui->ppd;
    int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, final_width);

    g->image_buffer = (guint8 *)calloc(stride * final_height, sizeof(guint8));
    surface = dt_cairo_image_surface_create_for_data(g->image_buffer, CAIRO_FORMAT_ARGB32, final_width,
                                                     final_height, stride);
    if(cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS)
    {
      free(g->image_buffer);
      g->image_buffer = NULL;
    }
    else
    {
      cr = cairo_create(surface);
      cairo_scale(cr, factor, factor);
      rsvg_handle_render_cairo(svg, cr);
      cairo_destroy(cr);
      cairo_surface_flush(surface);
      g->image = surface;
      g->image_width = final_width / darktable.gui->ppd;
      g->image_height = final_height / darktable.gui->ppd;
    }
    g_object_unref(svg);
  }
}
开发者ID:AdamMajer,项目名称:darktable,代码行数:59,代码来源:zonesystem.c


示例14: image_setup

gint
image_setup (GimpDrawable *drawable,
             gint       interactive)
{
  /* Set the tile cache size */
  /* ======================= */

  gimp_tile_cache_ntiles ((drawable->width + gimp_tile_width() - 1) /
                          gimp_tile_width ());

  /* Get some useful info on the input drawable */
  /* ========================================== */

  input_drawable  = drawable;
  output_drawable = drawable;

  if (! gimp_drawable_mask_intersect (drawable->drawable_id, &border_x, &border_y,
                                      &border_w, &border_h))
    return FALSE;

  width  = input_drawable->width;
  height = input_drawable->height;

  gimp_pixel_rgn_init (&source_region, input_drawable,
                       0, 0, width, height, FALSE, FALSE);

  maxcounter = (glong) width * (glong) height;

  if (mapvals.transparent_background == TRUE)
    {
      gimp_rgba_set (&background, 0.0, 0.0, 0.0, 0.0);
    }
  else
    {
      gimp_context_get_background (&background);
      gimp_rgb_set_alpha (&background, 1.0);
    }

  /* Assume at least RGB */
  /* =================== */

  in_channels = 3;
  if (gimp_drawable_has_alpha (input_drawable->drawable_id) == TRUE)
    in_channels++;

  if (interactive == TRUE)
    {
      preview_rgb_stride = cairo_format_stride_for_width (CAIRO_FORMAT_RGB24,
                                                          PREVIEW_WIDTH);
      preview_rgb_data = g_new0 (guchar, preview_rgb_stride * PREVIEW_HEIGHT);
      preview_surface = cairo_image_surface_create_for_data (preview_rgb_data,
                                                             CAIRO_FORMAT_RGB24,
                                                             PREVIEW_WIDTH,
                                                             PREVIEW_HEIGHT,
                                                             preview_rgb_stride);
    }

  return TRUE;
}
开发者ID:jiapei100,项目名称:gimp,代码行数:59,代码来源:map-object-image.c


示例15: open

/* Create a cairo surface using the specified framebuffer */
cairo_surface_t *cairo_linuxfb_surface_create(cairo_linuxfb_device_t *device, const char *fb_name)
{
    cairo_surface_t *surface;

    // Open the file for reading and writing
    device->fb_fd = open(fb_name, O_RDWR);
    if (device->fb_fd == -1) {
        perror("Error: cannot open framebuffer device");
        goto handle_allocate_error;
    }

    // Get variable screen information
    if (ioctl(device->fb_fd, FBIOGET_VSCREENINFO, &device->fb_vinfo) == -1) {
        perror("Error: reading variable information");
        goto handle_ioctl_error;
    }

    /* Set virtual display size double the width for double buffering */
    device->fb_vinfo.yoffset = 0;
    device->fb_vinfo.yres_virtual = device->fb_vinfo.yres * 2;
    if (ioctl(device->fb_fd, FBIOPUT_VSCREENINFO, &device->fb_vinfo)) {
        perror("Error setting variable screen info from fb");
        goto handle_ioctl_error;
    }

    // Get fixed screen information
    if (ioctl(device->fb_fd, FBIOGET_FSCREENINFO, &device->fb_finfo) == -1) {
        perror("Error reading fixed information");
        goto handle_ioctl_error;
    }

    // Map the device to memory
    device->fb_data = (unsigned char *)mmap(0, device->fb_finfo.smem_len,
                                            PROT_READ | PROT_WRITE, MAP_SHARED,
                                            device->fb_fd, 0);
    if ((int)device->fb_data == -1) {
        perror("Error: failed to map framebuffer device to memory");
        goto handle_ioctl_error;
    }


    /* Create the cairo surface which will be used to draw to */
    surface = cairo_image_surface_create_for_data(device->fb_data,
              CAIRO_FORMAT_RGB16_565,
              device->fb_vinfo.xres,
              device->fb_vinfo.yres_virtual,
              cairo_format_stride_for_width(CAIRO_FORMAT_RGB16_565,
                                            device->fb_vinfo.xres));
    cairo_surface_set_user_data(surface, NULL, device,
                                &cairo_linuxfb_surface_destroy);

    return surface;

handle_ioctl_error:
    close(device->fb_fd);
handle_allocate_error:
    free(device);
    exit(1);
}
开发者ID:MaxKrummenacher,项目名称:cairo-fb-examples,代码行数:60,代码来源:rectangles.c


示例16: init_graphicslib

void init_graphicslib(void)
{
	int stride;
	stride=cairo_format_stride_for_width(CAIRO_FORMAT_RGB16_565, 160);
	printf("stride is %d\n", stride);
	cs=cairo_image_surface_create_for_data(cairobuff, CAIRO_FORMAT_RGB16_565, 160, 120, stride);
	c=cairo_create(cs);
}
开发者ID:JSehgal,项目名称:EE478Capstone,代码行数:8,代码来源:camimg.c


示例17: display_create_shm_surface

static cairo_surface_t *
display_create_shm_surface(struct display *display,
			   struct rectangle *rectangle)
{
	struct shm_surface_data *data;
	cairo_surface_t *surface;
	struct wl_visual *visual;
	int stride, fd;
	char filename[] = "/tmp/wayland-shm-XXXXXX";

	data = malloc(sizeof *data);
	if (data == NULL)
		return NULL;

	stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32,
						rectangle->width);
	data->length = stride * rectangle->height;
	fd = mkstemp(filename);
	if (fd < 0) {
		fprintf(stderr, "open %s failed: %m", filename);
		return NULL;
	}
	if (ftruncate(fd, data->length) < 0) {
		fprintf(stderr, "ftruncate failed: %m");
		close(fd);
		return NULL;
	}

	data->map = mmap(NULL, data->length,
			 PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
	unlink(filename);

	if (data->map == MAP_FAILED) {
		fprintf(stderr, "mmap failed: %m");
		close(fd);
		return NULL;
	}

	surface = cairo_image_surface_create_for_data (data->map,
						       CAIRO_FORMAT_ARGB32,
						       rectangle->width,
						       rectangle->height,
						       stride);

	cairo_surface_set_user_data (surface, &surface_data_key,
				     data, shm_surface_data_destroy);

	visual = wl_display_get_premultiplied_argb_visual(display->display);
	data->data.buffer = wl_shm_create_buffer(display->shm,
						 fd,
						 rectangle->width,
						 rectangle->height,
						 stride, visual);

	close(fd);

	return surface;
}
开发者ID:CLowcay,项目名称:wayland-terminal,代码行数:58,代码来源:window.c


示例18: ARGB

    virtual int ARGB(Plugin::FeatureSet features, int width,
        int height, unsigned char *bitmap, int sampleRate)
    {
      const double lower = MIN_FREQ;
      const double higher = MAX_FREQ;
      const double lower_log = log10(lower);
      const double higher_log = log10(higher);

      // set up cairo surface
      cairo_surface_t *surface;
      cairo_format_t format = CAIRO_FORMAT_ARGB32;
      int stride = cairo_format_stride_for_width(format, width);
      surface = cairo_image_surface_create_for_data (bitmap, format, width,
          height, stride);

      // set up cairo context
      cairo_t *cr;
      cr = cairo_create(surface);
      cairo_scale(cr, width, height);
      cairo_set_source_rgba(cr, BG_COLOUR);
      cairo_paint(cr);

      // find number of frames for peak/spec centroid
      unsigned int peakFrames = features[0].size();
      unsigned int scFrames = features[1].size();
      double scScale = (double)scFrames/(double)peakFrames;

      // for each peak frame, draw a colored line
      for (unsigned int peakFrame=0; peakFrame<peakFrames; peakFrame++)
      {
        // find spectral contrast, clip and scale
        double sc = features[1].at(floor(scScale*peakFrame)).values[0];
        if (sc < lower) sc=lower;
        if (sc > higher) sc=higher;
        sc = (log10(sc)-lower_log)/(higher_log-lower_log);

        // get peak values
        double peak1 = features[0].at(peakFrame).values[0];
        double peak2 = features[0].at(peakFrame).values[1];
        
        // draw waveform
        cairo_set_source_rgba(cr, red(sc), green(sc), blue(sc), 1.0);
        cairo_line_to(cr, (double)peakFrame/(double)peakFrames,
                          0.5-(peak1*0.5));
        cairo_line_to(cr, (double)peakFrame/(double)peakFrames,
                          0.5-(peak2*0.5));
        cairo_set_line_width (cr, 0.1/(double)width);
        cairo_stroke (cr);
      }

      // clean up
      cairo_destroy(cr);
      cairo_surface_destroy (surface);

      return 0;
    }
开发者ID:bbcrd,项目名称:vampeyer,代码行数:56,代码来源:FreeSound.cpp


示例19: save_file

static void		save_file(GtkWidget *widget, t_env *rt)
{
	cairo_surface_t *surface;

	surface = cairo_image_surface_create_for_data((unsigned char *)rt->tmp_data,
	CAIRO_FORMAT_ARGB32, rt->w, rt->h,
	cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, rt->w));
	cairo_surface_write_to_png(surface, gtk_entry_get_text(GTK_ENTRY(widget)));
	gtk_widget_destroy(rt->dialog);
}
开发者ID:lnieto-m,项目名称:RT,代码行数:10,代码来源:screenshot.c


示例20: m_image

ImageGStreamer::ImageGStreamer(GstBuffer*& buffer, IntSize size, cairo_format_t& cairoFormat)
    : m_image(0)
    , m_surface(0)
{
    m_surface = cairo_image_surface_create_for_data(GST_BUFFER_DATA(buffer), cairoFormat,
                                                    size.width(), size.height(),
                                                    cairo_format_stride_for_width(cairoFormat, size.width()));
    ASSERT(cairo_surface_status(m_surface) == CAIRO_STATUS_SUCCESS);
    m_image = BitmapImage::create(m_surface);
}
开发者ID:ezrec,项目名称:owb-mirror,代码行数:10,代码来源:BCImageGStreamerCairoGStreamer.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ cairo_get_current_point函数代码示例发布时间:2022-05-30
下一篇:
C++ cairo_font_options_status函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap