Re: Copy parts of one image to another
- From: Tim Evans <t evans aranz com>
- To: gtk-app-devel-list gnome org
- Subject: Re: Copy parts of one image to another
- Date: Fri, 25 Jun 2004 14:19:24 +1200
Trevor Fancher wrote:
This is driving me absolutely nuts.  I have been trying for the past 3
days.  I have searched on Google and everywhere else logical.  My
question is, "How do I copy part of one image to part of another?"
What I want to do is copy a 16x16 area from my tileset image to a
background image and then display the results in a GtkEventbox.  I am
so frustrated because I just cannot figure this out.  If someone could
give me some example code doing this task, I would be *very*
appreciative.
Load your tileset image using:
  GdkPixbuf *tileset;
  GError *error=NULL;
  tileset = gdk_pixbuf_new_from_file ("tileset.png", &error);
Create an empty 16x16 tile pixbuf using:
  GdkPixbuf *tile;
  tile = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 16, 16);
Then display each tile in a GtkImage widget:
  GtkWidget *image;
  image = gtk_image_new ();
  gtk_image_set_from_pixbuf (GTK_IMAGE (image), tile);
And place the image inside the eventbox:
  gtk_container_add (GTK_CONTAINER (eventbox), image);
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]