Esempio n. 1
1
static GdkPixbuf *
pixbuf_from_data_with_size_data (const guchar * buff,
                                 size_t len,
                                 struct RsvgSizeCallbackData *data,
                                 const char *base_uri,
                                 const char *id,
                                 GError ** error)
{
    RsvgHandle *handle;
    GdkPixbuf *retval;

    handle = rsvg_handle_new ();

    if (!handle) {
        g_set_error (error, rsvg_error_quark (), 0, _("Error creating SVG reader"));
        return NULL;
    }

    rsvg_handle_set_size_callback (handle, _rsvg_size_callback, data, NULL);
    rsvg_handle_set_base_uri (handle, base_uri);

    if (!rsvg_handle_write (handle, buff, len, error)) {
        g_object_unref (G_OBJECT (handle));
        return NULL;
    }

    if (!rsvg_handle_close (handle, error)) {
        g_object_unref (G_OBJECT (handle));
        return NULL;
    }

    retval = rsvg_handle_get_pixbuf_sub (handle, id);
    g_object_unref (G_OBJECT (handle));

    return retval;
}
Esempio n. 2
0
static VALUE
rb_rsvg_handle_get_pixbuf(int argc, VALUE *argv, VALUE self)
{
    VALUE id;
    VALUE rb_pixbuf;
    GdkPixbuf *pixbuf = NULL;

    rb_scan_args(argc, argv, "01", &id);
    if (NIL_P(id)) {
        pixbuf = rsvg_handle_get_pixbuf(_SELF(self));
    } else {
#ifdef HAVE_RSVG_HANDLE_GET_PIXBUF_SUB
        pixbuf = rsvg_handle_get_pixbuf_sub(_SELF(self),
                                            (const char *)RVAL2CSTR(id));
#else
        rb_warning("rsvg_handle_get_pixbuf_sub isn't "
                   "supported in your librsvg");
#endif
    }

    rb_pixbuf = GOBJ2RVAL(pixbuf);
    if (pixbuf)
        g_object_unref(pixbuf);
    return rb_pixbuf;
}
Esempio n. 3
0
JNIEXPORT jlong JNICALL
Java_org_gnome_rsvg_RsvgHandle_rsvg_1handle_1get_1pixbuf_1sub
(
	JNIEnv* env,
	jclass cls,
	jlong _self,
	jstring _id
)
{
	GdkPixbuf* result;
	jlong _result;
	RsvgHandle* self;
	const char* id;

	// convert parameter self
	self = (RsvgHandle*) _self;

	// convert parameter id
	id = (const char*) bindings_java_getString(env, _id);
	if (id == NULL) {
		return 0L; // Java Exception already thrown
	}

	// call function
	result = rsvg_handle_get_pixbuf_sub(self, id);

	// cleanup parameter self

	// cleanup parameter id
	bindings_java_releaseString(id);

	// translate return value to JNI type
	_result = (jlong) result;

	// cleanup return value
	if (result != NULL) {
		bindings_java_memory_cleanup((GObject*)result, FALSE);
	}

	// and finally
	return _result;
}
Esempio n. 4
0
/**
 * rsvg_handle_get_pixbuf:
 * @handle: An #RsvgHandle
 *
 * Returns the pixbuf loaded by #handle.  The pixbuf returned will be reffed, so
 * the caller of this function must assume that ref.  If insufficient data has
 * been read to create the pixbuf, or an error occurred in loading, then %NULL
 * will be returned.  Note that the pixbuf may not be complete until
 * @rsvg_handle_close has been called.
 *
 * Returns: (transfer full): the pixbuf loaded by #handle, or %NULL.
 **/
GdkPixbuf *
rsvg_handle_get_pixbuf (RsvgHandle * handle)
{
    return rsvg_handle_get_pixbuf_sub (handle, NULL);
}