LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   cairo image refresh draw (https://www.linuxquestions.org/questions/programming-9/cairo-image-refresh-draw-856577/)

darthaxul 01-15-2011 10:24 PM

cairo image refresh draw
 
Trying to redraw different image via changeimage button event. Any ideas how to make that happen?

cairo_surface_t *image;
static gboolean pimage(GtkWidget *widget,GdkEventExpose *event,gpointer data)
{
cairo_t *cr;
cr = gdk_cairo_create (widget->window);
if(count==3)
image = cairo_image_surface_create_from_png("first.png");
else
image = cairo_image_surface_create_from_png("second.png");

cairo_set_source_surface(cr, image, 620, 81);
cairo_paint(cr);
cairo_destroy(cr);
return FALSE;
}
void changeimage(GtkWidget *widget)
{

}
g_signal_connect(window, "expose-event", G_CALLBACK (pimage), NULL);

Aquarius_Girl 01-18-2011 12:07 AM

See if this thread helps you: http://www.linuxquestions.org/questi...ibrary-792804/

If not then consider shooting off a mail to: http://lists.cairographics.org/mailman/listinfo/cairo

Julian Andrews 01-25-2011 02:52 PM

I'm not 100% sure what the part of the process your having trouble with is, but my best guess is that you want to cause the widget to redraw when changeimage() is called.

Here's my best guess at what you're looking for:
Code:

void changeimage(GtkWidget *widget)
{
    count = (count + 1) % 4;
    if (count == 3)
    {
        gtk_widget_queue_draw(widget);
    }
}

I'm just guessing based on the 'if (count)==3' in your code that what you want is for the image to change to "first.png" every 4th click. Anyway, let me know if I'm on target!

P.S: please excuse any syntax errors, I work mostly in python, and my C is very rusty.

darthaxul 01-30-2011 01:13 AM

yes! elemetary my dear watson, always overlooking the simple...


All times are GMT -5. The time now is 11:49 AM.