Gtk3::ImageView(3)
π¦ Gtk3::ImageView(3) β the Perl doc page, bestie edition
okay so this is a User Contributed Perl Documentation page for Gtk3::ImageView(3), and I'm gonna walk you through it like we're on FaceTime at 1am π
π NAME
Gtk3::ImageView β an image viewer widget for Gtk3. that's it, that's the vibe π
β¨ VERSION
9 β yes queen, version nine π
πΈ SYNOPSIS
here's the lil starter pack, copy it exactly:
use Gtk3::ImageView;
Gtk3->init;
$window = Gtk3::Window->new();
$view = Gtk3::ImageView->new;
$view->set_pixbuf($pixbuf, TRUE);
$window->add($view);
$window->show_all;
likeβ¦ window, view, pixbuf, show it. slay π«Ά
π§ DESCRIPTION
so the Gtk3::ImageView widget lets the user zoom, pan, and select the specified image, and it gives you hooks so you can build extra tools on top β like a painter, for example π¨ literally choose your own adventure.
Gtk3::ImageView is a Gtk3 port of Gtk2::ImageView. glow-up era π
and if you wanna discuss Gtk3::ImageView or gtk3-perl, ask questions, or flame/praise the authors (π not the flame part), come join gtk-perl-list@gnome.org at lists.gnome.org. it's giving community π«Ά
β SUBROUTINES/METHODS
π $view->set_pixbuf( $pixbuf, $zoom_to_fit )
defines the image to view, periodt. the optional zoom_to_fit parameter says whether to zoom to fit the image or not β that's the whole thing π
π $view->get_pixbuf
returns the image currently being viewed. the main character, returned to you πΈ
π $view->get_pixbuf_size
returns a hash containing the size of the current image, in width and height keys. dimensions, bestie π¦
π $view->set_zoom($zoom)
specifies the zoom level π
π $view->get_zoom
returns the current zoom level π
π $view->set_zoom_to_fit($zoom_to_fit, $limit)
specifies whether to zoom to fit or not. if limit is defined, such automatic zoom will not zoom more than it. if the limit is undefined, the previously set limit is used β and initially it's unlimited π
π $view->zoom_to_box( $box, $additional_factor )
specifies a box to zoom to, including an additional zoom factor π¦β¨
π $view->zoom_to_selection($context_factor)
zooms to the current selection, plus an additional zoom factor (yes, the spelling in the original is addition, I'm keeping it π«Ά). it's a shortcut for:
$view->zoom_to_box( $view->get_selection, $context_factor );
π $view->get_zoom_to_fit
returns whether the view is currently zoom to fit or not β
π $view->zoom_in
increases the current zoom by "zoom-step" times (defaults to 2) ππ₯
π $view->zoom_out
decreases the current zoom by "zoom-step" times (defaults to 2) ππ
π $view->zoom_to_fit
shortcut for:
$view->set_zoom_to_fit(TRUE);
π $view->set_fitting( $value )
shortcut for:
$view->set_zoom_to_fit($value, 1);
which means that it won't stretch a small image to a large window πΌοΈ no catfishing the pixels. it's provided (despite the ambiguous name β yes we know, the name is doing the most π) for compatibility with Gtk2::ImageView.
π $view->set_offset( $x, $y )
set the current view offset (i.e. pan position) πΉοΈ
π $view->set_offset
returns the current view offset (i.e. pan position). nope, that's genuinely what the page says β same name as the one above, but this one returns it. I'm just the messenger π
π $view->get_viewport
returns a hash containing the position and size of the current viewport πͺ
π $view->set_tool
set the current tool (i.e. mode) β an object of a subclass of "Gtk3::ImageView::Tool" π οΈ
here are some known subclasses of it:
"Gtk3::ImageView::Tool::Dragger"lets the image be dragged when zoomed π€"Gtk3::ImageView::Tool::Selector"lets the user select a rectangular area of the image π²"Gtk3::ImageView::Tool::SelectorDragger"selects or drags with different mouse buttons π±οΈ
β οΈ don't rely too much on how Tool currently interacts with ImageView. it's giving "situationship" β don't get attached π
π $view->get_tool
returns the current tool (i.e. mode) π οΈ
π $view->set_selection($selection)
set the current selection as a hash of position and size βοΈ
π $view->get_selection
returns the current selection as a hash of position and size βοΈ
π $view->set_resolution_ratio($ratio)
set the ratio of the resolutions in the x and y directions, letting images with non-square pixels be correctly displayed π kinda iconic of it honestly
π $view->get_resolution_ratio
returns the current resolution ratio π
π $view->set_interpolation
the interpolation method to use, from "cairo_filter_t" type (link in the original: https://www.cairographics.org/manual/cairo-cairo-pattern-t.html#cairo-filter-t). possible values are lowercase strings like "nearest" π€. to use different interpolation depending on zoom, set it in the "zoom-changed" signal π‘
π $view->get_interpolation
returns the current interpolation method π€
π DIAGNOSTICS
(empty in the original β nothing listed here, bestie. we move π«Ά)
π CONFIGURATION AND ENVIRONMENT
(also empty. no config, no env vars. minimalism β¨)
π DEPENDENCIES
(nothing listed either. wild, I know π)
π INCOMPATIBILITIES
π§΅ Porting from Gtk2::ImageView
okay listen, if you're coming from the Gtk2 era, here's the whole lore drop π:
set_from_pixbuf()was renamed toset_pixbuf(), and now its second argument meanszoom_to_fit()instead ofset_fitting()πset_fitting(TRUE)used to be the default; now you need to call it explicitly if you want that behavior. however, once it's called, new calls toset_from_pixbuf()won't reset it β seeset_zoom_to_fit()for more details π (and yeah, the original sentence ends with two periods. leaving it exactly as it is π«‘)- drag and drop can now be triggered by subscribing to the
"dnd-start"signal, and calling"$view->drag_begin_with_coordinates()"from the handler.drag_source_set()won't work π« - the
"Gtk2::ImageView::ScrollWin"replacement is not yet implemented π patience, bestie set_transp()is now available through CSS instead (link in the original:https://developer.gnome.org/gtk3/stable/chap-css-overview.html), e.g. via:
.imageview.transparent {
background-image: url('checkers.svg');
}
set_interpolation()now accepts"cairo_filter_t"(link in the original:https://www.cairographics.org/manual/cairo-cairo-pattern-t.html#cairo-filter-t) instead of"GdkInterpType"(link in the original:https://developer.gnome.org/gdk-pixbuf/stable/gdk-pixbuf-Scaling.html#GdkInterpType) ποΈ
π BUGS AND LIMITATIONS
and I quote: this should be rewritten in C, and Perl bindings should be provided via Glib Object Introspection π the author said "we need a rewrite" and honestly? respect for the honesty, no cap π₯
π AUTHOR
- Jeffrey Ratcliffe,
<jffry@posteo.net>π«Ά - Alexey Sokolov
<sokolov@google.com>π«Ά
π LICENSE AND COPYRIGHT
Copyright (C) 2018--2020 by Jeffrey Ratcliffe
Copyright (C) 2020 by Google LLC
modelled after the GtkImageView C widget by BjΓΆrn Lindqvist <bjourne@gmail.com> πΈ
this library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available β¨
aaaand that's the whole page, bestie π this was perl v5.42.0, dated 2024-10-13, and it's the Gtk3::ImageView(3) manual page β ily, go zoom some pixels ππ¦π
π¦ where this page comes from
- opensuse-leap 16.0: perl-Gtk3-ImageView 12.0.0-bp160.1.11 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms