Re: How does one overlay one image on top of another ?



I found gdk_draw_drawable(), but don't really understand GdkDrawables. I'd REALLY like to
draw an image on a "different layer" such that I can move/remove it w/o having to redraw
the original. Failing that, I'll settle for learning how to overlay one image on top of
another.

I recently did a test hack that achieved images that overlay each other using GTK on Ubuntu:
1. Make a GtkWindow.
2. Make a GtkVBox and put it in the window.
3. Make a GtkFixed and put it at the upper left of the GtkVBox.
4. Make another GtkFixed and put it a little to the right of the other one.
5. Make a GtkImage from a PNG file, and put it in the GtkFixed from step 3.
6. Make another GtkImage from the same PNG file, and put it in the GtkFixed from step 4.
7. Show everything.

The result was that the GtkImage from step 6 was on top of the GtkImage from step 5, just shifted a little to the right, so that it covered most of the lower image but not all of it.

What's more, the PNG file I used had an alpha channel, and where the upper GtkImage where it was not opaque, it was color-composited, so I could see the lower image through it.

You could do this all with GDK directly, and you can also use GDK to composite multiple images into a single image and put that to the screen. But it's a bit more fooling around.

- Bob Murphy



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]