本文整理汇总了C++中cairo_surface_create_similar函数的典型用法代码示例。如果您正苦于以下问题:C++ cairo_surface_create_similar函数的具体用法?C++ cairo_surface_create_similar怎么用?C++ cairo_surface_create_similar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cairo_surface_create_similar函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: draw
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
size_t i = 0;
cairo_operator_t op;
cairo_t *bgcr, *fgcr;
cairo_surface_t *bg, *fg;
bg = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_CONTENT_COLOR_ALPHA, SIZE * STEPS, SIZE * STEPS);
fg = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_CONTENT_COLOR_ALPHA, SIZE * STEPS, SIZE * STEPS);
bgcr = cairo_create (bg);
fgcr = cairo_create (fg);
cairo_scale (bgcr, SIZE, SIZE);
cairo_scale (fgcr, SIZE, SIZE);
create_patterns (bgcr, fgcr);
cairo_destroy (bgcr);
cairo_destroy (fgcr);
for (op = START_OPERATOR; op <= STOP_OPERATOR; op++, i++) {
cairo_save (cr);
cairo_translate (cr,
SIZE * (STEPS + 1) * (i % COUNT),
SIZE * (STEPS + 1) * (i / COUNT));
do_blend (cr, op, bg, fg);
cairo_restore (cr);
}
cairo_surface_destroy (fg);
cairo_surface_destroy (bg);
return CAIRO_TEST_SUCCESS;
}
开发者ID:JamalAbuDayyeh,项目名称:pdf4ax,代码行数:34,代码来源:extended-blend.c
示例2: subdraw
static void
subdraw (cairo_t *cr, int width, int height)
{
size_t i = 0;
cairo_operator_t op;
cairo_t *bgcr, *fgcr;
cairo_surface_t *bg, *fg;
bg = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_CONTENT_COLOR_ALPHA, SIZE * STEPS, SIZE * STEPS);
fg = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_CONTENT_COLOR_ALPHA, SIZE * STEPS, SIZE * STEPS);
bgcr = cairo_create (bg);
fgcr = cairo_create (fg);
cairo_scale (bgcr, SIZE, SIZE);
cairo_scale (fgcr, SIZE, SIZE);
create_patterns (bgcr, fgcr);
cairo_destroy (bgcr);
cairo_destroy (fgcr);
for (op = START_OPERATOR; op <= STOP_OPERATOR; op++, i++) {
cairo_save (cr);
cairo_translate (cr,
SIZE * (STEPS + 1) * (i % COUNT),
SIZE * (STEPS + 1) * (i / COUNT));
cairo_rectangle (cr, 0, 0, SIZE * (STEPS + 1), SIZE * (STEPS+1));
cairo_clip (cr);
do_composite (cr, op, bg, fg);
cairo_restore (cr);
}
cairo_surface_destroy (fg);
cairo_surface_destroy (bg);
}
开发者ID:ghub,项目名称:NVprSDK,代码行数:34,代码来源:operator-alpha-alpha.c
示例3: paint_window
static void paint_window(GtkWidget* widget, WindowData* windata)
{
cairo_t* context;
cairo_surface_t* surface;
cairo_t* cr;
if (windata->width == 0 || windata->height == 0)
{
#if GTK_CHECK_VERSION(3, 0, 0)
GtkAllocation allocation;
gtk_widget_get_allocation(windata->win, &allocation);
windata->width = MAX(allocation.width, 1);
windata->height = MAX(allocation.height, 1);
#else
windata->width = MAX(windata->win->allocation.width, 1);
windata->height = MAX(windata->win->allocation.height, 1);
#endif
}
context = gdk_cairo_create(widget->window);
cairo_set_operator(context, CAIRO_OPERATOR_SOURCE);
#if GTK_CHECK_VERSION(3, 0, 0)
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
surface = cairo_surface_create_similar(cairo_get_target(context), CAIRO_CONTENT_COLOR_ALPHA, allocation.width, allocation.height);
#else
surface = cairo_surface_create_similar(cairo_get_target(context), CAIRO_CONTENT_COLOR_ALPHA, widget->allocation.width, widget->allocation.height);
#endif
cr = cairo_create(surface);
fill_background(widget, windata, cr);
cairo_destroy(cr);
cairo_set_source_surface(context, surface, 0, 0);
cairo_paint(context);
cairo_surface_destroy(surface);
cairo_destroy(context);
update_shape(windata);
}
开发者ID:TheCoffeMaker,项目名称:Mate-Desktop-Environment,代码行数:51,代码来源:theme.c
示例4: _similar_surface_create
static cairo_surface_t *
_similar_surface_create (void *closure,
cairo_content_t content,
double width,
double height,
long uid)
{
cairo_surface_t *surface;
struct scache skey, *s;
if (uid == 0 || surface_cache == NULL)
return cairo_surface_create_similar (closure, content, width, height);
skey.entry.hash = uid;
s = _cairo_hash_table_lookup (surface_cache, &skey.entry);
if (s != NULL) {
if (s->content == content &&
s->width == width &&
s->height == height)
{
return cairo_surface_reference (s->surface);
}
/* The surface has been resized, allow the original entry to expire
* as it becomes inactive.
*/
}
surface = cairo_surface_create_similar (closure, content, width, height);
s = malloc (sizeof (struct scache));
if (s == NULL)
return surface;
s->entry.hash = uid;
s->content = content;
s->width = width;
s->height = height;
s->surface = surface;
if (_cairo_hash_table_insert (surface_cache, &s->entry)) {
free (s);
} else if (cairo_surface_set_user_data
(surface,
(const cairo_user_data_key_t *) &surface_cache,
s, scache_remove))
{
scache_remove (s);
}
return surface;
}
开发者ID:CliffsDover,项目名称:wesnoth_ios,代码行数:50,代码来源:cairo-perf-trace.c
示例5: void
/* cache buttons as small surfaces */
static cairo_surface_t *cache_button(Gameboard *g,
void (*draw)(cairo_t *c,
double x,
double y),
double pR,double pG,double pB,double pA,
double fR,double fG,double fB,double fA){
cairo_t *wc = gdk_cairo_create(g->w.window);
cairo_surface_t *ret =
cairo_surface_create_similar (cairo_get_target (wc),
CAIRO_CONTENT_COLOR_ALPHA,
BUTTON_RADIUS*2+1,
BUTTON_RADIUS*2+1);
cairo_t *c = cairo_create(ret);
cairo_destroy (wc);
cairo_save(c);
cairo_set_operator(c,CAIRO_OPERATOR_CLEAR);
cairo_set_source_rgba (c, 1,1,1,1);
cairo_paint(c);
cairo_restore(c);
cairo_set_source_rgba(c,fR,fG,fB,fA);
cairo_set_line_width(c,BUTTON_LINE_WIDTH);
draw(c,BUTTON_RADIUS+.5,BUTTON_RADIUS+.5);
cairo_set_source_rgba(c,pR,pG,pB,pA);
cairo_stroke(c);
cairo_destroy(c);
return ret;
}
开发者ID:kazutomi,项目名称:xiphqt,代码行数:32,代码来源:gameboard_logic_button.c
示例6: cairo_image_surface_get_width
/* Scale the surface with the width and height requested */
cairo_surface_t *
scale_surface (cairo_surface_t *surface,
gdouble width,
gdouble height)
{
gdouble old_width = cairo_image_surface_get_width (surface);
gdouble old_height = cairo_image_surface_get_height (surface);
cairo_surface_t *new_surface = cairo_surface_create_similar(surface, CAIRO_CONTENT_COLOR_ALPHA, width, height);
cairo_t *cr = cairo_create (new_surface);
/* Scale *before* setting the source surface (1) */
cairo_scale (cr, width / old_width, height / old_height);
cairo_set_source_surface (cr, surface, 0, 0);
/* 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 new_surface;
}
开发者ID:vulpineblaze,项目名称:cpe190_csus_f14,代码行数:31,代码来源:utils.c
示例7: resize_window
/**
* windows resize funtion
*/
static gboolean
resize_window (GtkWidget *widget,
GdkEventMotion *mev)
{
int w,h;
if(isFullSreen)
gdk_window_get_size(widget->window,&w,&h);
else {
w = DEFAULT_WIDTH;
h = DEFAULT_HEIGHT;
}
if(w!=window_w && h!=window_h){
window_w = w;
window_h = h;
surface = cairo_surface_create_similar (
surface,
CAIRO_CONTENT_COLOR_ALPHA,
w, h);
gtk_widget_set_size_request(widget,w,h);
CleanPaint();
}
/* tell the canvas widget that it needs to redraw itself */
gtk_widget_queue_draw (widget);
return FALSE;
}
开发者ID:Varhoo,项目名称:Fingerpaint,代码行数:32,代码来源:main.cpp
示例8: configure_cb
static gboolean configure_cb (GtkWidget *widget,
GdkEventConfigure *evt, gpointer user_data) {
canvasbacken_data_t *data = user_data;
assert (data);
int w = gtk_widget_get_allocated_width (widget);
int h = gtk_widget_get_allocated_height (widget);
if (data->track)
cairo_surface_destroy (data->track);
data->track = gdk_window_create_similar_surface (
gtk_widget_get_window (widget),
CAIRO_CONTENT_COLOR_ALPHA,
w, h);
clear_surface (data->track);
if (data->surf)
cairo_surface_destroy (data->surf);
data->surf = cairo_surface_create_similar (
data->track,
CAIRO_CONTENT_COLOR_ALPHA,
w, h);
clear_surface (data->surf);
canvas_draw (data);
gtk_widget_queue_draw (widget);
return TRUE;
}
开发者ID:firejox,项目名称:automobile,代码行数:31,代码来源:canvas.c
示例9: draw_mask
static void
draw_mask (cairo_t *cr, int x, int y)
{
cairo_surface_t *mask_surface;
cairo_t *cr2;
double width = (int)(0.9 * WIDTH);
double height = (int)(0.9 * HEIGHT);
x += 0.05 * WIDTH;
y += 0.05 * HEIGHT;
mask_surface = cairo_surface_create_similar (cairo_get_group_target (cr),
CAIRO_CONTENT_ALPHA,
width, height);
cr2 = cairo_create (mask_surface);
cairo_surface_destroy (mask_surface);
cairo_save (cr2);
cairo_set_source_rgba (cr2, 0, 0, 0, 0); /* transparent */
cairo_set_operator (cr2, CAIRO_OPERATOR_SOURCE);
cairo_paint (cr2);
cairo_restore (cr2);
cairo_set_source_rgb (cr2, 1, 1, 1); /* white */
cairo_arc (cr2, 0.5 * width, 0.5 * height, 0.45 * height, 0, 2 * M_PI);
cairo_fill (cr2);
cairo_mask_surface (cr, cairo_get_target (cr2), x, y);
cairo_destroy (cr2);
}
开发者ID:3oyka,项目名称:cairo2,代码行数:31,代码来源:unbounded-operator.c
示例10: ink_cairo_surface_create_same_size
cairo_surface_t *
ink_cairo_surface_create_same_size(cairo_surface_t *s, cairo_content_t c)
{
cairo_surface_t *ns = cairo_surface_create_similar(s, c,
ink_cairo_surface_get_width(s), ink_cairo_surface_get_height(s));
return ns;
}
开发者ID:Spin0za,项目名称:inkscape,代码行数:7,代码来源:cairo-utils.cpp
示例11: seed_cairo_surface_create_similar
static SeedValue
seed_cairo_surface_create_similar (SeedContext ctx,
SeedObject function,
SeedObject this_object,
gsize argument_count,
const SeedValue arguments[],
SeedException *exception)
{
gint width, height;
cairo_surface_t *surface, *ret;
cairo_content_t content;
CHECK_THIS();
if (argument_count != 3)
{
EXPECTED_EXCEPTION("create_similar", "3 arguments");
}
surface = seed_object_to_cairo_surface (ctx, this_object, exception);
if (!surface)
return seed_make_undefined (ctx);
content = seed_value_to_long (ctx, arguments[0], exception);
width = seed_value_to_int (ctx, arguments[1], exception);
height = seed_value_to_int (ctx, arguments[2], exception);
ret = cairo_surface_create_similar (surface, content, width, height);
return seed_object_from_cairo_surface (ctx, ret);
}
开发者ID:iRi-E,项目名称:GNOME-Seed,代码行数:27,代码来源:seed-cairo-surface.c
示例12: scale_icon
static inline cairo_surface_t *
scale_icon (cairo_surface_t *icon,
double width,
double height)
{
cairo_surface_t *scaled_icon;
cairo_t *cr;
scaled_icon = cairo_surface_create_similar (icon,
cairo_surface_get_content (icon),
THUMBNAIL_WIDTH,
THUMBNAIL_HEIGHT);
cr = cairo_create (scaled_icon);
cairo_scale (cr,
THUMBNAIL_WIDTH / width,
THUMBNAIL_HEIGHT / height);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_set_source_surface (cr,
icon,
0.0,
0.0);
cairo_paint (cr);
cairo_destroy (cr);
return scaled_icon;
}
开发者ID:community-ssu,项目名称:hildon-home,代码行数:30,代码来源:hd-bookmark-shortcut.c
示例13: exit
mWindow::mWindow() {
looping = false;
if (!(display = XOpenDisplay(NULL)))
exit(1);
screenID = DefaultScreen(display);
topWin = XCreateSimpleWindow(display, DefaultRootWindow(display), 0, 0,
winWidth, winHeight, 0, 100, 0xfffacd);
XSelectInput(display, topWin,
ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask
| PointerMotionMask | StructureNotifyMask | ExposureMask);
frontSurface = cairo_xlib_surface_create(display, topWin,
DefaultVisual(display, screenID), winWidth, winHeight);
frontContext = cairo_create(frontSurface);
GUI_surface = cairo_surface_create_similar(cairo_get_target(frontContext),
CAIRO_CONTENT_COLOR_ALPHA, winWidth, winHeight);
// MAP_surface = cairo_surface_create_similar(cairo_get_target(frontContext),
// CAIRO_CONTENT_COLOR_ALPHA, winWidth, winHeight);
GUI_context = cairo_create(GUI_surface);
//MAP_context = cairo_create(MAP_surface);
Gmanager = new GUIManager(GUI_context);
eventDispatcher = new EventDispatcher(winWidth, winHeight);
Gmanager->registerEventDispatcher(eventDispatcher,
eventDispatcher->getGUImap());
eventDispatcher->registerGUImanager(Gmanager);
animator = new Animator();
Animatable::animator = animator;
}
开发者ID:feiyuren233,项目名称:NotSoEasyGL,代码行数:34,代码来源:notSoEasyGL.cpp
示例14: set_surface_pattern
static void
set_surface_pattern (cairo_t *cr, int x, int y)
{
cairo_surface_t *source_surface;
cairo_t *cr2;
double width = (int)(0.6 * WIDTH);
double height = (int)(0.6 * HEIGHT);
x += 0.2 * WIDTH;
y += 0.2 * HEIGHT;
source_surface = cairo_surface_create_similar (cairo_get_group_target (cr),
CAIRO_CONTENT_COLOR_ALPHA,
width, height);
cr2 = cairo_create (source_surface);
cairo_surface_destroy (source_surface);
cairo_set_source_rgb (cr2, 1, 0, 0); /* red */
cairo_paint (cr2);
cairo_set_source_rgb (cr2, 1, 1, 1); /* white */
cairo_arc (cr2, 0.5 * width, 0.5 * height, 0.5 * height, 0, 2 * M_PI);
cairo_fill (cr2);
cairo_set_source_surface (cr, cairo_get_target (cr2), x, y);
cairo_destroy (cr2);
}
开发者ID:jaglass,项目名称:WinCairoRequirements,代码行数:28,代码来源:operator-source.c
示例15: _gtk_css_image_get_surface
cairo_surface_t *
_gtk_css_image_get_surface (GtkCssImage *image,
cairo_surface_t *target,
int surface_width,
int surface_height)
{
cairo_surface_t *result;
cairo_t *cr;
g_return_val_if_fail (GTK_IS_CSS_IMAGE (image), NULL);
g_return_val_if_fail (surface_width > 0, NULL);
g_return_val_if_fail (surface_height > 0, NULL);
if (target)
result = cairo_surface_create_similar (target,
CAIRO_CONTENT_COLOR_ALPHA,
surface_width,
surface_height);
else
result = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
surface_width,
surface_height);
cr = cairo_create (result);
_gtk_css_image_draw (image, cr, surface_width, surface_height);
cairo_destroy (cr);
return result;
}
开发者ID:endlessm,项目名称:gtk,代码行数:29,代码来源:gtkcssimage.c
示例16: draw
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
cairo_surface_t *surface, *target;
cairo_t *cr2;
/* First draw a shape in blue on the original destination. */
cairo_set_source_rgb (cr, 0, 0, 1); /* blue */
draw_square (cr);
/* Then, create an offset surface and repeat the drawing in red. */
target = cairo_get_group_target (cr);
surface = cairo_surface_create_similar (target,
cairo_surface_get_content (target),
SIZE / 2, SIZE / 2);
cr2 = cairo_create (surface);
cairo_set_source_rgb (cr2, 1, 0, 0); /* red */
draw_square (cr2);
cairo_destroy (cr2);
cairo_surface_set_device_offset (surface, + SIZE / 2, + SIZE / 2);
/* Finally, copy the offset surface to the original destination.
* The final result should be a blue square with the upper-left
* quarter red. */
cairo_set_source_surface (cr, surface, SIZE / 2, SIZE / 2);
cairo_paint (cr);
cairo_surface_destroy (surface);
return CAIRO_TEST_SUCCESS;
}
开发者ID:Dirbaio,项目名称:libgdiplus,代码行数:35,代码来源:device-offset-positive.c
示例17: 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
示例18: iupDrawUpdateSize
void iupDrawUpdateSize(IdrawCanvas* dc)
{
int w, h;
#if GTK_CHECK_VERSION(2, 24, 0)
w = gdk_window_get_width(dc->window);
h = gdk_window_get_height(dc->window);
#else
gdk_drawable_get_size(dc->window, &w, &h);
#endif
if (w != dc->w || h != dc->h)
{
cairo_surface_t* surface;
dc->w = w;
dc->h = h;
cairo_destroy(dc->image_cr);
surface = cairo_surface_create_similar(cairo_get_target(dc->cr), CAIRO_CONTENT_COLOR_ALPHA, dc->w, dc->h);
dc->image_cr = cairo_create(surface);
cairo_surface_destroy(surface);
}
}
开发者ID:kmx,项目名称:mirror-iup,代码行数:25,代码来源:iupgtk_draw_cairo.c
示例19: draw_mask
static void
draw_mask (cairo_t *cr)
{
cairo_surface_t *surface;
cairo_t *cr2;
surface = cairo_surface_create_similar (cairo_get_group_target (cr),
CAIRO_CONTENT_ALPHA,
50, 50);
cr2 = cairo_create (surface);
cairo_surface_destroy (surface);
cairo_rectangle (cr2,
0, 0,
40, 40);
cairo_rectangle (cr2,
10, 10,
40, 40);
cairo_clip (cr2);
cairo_move_to (cr2, 0, 25);
cairo_line_to (cr2, 50, 25);
cairo_move_to (cr2, 25, 0);
cairo_line_to (cr2, 25, 50);
cairo_set_source_rgb (cr2, 1, 1, 1);
cairo_stroke (cr2);
cairo_set_source_rgb (cr, 1, 0, 0);
cairo_mask_surface (cr, cairo_get_target (cr2), 50, 50);
cairo_destroy (cr2);
}
开发者ID:499940913,项目名称:moon,代码行数:31,代码来源:xlib-expose-event.c
示例20: zoom_rect
static void zoom_rect(int x1, int y1, int x2, int y2) {
cairo_t *ctx;
cairo_surface_t *buf, *t;
t = cairo_xlib_surface_create(dpy, wshow, vis, sw, sh);
buf = cairo_surface_create_similar(t, CAIRO_CONTENT_COLOR, sw, sh);
ctx = cairo_create(buf);
cairo_surface_destroy(t);
PopplerDocument *pdf;
pdf = poppler_document_new_from_file(show->uri, NULL, NULL);
PopplerPage *page = poppler_document_get_page(pdf, show->cur);
double pdfw, pdfh;
poppler_page_get_size(page, &pdfw, &pdfh);
cairo_set_source_rgba(ctx, 1, 1, 1, 1);
cairo_paint(ctx);
double scx = show->w / pdfw, scy = show->h / pdfh;
double dx = 0.0, dy = 0.0;
if (conf.lock_aspect) {
if (scx > scy) dx = (show->w - pdfw * (scx=scy)) / 2.0;
else dy = (show->h - pdfh * (scy=scx)) / 2.0;
}
cairo_scale(ctx, scx * show->w /(double) (x2-x1),
scy * show->h /(double) (y2-y1));
cairo_translate(ctx, (dx - x1)/scx, (dy - y1)/scy);
poppler_page_render(page, ctx);
cairo_set_source_surface(show->target[0].ctx, buf, 0, 0);
int i;
for (i = conf.fade; i; i--) {
cairo_paint_with_alpha(show->target[0].ctx, 1/(float)i);
XFlush(dpy);
usleep(5000);
}
cairo_destroy(ctx);
cairo_surface_destroy(buf);
}
开发者ID:thamnos,项目名称:Slider,代码行数:34,代码来源:actions.c
注:本文中的cairo_surface_create_similar函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论