mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-14 01:04:04 +00:00
56b5a7eeca
One problem is, that tolua/lua does not handle plain data pointers properly. Therefore something like local surface = cairo_image_surface_create_for_data( imlib_image_get_data_for_reading_only(), .. will fail using the lua bindings. Hence this wrapper, which adds a function which be used to draw an imlib image to a cairo surface. This also addresses another issue, drawing images with a transparent background (e.g. gifs or pngs) to the cairo surface properly. Apparently the image format of imlib is incompatible to cairos which uses pre-multiplied data. This is also explained in the cairo documentation. A fix for this issue is to blend the image with another alpha mask to get the correct values. The code and explanation for this was taken from http://lists.cairographics.org/archives/cairo/2008-March/013492.html Executive Summary: This wrapper function can load (transparent) images (e.g. gif or png) from a file by using imlib and draw them on a cairo surface.
6 lines
212 B
Plaintext
6 lines
212 B
Plaintext
$#include <cairo.h>
|
|
$#include <libcairo_imlib2_helper.h>
|
|
|
|
void cairo_draw_image(const char *, cairo_surface_t *, int, int, double, double,
|
|
double * return_scale_w, double * return_scale_h);
|