Re: const version of Gdk::Pixbuf::save()
- From: Kjell Ahlstedt <kjell ahlstedt bredband net>
- To: Tom <tfj gmx de>
- Cc: gtkmm-list <gtkmm-list gnome org>
- Subject: Re: const version of Gdk::Pixbuf::save()
- Date: Thu, 21 Jun 2012 19:45:48 +0200
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*.
Kjell
2012-06-21 09:31, Tom skrev:
Hello,
In the documentation of Pixbuf
(http://developer.gnome.org/gtkmm/3.4/classGdk_1_1Pixbuf.html) I can not
find const versions of save methods (save, save_to_buffer). I wonder why?
In my application I show some calculated image data employing a
Gtk::Image that is initialized with a Glib::RefPtr<Gdk::Pixbuf>.
Within my saving method I fetch the data as follow:
1 Gtk::Image const& img (my_canvas->getImage()); // getImage() is const
2 Glib::RefPtr<const Gdk::Pixbuf> pix_buf (img.get_pixbuf());
3 pix_buf.save(fname, "png"); // fname is a std::string
The compiler complains:
error: passing ‘const Gdk::Pixbuf’ as ‘this’ argument of ‘void
Gdk::Pixbuf::save(const string&, const Glib::ustring&)’ discards
qualifiers [-fpermissive]
In line 3 of the above code I need the save method to be const.
In general maybe this is not the appropriate way to save the image?
Thank you for your effort to read my text and hopefully answer my questions
tom
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]