Re: [gtk-osx-devel] Gdk::Pixbuf::create(Gdk::Window, int, int, int, int) on Mac LION
- From: Richard Procter <richard n procter gmail com>
- To: charltn gmail com
- Cc: gtk-osx-devel-list gnome org
- Subject: Re: [gtk-osx-devel] Gdk::Pixbuf::create(Gdk::Window, int, int, int, int) on Mac LION
- Date: Fri, 20 Jul 2012 09:30:02 +1200
Hi Jim,
Good to hear you found a workaround and thanks for taking the time to share with us.
I'm unfamiliar with gtkmm and the gory details of gdk-pixbuf, which is why I didn't comment further.
best,
Richard.
On 19/07/2012, at 4:30 AM, JIm Charlton wrote:
> A final post about the problems with Gdk::Pixbuf::create() on OS X 10.7 using gtkmm-3.0...
>
> I have not found a way to make this call work on the MAC.
> I found a work-around. I needed to save the image drawn within a Cairo::Context (cr). Rather than getting a pixbuf from the Gdk::Window after rendering the image, I do a cr->push_group() before the cairo draw instructions. After drawing the image I do a Cairo::RefPtr<Cairo::Pattern> pattern_ = cr->pop_group(). This saves a pointer to the image. I can then render the image with cr->set_source(pattern_) and cr->paint(). Later, after placing some additional features on the image I can revert to the original image in pattern_ by wiping the context with cr->set_source_rgb( 0.9,0.9,0.9); cr->paint(), and then restore the original image as above.
>
> I am sure that most of my problems stem from a lack of familiarity with cairo and cairomm. But for now, I seem to have solved my immediate problems.
>
> Sorry I could not be more helpful with the bug in the gtkmm/gtk libraries on OS X.
>
> jim...
>
>
>
> On 12-07-14 05:08 PM, JIm Charlton wrote:
>> Further to my problem with a call to Gdk::Pixbuf::create(), I compiled the gtk libraries with debugging support and ran my test program under gdb. Here is the output from stepping into the Gdk library. Any suggestions on where to go now? Exactly where do I file a bug with bugzilla? Sorry about my ignorance! :-)
>> ********************
>> (gdb) break 134
>> Breakpoint 1 at 0x1000021b9: file main-2.cc, line 134.
>> (gdb) run
>> Starting program: /Users/jim-2/pixbuf_test/bin/Debug/myprog
>> Reading symbols for shared libraries ++++++++++++++++++++++.................................................................................................................................................... done
>> Reading symbols for shared libraries . done
>> Reading symbols for shared libraries . done
>> Reading symbols for shared libraries . done
>> Reading symbols for shared libraries . done
>> Reading symbols for shared libraries . done
>> In Area::on_draw()...
>> In Area::on_draw()...
>> Realized 1
>>
>> Breakpoint 1, PlotTest::on_test_clicked (this=0x7fff5fbfee98) at main-2.cc:134
>> warning: Source file is more recent than executable.
>> 134 Glib::RefPtr<Gdk::Pixbuf> pixbuf_ = Gdk::Pixbuf::create(myarea.myarea_win_, 0,0,winw,winh);
>> (gdb) s
>> Gdk::Pixbuf::create (src=@0x7fff5fbfeee0, src_x=0, src_y=0, width=500, height=300) at pixbuf.cc:381
>> 381 return Glib::RefPtr<Pixbuf>( new Pixbuf(src, src_x, src_y, width, height) );
>> (gdb) s
>> Gdk::Pixbuf::Pixbuf (this=0x102543b90, src=@0x7fff5fbfeee0, src_x=0, src_y=0, width=500, height=300)
>> at pixbuf.cc:68
>> 68 src->gobj(), src_x, src_y, width, height))
>> (gdb) s
>> Glib::ObjectBase::ObjectBase (this=0x102543ba0, __vtt_parm=0x100a005a8) at objectbase.cc:49
>> 49 cpp_destruction_in_progress_ (false)
>> (gdb) s
>> 50 {}
>> (gdb) s
>>
>> (myprog:38919): glibmm-CRITICAL **: Glib::Interface::Interface(const Glib::Interface_Class&): assertion `gobject_ != 0' failed
>>
>> (myprog:38919): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed
>> *********************
>>
>> Here is the program
>> *********************
>> #include <gtkmm/main.h>
>>
>> #include <gtkmm/box.h>
>> #include <gtkmm/window.h>
>>
>> #include <gtkmm/separator.h>
>> #include <gtkmm/textview.h>
>> #include <gtkmm.h>
>>
>> #include <gtkmm/drawingarea.h>
>>
>> #include <gtkmm/image.h>
>> #include <gtkmm/stock.h>
>> #include <iostream>
>> #include <cairomm/context.h>
>> #include <gtkmm/button.h>
>>
>>
>> class Area : public Gtk::DrawingArea
>> {
>> public:
>> Area();
>> virtual ~Area();
>> Glib::RefPtr<Gdk::Window> myarea_win_;
>> protected:
>> virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
>> virtual void on_realize();
>> };
>>
>> Area::Area()
>> {
>>
>> }
>>
>> Area::~Area()
>> {
>> }
>>
>> bool Area::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
>> {
>>
>> printf("In Area::on_draw()...\n");
>> return true;
>> }
>>
>> void Area::on_realize()
>> {
>> // We need to call the base on_realize()
>> Gtk::DrawingArea::on_realize();
>> myarea_win_ = get_window();
>>
>> }
>>
>> class PlotTest : public Gtk::Window
>> {
>> public:
>> PlotTest();
>> virtual ~PlotTest();
>>
>> protected:
>> Area myarea;
>>
>> //Signal handlers:
>> void on_close_clicked();
>> void on_test_clicked();
>>
>> //Child widgets:
>> Gtk::TextView t_view;
>> Gtk::Box m_Box_Top;
>> Gtk::Button m_Button_Close;
>> Gtk::Button m_Button_Test;
>> };
>>
>> PlotTest::PlotTest() :
>> m_Box_Top(Gtk::ORIENTATION_VERTICAL),
>> m_Button_Close("Close"),
>> m_Button_Test("Test Pixbuf Code")
>> {
>> // Set title and border of the window
>> set_title("Cairo Test");
>> set_border_width(0);
>>
>> add(m_Box_Top);
>>
>> // Add myarea to m_Box3. myarea is an Area object (see myarea.h)
>>
>> myarea.set_size_request(500, 300);
>>
>> m_Box_Top.pack_start(myarea);
>>
>> // Put Close button in Box2:
>> m_Box_Top.pack_start(m_Button_Close);
>> m_Box_Top.pack_start(m_Button_Test);
>>
>> m_Button_Close.set_can_default();
>> m_Button_Close.grab_default();
>>
>> // Connect the clicked signal of the button to
>> m_Button_Close.signal_clicked().connect(sigc::mem_fun(*this,
>> &PlotTest::on_close_clicked) );
>>
>> m_Button_Test.signal_clicked().connect(sigc::mem_fun(*this,
>> &PlotTest::on_test_clicked) );
>>
>> show_all();
>> }
>>
>> PlotTest::~PlotTest()
>> {
>> }
>>
>> void PlotTest::on_close_clicked()
>> {
>> hide(); //to close the application.
>> }
>>
>> void PlotTest::on_test_clicked()
>> {
>> int winx, winy, winw, winh;
>>
>> printf("Realized %i\n", myarea.get_realized());
>>
>> myarea.get_window()->get_geometry(winx, winy, winw, winh);
>>
>> Glib::RefPtr<Gdk::Pixbuf> pixbuf_ = Gdk::Pixbuf::create(myarea.myarea_win_, 0,0,winw,winh);
>> }
>>
>> int main(int argc, char *argv[])
>> {
>> Gtk::Main kit(argc, argv);
>>
>> PlotTest Prog;
>> //Shows the window and returns when it is closed.
>>
>> Gtk::Main::run(Prog);
>>
>> return 0;
>> }
>> ****************************
>>
>>
>>
>> _______________________________________________
>> Gtk-osx-devel-list mailing list
>>
>> Gtk-osx-devel-list gnome org
>> https://mail.gnome.org/mailman/listinfo/gtk-osx-devel-list
>
>
> _______________________________________________
> Gtk-osx-devel-list mailing list
> Gtk-osx-devel-list gnome org
> https://mail.gnome.org/mailman/listinfo/gtk-osx-devel-list
- References:
- Re: [gtk-osx-devel] Gdk::Pixbuf::create(Gdk::Window, int, int, int, int) on Mac LION
- Re: [gtk-osx-devel] Gdk::Pixbuf::create(Gdk::Window, int, int, int, int) on Mac LION
- Re: [gtk-osx-devel] Gdk::Pixbuf::create(Gdk::Window, int, int, int, int) on Mac LION
- Re: [gtk-osx-devel] Gdk::Pixbuf::create(Gdk::Window, int, int, int, int) on Mac LION
[
Date Prev][Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]