[prev in list] [next in list] [prev in thread] [next in thread]
List: gtkmm
Subject: Re: const version of Gdk::Pixbuf::save()
From: Florian Philipp <lists () binarywings ! net>
Date: 2012-06-21 19:28:43
Message-ID: 4FE375EB.70407 () binarywings ! net
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
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
["signature.asc" (application/pgp-signature)]
_______________________________________________
gtkmm-list mailing list
gtkmm-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtkmm-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic