1Gtk3::ImageView(3) User Contributed Perl Documentation Gtk3::ImageView(3)
2
3
4
6 Gtk3::ImageView - Image viewer widget for Gtk3
7
9 9
10
12 use Gtk3::ImageView;
13 Gtk3->init;
14
15 $window = Gtk3::Window->new();
16
17 $view = Gtk3::ImageView->new;
18 $view->set_pixbuf($pixbuf, TRUE);
19 $window->add($view);
20
21 $window->show_all;
22
24 The Gtk3::ImageView widget allows the user to zoom, pan and select the
25 specified image and provides hooks to allow additional tools, e.g.
26 painter, to be created and used.
27
28 Gtk3::ImageView is a Gtk3 port of Gtk2::ImageView.
29
30 To discuss Gtk3::ImageView or gtk3-perl, ask questions and flame/praise
31 the authors, join gtk-perl-list@gnome.org at lists.gnome.org.
32
34 $view->set_pixbuf( $pixbuf, $zoom_to_fit )
35 Defines the image to view. The optional zoom_to_fit parameter specifies
36 whether to zoom to fit the image or not.
37
38 $view->get_pixbuf
39 Returns the image currently being viewed.
40
41 $view->get_pixbuf_size
42 Returns a hash of containing the size of the current image in width and
43 height keys.
44
45 $view->set_zoom($zoom)
46 Specifies the zoom level.
47
48 $view->get_zoom
49 Returns the current zoom level.
50
51 $view->set_zoom_to_fit($zoom_to_fit, $limit)
52 Specifies whether to zoom to fit or not. If limit is defined, such
53 automatic zoom will not zoom more than it. If the limit is undefined,
54 the previously set limit is used, initially it's unlimited.
55
56 $view->zoom_to_box( $box, $additional_factor )
57 Specifies a box to zoom to, including an additional zoom factor
58
59 $view->zoom_to_selection($context_factor)
60 Zooms to the current selection, plus an addition zoom factor. Shortcut
61 for
62
63 $view->zoom_to_box( $view->get_selection, $context_factor );
64
65 $view->get_zoom_to_fit
66 Returns whether the view is currently zoom to fit or not.
67
68 $view->zoom_in
69 Increases the current zoom by "zoom-step" times (defaults to 2).
70
71 $view->zoom_out
72 Decreases the current zoom by "zoom-step" times (defaults to 2).
73
74 $view->zoom_to_fit
75 Shortcut for
76
77 $view->set_zoom_to_fit(TRUE);
78
79 $view->set_fitting( $value )
80 Shortcut for
81
82 $view->set_zoom_to_fit($value, 1);
83
84 which means that it won't stretch a small image to a large window.
85 Provided (despite the ambiguous name) for compatibility with
86 Gtk2::ImageView.
87
88 $view->set_offset( $x, $y )
89 Set the current view offset (i.e. pan position).
90
91 $view->set_offset
92 Returns the current view offset (i.e. pan position).
93
94 $view->get_viewport
95 Returns a hash containing the position and size of the current
96 viewport.
97
98 $view->set_tool
99 Set the current tool (i.e. mode) - an object of a subclass of
100 "Gtk3::ImageView::Tool".
101
102 Here are some known subclasses of it:
103
104 •
105 "Gtk3::ImageView::Tool::Dragger" allows the image to be dragged when
106 zoomed.
107
108 •
109 "Gtk3::ImageView::Tool::Selector" allows the user to select a
110 rectangular area of the image.
111
112 •
113 "Gtk3::ImageView::Tool::SelectorDragger" selects or drags with
114 different mouse buttons.
115
116 Don't rely too much on how Tool currently interacts with ImageView.
117
118 $view->get_tool
119 Returns the current tool (i.e. mode).
120
121 $view->set_selection($selection)
122 Set the current selection as a hash of position and size.
123
124 $view->get_selection
125 Returns the current selection as a hash of position and size.
126
127 $view->set_resolution_ratio($ratio)
128 Set the ratio of the resolutions in the x and y directions, allowing
129 images with non-square pixels to be correctly displayed.
130
131 $view->get_resolution_ratio
132 Returns the current resolution ratio.
133
134 $view->set_interpolation
135 The interpolation method to use, from "cairo_filter_t"
136 <https://www.cairographics.org/manual/cairo-cairo-pattern-t.html#cairo-
137 filter-t> type. Possible values are lowercase strings like "nearest".
138 To use different interpolation depending on zoom, set it in the
139 "zoom-changed" signal.
140
141 $view->get_interpolation
142 Returns the current interpolation method.
143
148 Porting from Gtk2::ImageView
149 •
150 set_from_pixbuf() was renamed to set_pixbuf() and now its second
151 argument means zoom_to_fit() instead of set_fitting().
152
153 •
154 set_fitting(TRUE) used to be the default, now you need to call it
155 explicitly if you want that behavior. However, once it's called, new
156 calls to set_from_pixbuf() won't reset it, see set_zoom_to_fit() for
157 more details..
158
159 •
160 Drag and drop now can be triggered by subscribing to "dnd-start"
161 signal, and calling "$view->drag_begin_with_coordinates()" from the
162 handler. drag_source_set() won't work.
163
164 •
165 "Gtk2::ImageView::ScrollWin" replacement is not yet implemented.
166
167 •
168 set_transp() is now available through CSS
169 <https://developer.gnome.org/gtk3/stable/chap-css-overview.html>
170 instead, e.g. via
171
172 .imageview.transparent {
173 background-image: url('checkers.svg');
174 }
175
176 •
177 set_interpolation() now accepts "cairo_filter_t"
178 <https://www.cairographics.org/manual/cairo-cairo-pattern-
179 t.html#cairo-filter-t> instead of "GdkInterpType"
180 <https://developer.gnome.org/gdk-pixbuf/stable/gdk-pixbuf-
181 Scaling.html#GdkInterpType>.
182
184 This should be rewritten on C, and Perl bindings should be provided via
185 Glib Object Introspection.
186
188 Jeffrey Ratcliffe, <jffry@posteo.net>
189
190 Alexey Sokolov <sokolov@google.com>
191
193 Copyright (C) 2018--2020 by Jeffrey Ratcliffe
194
195 Copyright (C) 2020 by Google LLC
196
197 Modelled after the GtkImageView C widget by Björn Lindqvist
198 <bjourne@gmail.com>
199
200 This library is free software; you can redistribute it and/or modify it
201 under the same terms as Perl itself, either Perl version 5.8.5 or, at
202 your option, any later version of Perl 5 you may have available.
203
204
205
206perl v5.38.0 2023-07-20 Gtk3::ImageView(3)