strange behaviour of Gtk::Image



Hi,

I got a strange problem. I am writing data out of a matrix or double array
into a pixel buffer. But when I want to display it nothing happens. Only the
borders of my scrolled window are reset. The wired thing about it is that I
do the same stuff in other applications to and I don’t see why it is not
working. Here is my code how I want to change a Gtk::Image:

pixbuf in headerfile:   Glib::RefPtr<Pixbuf> pixbufer;
                              guint8 *pixels, *pixel;
                              bool pixbuf_build;

void main_window::on_button1_clicked()
{
…// a lot of code to put data into a matrix called data_matrix[x][y]
    pixbufer = Gdk::Pixbuf::create(COLORSPACE_RGB, false, 8, 1000, 1000);
    pixels = pixbufer -> get_pixels();
    int channels = pixbufer -> get_n_channels();
    int linelength = pixbufer -> get_rowstride();
    for (int i=0; i<1000; i++)
    {
        for(int j=0; j<1000; j++)
        {
            // set up pixbuf for display 
            pixel = pixels + i*channels +j*linelength;
            pixel[0] = (guint8) 0; //data_matrix[i][j];	// to check if I
have a mistake in the 
            pixel[1] = (guint8) 0; //data_matrix[i][j];	// data format I
made everything 
            pixel[2] = (guint8) 0; //data_matrix[i][j];	// black, but no
response
        }
    }
    pixbuf_build = true;
    queue_draw();
}

bool main_window::on_image1_expose_event(GdkEventExpose *ev)
{
    if (pixbuf_build)
    {
            image1 -> set(pixbufer);
    }
} 

My application I created in glade. It simply consists out of one button and
a scrolled window with an image inside. It is nothing fancy. But still I
cannot see the reason for this behavior. 

Thank you in advance for your help
Best regards

-- 
View this message in context: http://www.nabble.com/strange-behaviour-of-Gtk%3A%3AImage-tf2587148.html#a7213667
Sent from the Gtkmm mailing list archive at Nabble.com.




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