views:

15

answers:

0

Which is the best and fastest way to retrieve the color of a given pixel of a widget? For example: I load an image onto a Gtk::DrawingArea or draw something on it. Then I try to retrieve the color of the pixel that the mouse cursor is over. I use this technique:

bool MainWindow::on_canvas_motion_notify(GdkEventMotion* event)
{
    get_window()->get_image(0, 0, -1, -1)->get_pixel (event->x, event->y);
}

But it kills the speed and slows down the execution of the app. Is there a better way to do such a thing, or do I have to use another library instead of GDK? I don't want to use Cairo because I have to work with raster graphics not vector ones.