[LIBART] proposed librsvg API change.



Hi,

I'm interested in improving librsvg.  In particular, the current API is
pretty limitted.  You need to give it a FILE, which precludes loading
one from memory, from gnome-vfs, etc.  Additionally, there is no way to
know the zoom factor to pass in if you don't know the size of the file
ahead of time.  There's also no error handling.

I have a proposal for an alternate API here.  I'm probably going to code
it tonight.  Does anyone mind if I commit it when it works?

Thanks,
-Jonathan

--------------------

#ifndef RSVG_H
#define RSVG_H

G_BEGIN_DECLS

#include <stdio.h>
#include <gdk-pixbuf/gdk-pixbuf.h>

typedef enum {
        RSVG_ERROR_FAILED
} RsvgError;

#define RSVG_ERROR (rsvg_error_quark ())
GQuark rsvg_error_quark (void) G_GNUC_CONST;

typedef struct RsvgHandle RsvgHandle;

typedef void (* RsvgSizeFunc) (gint *width,
                               gint *height);


RsvgHandle *rsvg_handle_new               (void);
void        rsvg_handle_set_fonts_dir     (RsvgHandle      *handle,
                                           const char      *fonts_dir);
void        rsvg_handle_set_size_callback (RsvgHandle      *handle,
                                           RsvgSizeFunc     func,
                                           gpointer         data,
                                           GDestroyNotify   destroy);
gboolean    rsvg_handle_write             (RsvgHandle      *handle,
                                           const guchar    *buf,
                                           gsize            count,
                                           GError         **error);
gboolean    rsvg_handle_close             (RsvgHandle      *handle,
                                           GError         **close);
GdkPixbuf  *rsvg_handle_get_pixbuf        (RsvgHandle      *handle,
                                           GError         **errror);
void        rsvg_handle_get_size          (RsvgHandle      *handle,
                                           gint            *width,
                                           gint            *height);
gboolean    rsvg_handle_destroy           (RsvgHandle      *handle);

/* convenience API */
GdkPixbuf  *rsvg_pixbuf_from_file_at_zoom (gchar           *file_name,
                                           double           x_zoom,
                                           double           y_zoom);
GdkPixbuf  *rsvg_pixbuf_from_file_at_size (gchar           *file_name,
                                           gint             width,
                                           gint             height);


G_END_DECLS

#endif





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]