Add a function for drawing a cairo surface
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
c3e0f72c56
commit
7b53a73b0f
19
draw.c
19
draw.c
|
@ -283,6 +283,25 @@ draw_image(draw_context_t *ctx, int x, int y, double ratio, image_t *image)
|
|||
draw_image_from_argb_data(ctx, x, y, image_getwidth(image), image_getheight(image), ratio, image_getdata(image));
|
||||
}
|
||||
|
||||
/** Draw an image to a draw context.
|
||||
* \param ctx Draw context to draw to.
|
||||
* \param x X coordinate.
|
||||
* \param y Y coordinate.
|
||||
* \param ratio The ratio to apply to the image.
|
||||
* \param source The image to draw.
|
||||
*/
|
||||
void
|
||||
draw_surface(draw_context_t *ctx, int x, int y,
|
||||
double ratio, cairo_surface_t *source)
|
||||
{
|
||||
cairo_t *cr = cairo_create(ctx->surface);
|
||||
cairo_scale(cr, ratio, ratio);
|
||||
cairo_set_source_surface(cr, source, x / ratio, y / ratio);
|
||||
cairo_paint(cr);
|
||||
|
||||
cairo_destroy(cr);
|
||||
}
|
||||
|
||||
/** Rotate a pixmap.
|
||||
* \param ctx Draw context to draw with.
|
||||
* \param src Drawable to draw from.
|
||||
|
|
1
draw.h
1
draw.h
|
@ -130,6 +130,7 @@ bool draw_text_context_init(draw_text_context_t *, const char *, ssize_t);
|
|||
void draw_text(draw_context_t *, draw_text_context_t *, PangoEllipsizeMode, PangoWrapMode, alignment_t, alignment_t, area_t);
|
||||
void draw_rectangle(draw_context_t *, area_t, float, bool, const color_t *);
|
||||
void draw_image(draw_context_t *, int, int, double, image_t *);
|
||||
void draw_surface(draw_context_t *, int, int, double, cairo_surface_t *);
|
||||
void draw_rotate(draw_context_t *, xcb_drawable_t, xcb_drawable_t, int, int, int, int, double, int, int);
|
||||
area_t draw_text_extents(draw_text_context_t *);
|
||||
alignment_t draw_align_fromstr(const char *);
|
||||
|
|
Loading…
Reference in New Issue