Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 01-15-2011, 10:24 PM   #1
Registered: Aug 2008
Distribution: Gentoo; VoidLinux; Funtoo
Posts: 216

Rep: Reputation: 18
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);
image = cairo_image_surface_create_from_png("first.png");
image = cairo_image_surface_create_from_png("second.png");

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

g_signal_connect(window, "expose-event", G_CALLBACK (pimage), NULL);
Old 01-18-2011, 12:07 AM   #2
Senior Member
Registered: Dec 2008
Posts: 4,680
Blog Entries: 29

Rep: Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917
See if this thread helps you:

If not then consider shooting off a mail to:
Old 01-25-2011, 02:52 PM   #3
Julian Andrews
LQ Newbie
Registered: Jan 2011
Distribution: Ubuntu
Posts: 21

Rep: Reputation: 13
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:
void changeimage(GtkWidget *widget)
    count = (count + 1) % 4;
    if (count == 3)
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.
1 members found this post helpful.
Old 01-30-2011, 01:13 AM   #4
Registered: Aug 2008
Distribution: Gentoo; VoidLinux; Funtoo
Posts: 216

Original Poster
Rep: Reputation: 18
Thumbs up

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Screen refresh, image distorted if moving bucovaina78 Linux - Desktop 7 02-10-2012 11:09 AM
[SOLVED] Pasting a png image on another through CAIRO library TheIndependentAquarius Programming 5 03-06-2010 03:22 AM
How do I draw an image with Qt? Ephracis Programming 3 06-27-2009 06:10 AM
Folder refresh. Where can I change how often the refresh occurs? glore2002 Slackware 2 08-12-2008 12:37 AM
pckage "cairo" required by cairo" not found barunparichha Linux - Software 4 06-25-2008 08:29 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:40 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration