/** * Convertit un pixbuf en chaine codée en base 64 * * \param pixbuf * * */ gchar * gsb_select_icon_create_chaine_base64_from_pixbuf ( GdkPixbuf *pixbuf ) { GdkPixdata pixdata; guint8 *str; guint longueur; gchar * str64; gdk_pixdata_from_pixbuf ( &pixdata, pixbuf, FALSE ); str = gdk_pixdata_serialize ( &pixdata, &longueur ); str64 = g_base64_encode(str, longueur); g_free(str); return str64; }
/* --- functions --- */ static void print_csource (FILE *f_out, GdkPixbuf *pixbuf) { GdkPixdata pixdata; gpointer free_me; GString *gstring; free_me = gdk_pixdata_from_pixbuf (&pixdata, pixbuf, use_rle); gstring = gdk_pixdata_to_csource (&pixdata, image_name, gen_type | gen_ctype | (with_decoder ? GDK_PIXDATA_DUMP_RLE_DECODER : 0)); g_fprintf (f_out, "%s\n", gstring->str); g_free (free_me); }
static char* serializer_pixbuf_encode_b64 (Serializer* self, GdkPixbuf* pixbuf) { char* result = NULL; GdkPixdata _tmp0_ = {0}; GdkPixdata pixdata; void* pixel_data; guchar* _tmp3_; gint _tmp2__length1; guchar* _tmp2_; gint _tmp1_; char* _tmp4_; char* rt; g_return_val_if_fail (self != NULL, NULL); g_return_val_if_fail (pixbuf != NULL, NULL); pixdata = (_tmp0_.magic = (guint32) 0, _tmp0_); pixel_data = gdk_pixdata_from_pixbuf (&pixdata, pixbuf, TRUE); rt = (_tmp4_ = (_tmp3_ = (_tmp2_ = gdk_pixdata_serialize (&pixdata, &_tmp1_), _tmp2__length1 = _tmp1_, _tmp2_), g_base64_encode (_tmp3_, _tmp1_)), _tmp2_ = (g_free (_tmp2_), NULL), _tmp4_); g_free (pixel_data); result = rt; return result; }
static void create_factory_entry(GtkItemFactoryEntry *entry, VALUE self, VALUE path, VALUE item_type, VALUE accel, VALUE extdata, VALUE func, VALUE data) { VALUE action; entry->path = NIL_P(path) ? NULL : RVAL2CSTR(path); entry->item_type = NIL_P(item_type) ? "<Branch>" : RVAL2CSTR(item_type); entry->accelerator = NIL_P(accel) ? NULL : RVAL2CSTR(accel); if (menuitem_type_check(entry->item_type) == 0) { entry->callback = NULL; } else { if (NIL_P(func)) { entry->callback = NULL; } else { entry->callback = items_exec_callback_wrap; } } action = rb_ary_new3(2, func, data); G_RELATIVE(self, action); rb_hash_aset(action_table, UINT2NUM(action_id), action); entry->callback_action = action_id; action_id++; if (NIL_P(extdata)){ entry->extra_data = NULL; } else if (TYPE(extdata) == T_STRING){ entry->extra_data = RVAL2CSTR(extdata); } else if (TYPE(extdata) == T_SYMBOL){ entry->extra_data = rb_id2name(SYM2ID(extdata)); } else if (RVAL2GTYPE(extdata) == GDK_TYPE_PIXBUF){ GdkPixdata pixdata; guint stream_length_p; gdk_pixdata_from_pixbuf(&pixdata, GDK_PIXBUF(RVAL2GOBJ(extdata)), TRUE); entry->extra_data = gdk_pixdata_serialize(&pixdata, &stream_length_p); } else { entry->extra_data = NULL; } }