Re: how to handle an array of Pixbuf?



How do you transfer the array from the creating method to the painting method? With arrays it's easy to (by mistake) copy a pointer to the array when you should have copied the whole array. A std::vector is often safer,

std::vector< Glib::RefPtr<Gdk::Pixbuf> > image2(3);

Kjell

2013-03-01 19:17, jody skrev:
Follow up:
when i fill the PixBuf array in the same method where i paint its
element this works...
Jody

On Fri, Mar 1, 2013 at 7:10 PM, jody <jody xha gmail com> wrote:
Hi

When i do
    Glib::RefPtr<Gdk::Pixbuf> image1 =
Gdk::Pixbuf::create_from_file("base1.png");

i can later (in a different method) paint this into a cairo context like this:
    Gdk::Cairo::set_source_pixbuf(cr, image1, 0, 0);


Now i wanted to do the same with an array of PixBufs:
     Glib::RefPtr<Gdk::Pixbuf> image2[3];
     image2[0] =  Gdk::Pixbuf::create_from_file("hexT1.png");
     image2[1] =  Gdk::Pixbuf::create_from_file("hexT2.png");
     image2[2] =  Gdk::Pixbuf::create_from_file("hexT3.png");
this compiles and seems to work, but painting (in a different method) :
     Gdk::Cairo::set_source_pixbuf(cr, image2[0], 0, 0);
fails with a segmentation fault.

I suspect that for some reason the RefPtr died, but i actually have no idea.

Can anybody help me?

Thank You
   Jody
_______________________________________________




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]