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



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bob Murphy wrote:
|> 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.

Thank's Bob. From your description, and looking at GtkFixed, it looks like GtkFixed might
well solve the problem I'm looking at.

I have a question, or 2, about what you described above:

Step 3 (where you put the 1st GtkFixed into the GtkVBox) - You specify that you "position"
it in teh "upper left" corner. GtkVBox doesn't let you position it's children, and
GtkFixed doesn't let you position itself (only it's children). So I'm wondering about your
statement of "put it at the upper left of the GtkVBox"

Step 4) The 2nd GtkFixed is a child of which ? the GtkVBox, or the 1st GtkFixed. It seems
to me that the only way to position the 2nd GtkFixed, is to make it a child of the 1st
GtkFixed. Is this what you did ?

Other than that, this looks pretty much like what I'm looking for. When I want to move the
embedded image, I just gtk_fixed_move the embedded image within the 1st GtkFixed. In
fact... it looks to me like I do not need the 2nd GtkImage embedded inside of a GtkFixed,
since (as near as I can tell from reading the GtkFixed documentation), positioning the
embedded image will be done by gtk_fixed_move() of the child inside the top layer
GtkFixed. Do you concur ?

All the best,

- -Greg

| - Bob Murphy
| _______________________________________________
| gtk-app-devel-list mailing list
| gtk-app-devel-list gnome org
| http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


- --
+---------------------------------------------------------------------+

Please also check the log file at "/dev/null" for additional information.
                (from /var/log/Xorg.setup.log)

| Greg Hosler                                   ghosler redhat com    |
+---------------------------------------------------------------------+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFH41K7404fl/0CV/QRAszeAJ9Va6r+t6kPidEfGQGFBHhcSzc1FQCgzrgZ
Zox/zZHvJPCRdg+8B0XVtB8=
=ypTG
-----END PGP SIGNATURE-----



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