Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4064308
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:50:21+00:00 2026-05-20T15:50:21+00:00

I want to be able to dynamically place images over another image in my

  • 0

I want to be able to dynamically place images over another image in my app, using Cairo or GTK functions. Imagine, for example, a sea in which the user places fish and sea animals: it will be like that.

How can I do this? If you don’t know but remember any simple program or demo that does that, it will be also very welcome!

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T15:50:21+00:00Added an answer on May 20, 2026 at 3:50 pm

    You can use a GtkDrawingArea and draw the images on it using cairo:

    Example:

    #include <cairo.h>
    #include <gtk/gtk.h>
    
    cairo_surface_t * sea_surface;
    cairo_surface_t * fish_surface;
    
    gboolean on_expose_event(GtkWidget * widget, GdkEventExpose * event, gpointer data) {
        // Create the cairo instance.
        cairo_t * cr = gdk_cairo_create(widget->window);
        // Draw the sea background.
        cairo_set_source_surface(cr, sea_surface, 0.0, 0.0);
        cairo_paint(cr);
        // Draw the fish.
        cairo_set_source_surface(cr, fish_surface, 50.0, 50.0);
        cairo_paint(cr);
        // Destroy the cairo instance.
        cairo_destroy(cr);
        return FALSE;
    }
    
    int main(int argc, char * argv[]) {
        gtk_init(&argc, &argv);
    
        // Load images.
        sea_surface = cairo_image_surface_create_from_png("sea.png");
        fish_surface = cairo_image_surface_create_from_png("fish.png");
    
        // Create window.
        GtkWidget * window;
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
        gtk_window_set_default_size(GTK_WINDOW(window), 320, 240);  
    
        // Create drawing area where we're going to draw our images.
        GtkWidget * drawing_area = gtk_drawing_area_new();
        g_signal_connect(G_OBJECT(drawing_area), "expose-event", G_CALLBACK(on_expose_event), NULL);
        gtk_container_add(GTK_CONTAINER(window), drawing_area);
    
        // Show window and start gtk main loop.
        gtk_widget_show_all(window);
        gtk_main();
    
        // Clean-up.
        cairo_surface_destroy(fish_surface);
        cairo_surface_destroy(sea_surface);
        return 0;
    }
    

    To compile it on linux use:

    gcc -Wall -g images.c -o images `pkg-config --cflags --libs gtk+-2.0`
    

    Documentation:

    • http://library.gnome.org/devel/gtk/stable/GtkDrawingArea.html
    • http://library.gnome.org/devel/gdk/stable/gdk-Cairo-Interaction.html
    • http://www.cairographics.org/manual/cairo-cairo-t.html

    Examples:

    • http://www.tortall.net/mu/wiki/PyGTKCairoTutorial
    • http://www.zetcode.com/tutorials/cairographicstutorial/cairoimages/

    EDIT: If you need to be able to do this from Java, you can use java-gnome which provides bindings for both GTK and cairo.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to be able to dynamically place image(s) over another image in my
I want to be able to dynamically create ViewControllers based on a JSON file.
I'm using LaTeX and BibTeX for an article, and I want to able to
I want to be able to take an image that i have already captured
I want to be able to dynamically mirror a silverlight control. suppose i have
I want to be able to dynamically select a range of cells (the heading
I want to be able to dynamically change width and height in a div
I have compiled shared libraries dynamically linked against libstdc++.so using GLIBCXX_3.4.11. I want to
I kind of want to make a game.... so I want able to dynamically
I want to be able to dynamically control the level of logging my Azure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.