RSS/Atom feed Twitter
Site is read-only, email is disabled

Question about how Gimp displays multiple layers

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

4 of 4 messages available
Toggle history

Please log in to manage your subscriptions.

Question about how Gimp displays multiple layers Gregory Hosler 31 Mar 13:53
  Question about how Gimp displays multiple layers David Gowers 31 Mar 16:10
  Question about how Gimp displays multiple layers Bill Skaggs 31 Mar 17:39
  Question about how Gimp displays multiple layers Mukund Sivaraman 03 Apr 04:31
Gregory Hosler
2008-03-31 13:53:16 UTC (about 17 years ago)

Question about how Gimp displays multiple layers

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

Hi all,

I'm working on a gtk application, and I have a need to display a composite image. i.e. a base image, with a 2nd (much smaller) image overlaying a part of the bigger 1st image. Periodically I may need to move the smaller image to a different location within the bigger image.

My first attempt was to use the GtkFixed widget, and put both images into the GtkFixed container. The problem I faced is that GtkFixed will always layer the larger image on top of the smaller image (at least this is my observation, and I cannot figure out how to control the layering order for GtkFixed).

In [minimal] playing around with Gimp, I am aware that Gimp has the ability to create a composite image, out of multiple layers. I'm kinda curious as to the algorithms (pointers to within the code welcome), and whether there are widgets that are more suited to this, rather than the GtkFixed (that I could not get to work for me).

I do not mind loading a pixbuf, and then replacing a designated section of it with the smaller image's pixbuf, if that is what it takes... I cannot figure out from the gtk pixbuf devhelp pages how I might achieve this though.

Any thoughts/comments are most welcome.

Thanks, and best rgds,

- -Greg

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

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)

iD8DBQFH8NCq404fl/0CV/QRAnelAJ42K0vVFIy/4g6u1CCQGTdu+v2buwCbBpIZ 8xUITPrCcFIJqPbMpCu98Ew=
=lmCC
-----END PGP SIGNATURE-----

David Gowers
2008-03-31 16:10:48 UTC (about 17 years ago)

Question about how Gimp displays multiple layers

Hello. I cannot address the issue of widgets. Anyway GIMP does not use widgets to display individual layers, only the final composition, app/display holds the code IIRC(quite a bit of code -- someone else might be able to narrow it down further.). The image is composited and THEN displayed (in one widget). With this sort of display there really is no reason to try to be clever by doing things as confusing as you described. You just need to do the composition (GDK will help you with that) and display the relevant area of it in an expose handler for your display widget.

In short, this reminds me of when I used to make more work for myself by being clever about finding ways to reduce the work I needed to do. Do things the plain way first, try to be clever later if it doesn't work well enough, OK?

On Mon, Mar 31, 2008 at 10:23 PM, Gregory Hosler wrote:

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

Hi all,

I'm working on a gtk application, and I have a need to display a composite image. i.e. a base image, with a 2nd (much smaller) image overlaying a part of the bigger 1st image. Periodically I may need to move the smaller image to a different location within the bigger image.

My first attempt was to use the GtkFixed widget, and put both images into the GtkFixed container. The problem I faced is that GtkFixed will always layer the larger image on top of the smaller image (at least this is my observation, and I cannot figure out how to control the layering order for GtkFixed).

In [minimal] playing around with Gimp, I am aware that Gimp has the ability to create a composite image, out of multiple layers. I'm kinda curious as to the algorithms (pointers to within the code welcome), and whether there are widgets that are more suited to this, rather than the GtkFixed (that I could not get to work for me).

I do not mind loading a pixbuf, and then replacing a designated section of it with the smaller image's pixbuf, if that is what it takes... I cannot figure out from the gtk pixbuf devhelp pages how I might achieve this though.

Any thoughts/comments are most welcome.

Thanks, and best rgds,

- -Greg

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

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)

iD8DBQFH8NCq404fl/0CV/QRAnelAJ42K0vVFIy/4g6u1CCQGTdu+v2buwCbBpIZ 8xUITPrCcFIJqPbMpCu98Ew=
=lmCC
-----END PGP SIGNATURE-----

Bill Skaggs
2008-03-31 17:39:31 UTC (about 17 years ago)

Question about how Gimp displays multiple layers

Gimp handles all this with its own special code, which you most definitely don't want to try to replicate.

There are several ways to handle this. Basically the thing you have to know is that widget drawing happens in response to "expose" events, and what you need to accomplish is to make the large widget ignore exposures that fall within the area of the small widget. When a container, such as GtkFixed, is called upon to handle an expose event, it generates synthetic expose events for each of its children that overlap the exposed area. You will need to replace the "expose handler" for the large widget with a custom-written one that does what you require it to. If you are custom-drawing the large widget, this should be pretty easy -- you just have to avoid doing any drawing in the part that lies within the small widget.

I expect you will find this explanation pretty confusing -- the main thing I am trying to do here is to point you toward "expose" events as the thing you need to read about.

-- Bill

Mukund Sivaraman
2008-04-03 04:31:48 UTC (about 17 years ago)

Question about how Gimp displays multiple layers

Hi Gregory

Gregory Hosler wrote:

I'm working on a gtk application, and I have a need to display a composite image. i.e. a base image, with a 2nd (much smaller) image overlaying a part of the bigger 1st image. Periodically I may need to move the smaller image to a different location within the bigger image.

Have you checked out the source code for gtk-demo? The Pixbuf demo in it seems to be exactly what you described above.

Kind regards,

Mukund