23#include <gdk-pixbuf/gdk-pixbuf.h>
37 FILE *
const fp = fopen(file,
"rb");
40 fseek (fp, 0, SEEK_END);
46 if (fread(
data,
len, 1, fp) != 1) {
54 if (cairo_surface_set_mime_data(
image, mime_type,
data,
56 CAIRO_STATUS_SUCCESS) {
61 agxbprint(&
id,
"gvloadimage_gdk-%s", file);
63 if (cairo_surface_set_mime_data(
image, CAIRO_MIME_TYPE_UNIQUE_ID,
64 (
unsigned char *)unique_id,
65 strlen(unique_id),
free, unique_id) !=
66 CAIRO_STATUS_SUCCESS) {
96 const bool is_last = cairo_surface_get_reference_count(
data->surface) == 1;
97 cairo_surface_destroy(
data->surface);
108 cairo_surface_t *cairo_image =
NULL;
118 cairo_image = cairo_surface_reference(
data->surface);
142 gdk_cairo_set_source_pixbuf (cr,
image, 0, 0);
143 cairo_pattern_t *
const pattern = cairo_get_source(cr);
144 assert(cairo_pattern_get_type (pattern) == CAIRO_PATTERN_TYPE_SURFACE);
145 cairo_pattern_get_surface (pattern, &cairo_image);
146 cairo_image = cairo_surface_reference (cairo_image);
150 *
data = (
data_t){.surface = cairo_surface_reference(cairo_image),
168 cairo_translate(cr, b.
LL.
x, -b.
UR.
y);
169 cairo_scale(cr, (b.
UR.
x - b.
LL.
x) / us->
w, (b.
UR.
y - b.
LL.
y) / us->
h);
170 cairo_set_source_surface (cr,
image, 0, 0);
173 cairo_surface_destroy (
image);
static int agxbprint(agxbuf *xb, const char *fmt,...)
Printf-style output to an agxbuf.
static char * agxbdisown(agxbuf *xb)
Memory allocation wrappers that exit on failure.
static void * gv_alloc(size_t size)
static double len(glCompPoint p)
void gvusershape_file_release(usershape_t *us)
bool gvusershape_file_access(usershape_t *us)
static size_t gv_ftell(FILE *stream)
ftell, accounting for platform limitations
gvplugin_installed_t gvloadimage_gdk_types[]
static void gdk_loadimage_cairo(GVJ_t *job, usershape_t *us, boxf b, bool filled)
static void gdk_set_mimedata_from_file(cairo_surface_t *image, const char *mime_type, const char *file)
static gvloadimage_engine_t engine_gdk
static void gdk_freeimage(usershape_t *us)
static cairo_surface_t * gdk_loadimage(GVJ_t *job, usershape_t *us)
static void gdk_set_mimedata(cairo_surface_t *image, usershape_t *us)
resources allocated for loaded images
cairo_surface_t * surface
void(* datafree)(usershape_t *us)