Am 21.06.2012 19:45, schrieb Kjell Ahlstedt: > Gdk::Pixbuf::save() and save_to_buffer() are C++ wrappers around the C > functions gdk_pixbuf_savev() and gdk_pixbuf_save_to_buffer(), resp. > Those C functions take a "GdkPixbuf* pixbuf" parameter (i.e. not const > GdkPixbuf* pixbuf). I don't know why. It's unintuitive that they should > modify the GdkPixbuf, but perhaps they do. Anyway, that's the reason why > there are no const versions of the corresponding C++ member functions. > > A solution (not very attractive, I admit) is to take a copy of the > Pixbuf with Gdk::Pixbuf::copy() and save the copy. > > If you don't get a better answer here, you can try asking on a gtk+ list > (e.g. gtk-app-devel-list) why the gdk_pixbuf_save*() functions don't > take const GdkPixbuf*. > Why don't you simply cast the const away? Gtk::Image const& img (my_canvas->getImage()); Glib::RefPtr<const Gdk::Pixbuf> pix_buf (img.get_pixbuf()); Glib::RefPtr<Gdk::Pixbuf> mutable_pix_buf = Glib::RefPtr<Gdk::Pixbuf>::cast_const (pix_buf); mutable_pix_buf.save(fname, "png"); Regards, Florian Philipp
Attachment:
signature.asc
Description: OpenPGP digital signature