LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 01-15-2011, 10:24 PM   #1
darthaxul
Member
 
Registered: Aug 2008
Distribution: Devuan; Gentoo; FreeBSD
Posts: 236

Rep: Reputation: 19
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);
 
Old 01-18-2011, 12:07 AM   #2
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,732
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
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
 
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:
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.
 
1 members found this post helpful.
Old 01-30-2011, 01:13 AM   #4
darthaxul
Member
 
Registered: Aug 2008
Distribution: Devuan; Gentoo; FreeBSD
Posts: 236

Original Poster
Rep: Reputation: 19
Thumbs up

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


Reply



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 Aquarius_Girl 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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:26 PM.

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