This site has been retired. For up to date information, see handbook.gnome.org or gitlab.gnome.org.


[Home] [TitleIndex] [WordIndex

GtkImageView

ToDo

The Google Summer of Code is over and the widget is not 100% done. Current TODO items:

GtkImageView is supposed to be a widget to present an image to the user. Features include gestures to rotate/scale the image, different zoom modes (see below), etc.

Relevant bug report in Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=726490

API

GtkImageView is a GtkWidget subclass and implements GtkScrollable.

There are currently 3 zoom modes:

So, these seem to be weird to me. When using FIT, setting the scale property manually doesn'y make sense*, because the "output" size, i.e. the size we draw the image in is determined by the widget allocation. So NONE would be "use the scale property to determine the output size (and nothing else), but make sure the final image can be seen, so set the minimum size to the output size". However, that's exactly what ORIGINAL is, except for the part that ORIGINAL never cares about the scale property. So on closer inspection, it seems like it makes sense to reduce that to 2 zoom modes and use ORIGINAL for "I want to zoom in or out but keep the widget at the output size".

OTOH none of these make sense for e.g. eog, which tries to keep the image at the window size (i.e. FIT) until the user zooms in/out, in which case the image can take any size (i.e. ORIGINAL).

Also, when rotating using gestures, the corners of the rotated image should probably be cut off, which none of the zoom modes do currently (maybe do that using a property?)

Of course now ORIGINAL should maybe be renamed to something else.

* How to handle? Just print a warning and don't set the scale?

Constructors:

Loading:

Properties:

Signals:

Additional Use Cases

  1. gnome-photos uses gegl to apply filters, etc. to the image, then lets gegl draw its buffer on a cairo_surface. So it'd need to pass just that cairo_surface to GtkImageView. Theoretically this is possible right now using the prepare-image signal, but you'd still need to load an image in the correct size so GtkImageView creates the appropriate cairo_surface.

  2. In addition to 1), gegl can use mipmap based rendering when scaling the image down, but in that case we need information about in which size we will draw the surface (in the prepare-image signal).
  3. Cropping isn't doable using cairo surfaces. One way to implement it is to take the GdkPixbuf and gdk_pixbuf_copy_area a part from it, then set it on the GtkImageView again (needs setter for the pixbuf, unless we want the user to create a GMemoryInputStream for the pixbuf, etc.). gnome-photos however uses (read: will use) gegl to crop, then draws its buffer on the cairo_surface again, etc.

  4. Additionally, rishi wants to draw the cropping UI (a simple rectangle probably) directly on the surface.

Open Questions


2024-10-23 11:37