Re: Thoughts about a new GdkPixbuf transform interface



Minimal GdkPixbufTransform API as I see it.
[comments in the code]
Should be many typos.


typedef struct _GdkPixbufTransform GdkPixbufTransform;

enum {
GDK_TRANSFORM_AFFINE, /* dest coord = linear function (src coord) */
       GDK_TRANSFORM_FUNCTION, /* any arbitrary function */
GDK_TRANSFORM_FUNCTION_AFFINE, /* dst coord = function ( affine (src coord) ) */ GDK_TRANSFORM_AFFINE_FUNCTION, /* dst coord = affine ( function (src coord) ) */
} GdkPixbufTransformType;

GdkPixbufTransform* gdk_pixbuf_transform_new    (GdkPixbuf*             src,
GdkPixbufTransformType type);

/* transformation setup functions */

void gdk_pixbuf_transform_reset         (GdkPixbufTransform*    trans);
void gdk_pixbuf_transform_set_affine    (GdkPixbufTransform*    trans,
                                        gdouble                offset_x,
                                        gdouble                offset_y,
                                        gdouble                m00,
                                        gdouble                m01,
                                        gdouble                m10,
                                        gdouble                m11);
[I like it this way. Somebody will like big matrix]
void gdk_pixbuf_transform_rotate        (GdkPixbufTransform*    trans,
                                        gdouble                angle);
void gdk_pixbuf_transform_scale         (GdkPixbufTransform*    trans,
                                        gdouble                scale_x,
                                        gdouble                scale_y);
void gdk_pixbuf_transform_offset        (GdkPixbufTransform*    trans,
                                        gdouble                move_x,
                                        gdouble                move_y);

typedef gboolean (*GdkPixbufTransformFunc)      (gdouble*       src_x,
                                                gdouble*       src_y,
                                                gdouble        dst_x,
                                                gdouble        dst_y,
                                                gpointer       user_data);

void gdk_pixbuf_transform_set_func (GdkPixbufTransform* trans, GdkPixbufTransformFunc reverse_func, gpointer user_data);
[one function call for each pixel.
nearest is trivial.
keeping values for neighbor pixels allows to approximate derivatives, should be
enough to calculate filter]


/* convenience setup functions */

void gdk_pixbuf_transform_setup_rotate  (GdkPixbufTransform*    trans,
                                        gdouble                dst_x,
                                        gdouble                dst_y,
                                        gdouble                angle,
gdouble src_center_x, gdouble src_center_y);

/* options */

typedef enum {
       GDK_PIXBUF_EDGE_TRANSPARENT,    /* do nothing (default) */
GDK_PIXBUF_EDGE_NEAREST, /* edges stratching mode (useful when scaling) */
       GDK_PIXBUF_EDGE_TILE,           /* clone src pixbuf */
} GdkPixbufEdgeMode;

void gdk_pixbuf_transform_set_edge_mode (GdkPixbufTransform* trans, GdkPixbufEdgeMode mode); void gdk_pixbuf_transform_set_interp_type (GdkPixbufTransform* trans, GdkInterpType interp_type); void gdk_pixbuf_transform_set_overall_alpha (GdkPixbufTransform* trans, gint overall_alpha); void gdk_pixbuf_transform_set_background_color (GdkPixbufTransform* trans, guint32 color);

/* render functions */

void gdk_pixbuf_transform_get_bounds    (GdkPixbufTransform*    trans,
                                        GdkPixbuf*             dest,
gdouble* bound_rect_x, gdouble* bound_rect_y, gdouble* bound_rect_width, gdouble* bound_rect_height);

void gdk_pixbuf_transform_render        (GdkPixbufTransform*    trans,
                                        GdkPixbuf*             dest);

void gdk_pixbuf_transform_render_rect   (GdkPixbufTransform*    trans,
                                        GdkPixbuf*             dest,
                                        gint                   rect_x,
                                        gint                   rect_y,
                                        gint                   rect_width,
gint rect_height);

/* convinience functions */

void gdk_pixbuf_transform_vector        (GdkPixbufTransform*    trans,
gdouble* dst_vector_x, gdouble* dst_vector_y, gdouble src_vector_x, gdouble src_vector_y);

GdkPixbuf* gdk_pixbuf_transform_rotate_simple   (GdkPixbuf*     src,
                                                gdouble        angle);
GdkPixbuf* gdk_pixbuf_transform_scale_simple    (GdkPixbuf*     src,
                                                gint           dest_width,
gint dest_height);

Suggestions welcome.
(I'm now implemeting it, quite easy, without complex filters)






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