1Gtk2::ImageView(3)    User Contributed Perl Documentation   Gtk2::ImageView(3)
2
3
4

NAME

6       Gtk2::ImageView -  General purpose image viewer for Gtk+
7

SYNOPSIS

9        use Gtk2::ImageView;
10        Gtk2->init;
11
12        $window = Gtk2::Window->new();
13
14        $view = Gtk2::ImageView->new;
15        $view->set_pixbuf($pixbuf, TRUE);
16        $window->add($view);
17
18        $window->show_all;
19

DESCRIPTION

21       GtkImageView is a full-featured general purpose image viewer widget for
22       GTK.  It provides a scrollable, zoomable pane in which a pixbuf can be
23       displayed.
24
25       The Gtk2::ImageView module allows a perl developer to use the
26       GtkImageView Widget.
27

HIERARCHY

29         Glib::Object
30         +----Glib::InitiallyUnowned
31              +----Gtk2::Object
32                   +----Gtk2::Widget
33                        +----Gtk2::ImageView
34

INTERFACES

36         Glib::Object::_Unregistered::AtkImplementorIface
37         Gtk2::Buildable
38

METHODS

40   widget or undef = Gtk2::ImageView->new
41       Returns a new Gtk2::ImageView with the following default values.
42
43       black bg : FALSE
44       fitting : TRUE
45       image tool : a Gtk2::ImageView::Tool::Dragger instance
46       interpolation mode : GDK_INTERP_BILINEAR
47       offset : (0, 0)
48       pixbuf : NULL
49       show cursor: TRUE
50       show frame : TRUE
51       transp : GTK_IMAGE_TRANSP_GRID
52       zoom : 1.0
53
54   boolean = $view->get_black_bg
55       Returns TRUE if the view renders the widget on a black background,
56       otherwise FALSE.
57
58   $view->set_black_bg ($black_bg)
59       •   $black_bg (boolean)
60
61       If TRUE, the view uses a black background. If FALSE, the view uses the
62       default (normally gray) background.
63
64       The default value is FALSE.
65
66   list = $view->get_check_colors
67       Reads the two colors used to draw transparent parts of images with an
68       alpha channel. Note that if the transp setting of the view is
69       GTK_IMAGE_TRANSP_BACKGROUND or GTK_IMAGE_TRANSP_COLOR, then both colors
70       will be equal.
71
72   $view->damage_pixels ($rect)
73       •   $rect (Gtk2::Gdk::Rectangle)
74
75       Mark the pixels in the rectangle as damaged. That the pixels are
76       damaged means that they have been modified and that the view must
77       redraw them to ensure that the visible part of the image corresponds to
78       the pixels in that image. Calling this method emits the
79       ::pixbuf-changed signal.
80
81       This method must be used when modifying the image data:
82
83           // Drawing something cool in the area 20,20 - 60,60 here...
84           ...
85           // And force an update
86           $view->damage_pixels (Gtk2::Gdk::Rectangle->new(20, 20, 40, 40);
87
88       If the whole pixbuf has been modified then rect should be NULL to
89       indicate that a total update is needed.
90
91       See also gtk_image_view_set_pixbuf().
92
93       view : a Gtk2::ImageView
94       view : a Gtk2::Gdk::Rectangle in image space coordinates to mark as
95       damaged or NULL, to mark the whole pixbuf as damaged.
96
97   rectangle = $view->get_draw_rect
98       Get the rectangle in the widget where the pixbuf is painted, or undef
99       if the view is not allocated or has no pixbuf.
100
101       For example, if the widgets allocated size is 100, 100 and the pixbufs
102       size is 50, 50 and the zoom factor is 1.0, then the pixbuf will be
103       drawn centered on the widget. rect will then be (25,25)-[50,50].
104
105       This method is useful when converting from widget to image or zoom
106       space coordinates.
107
108   boolean = $view->get_fitting
109       Returns TRUE if the view fits the image, FALSE otherwise.
110
111   $view->set_fitting ($fitting)
112       •   $fitting (boolean)
113
114       Sets whether to fit or not. If TRUE, then the view will adapt the zoom
115       so that the whole pixbuf is visible.
116
117       Setting the fitting causes the widget to immediately repaint itself.
118
119       Fitting is by default TRUE.
120
121       view : a Gtk2::ImageView
122       fitting : whether to fit the image or not
123
124   rectangle = $view->image_to_widget_rect ($rect_in)
125       •   $rect_in (Gtk2::Gdk::Rectangle)
126
127       Converts a rectangle in image space coordinates to widget space
128       coordinates.  If the view is not realized, or if it contains no pixbuf,
129       then the conversion was unsuccessful, FALSE is returned and rect_out is
130       left unmodified.
131
132       Note that this function may return a rectangle that is not visible on
133       the widget.
134
135   interptype = $view->get_interpolation
136       Returns the current interpolation mode of the view.
137
138   $view->set_interpolation ($interp)
139       •   $interp (Gtk2::Gdk::InterpType)
140
141       Sets the interpolation mode of how the view. GDK_INTERP_HYPER is the
142       slowest, but produces the best results. GDK_INTERP_NEAREST is the
143       fastest, but provides bad rendering quality. GDK_INTERP_BILINEAR is a
144       good compromise.
145
146       Setting the interpolation mode causes the widget to immidiately repaint
147       itself.
148
149       The default interpolation mode is GDK_INTERP_BILINEAR.
150
151       view : a Gtk2::ImageView
152       interp : The Gtk2::Gdk::InterpType to use. One of GDK_INTERP_NEAREST,
153       GDK_INTERP_BILINEAR and GDK_INTERP_HYPER.
154
155   string = Gtk2::ImageView->library_version
156       Returns the version of the underlying GtkImageView C library
157
158   $view->set_offset ($x, $y, $invalidate=FALSE)
159       •   $x (double)
160
161       •   $y (double)
162
163       •   $invalidate (boolean)
164
165       Sets the offset of where in the image the GtkImageView should begin
166       displaying image data.
167
168       The offset is clamped so that it will never cause the GtkImageView to
169       display pixels outside the pixbuf. Setting this attribute causes the
170       widget to repaint itself if it is realized.
171
172       If invalidate is TRUE, the views entire area will be invalidated
173       instead of redrawn immidiately. The view is then queued for redraw,
174       which means that additional operations can be performed on it before it
175       is redrawn.
176
177       The difference can sometimes be important like when you are overlaying
178       data and get flicker or artifacts when setting the offset. If that
179       happens, setting invalidate to TRUE could fix the problem. See the
180       source code to GtkImageToolSelector for an example.
181
182       Normally, invalidate should always be FALSE because it is much faster
183       to repaint immidately than invalidating.
184
185       view : a Gtk2::ImageView
186       x : X-component of the offset in zoom space coordinates.
187       y : Y-component of the offset in zoom space coordinates.
188       invalidate : whether to invalidate the view or redraw immediately,
189       default=FALSE.
190
191   pixbuf or undef = $view->get_pixbuf
192       Returns the pixbuf this view shows.
193
194   $view->set_pixbuf ($pixbuf, $reset_fit=TRUE)
195       •   $pixbuf (Gtk2::Gdk::Pixbuf or undef)
196
197       •   $reset_fit (boolean)
198
199       Sets the pixbuf to display, or NULL to not display any pixbuf.
200       Normally, reset_fit should be TRUE which enables fitting. Which means
201       that, initially, the whole pixbuf will be shown.
202
203       Sometimes, the fit mode should not be reset. For example, if
204       GtkImageView is showing an animation, it would be bad to reset the fit
205       mode for each new frame.  The parameter should then be FALSE which
206       leaves the fit mode of the view untouched.
207
208       This method should not be used if merely the contents of the pixbuf has
209       changed.  See gtk_image_view_damage_pixels() for that.
210
211       If reset_fit is TRUE, the zoom-changed signal is emitted, otherwise
212       not. The pixbuf-changed signal is also emitted.
213
214       The default pixbuf is NULL.
215
216       view : a Gtk2::ImageView
217       pixbuf : The pixbuf to display.
218       reset_fit : Whether to reset fitting or not.
219
220   boolean = $view->get_show_cursor
221       Returns TRUE if the cursor is shown when the mouse is over the widget,
222       otherwise FALSE.
223
224   $view->set_show_cursor ($show_cursor)
225       •   $show_cursor (boolean)
226
227       Sets whether to show the mouse cursor when the mouse is over the widget
228       or not.  Hiding the cursor is useful when the widget is fullscreened.
229
230       The default value is TRUE.
231
232       view : a Gtk2::ImageView
233       show_cursor : whether to show the cursor or not
234
235   boolean = $view->get_show_frame
236       Returns TRUE if a one pixel frame is drawn around the pixbuf, otherwise
237       FALSE.
238
239   $view->set_show_frame ($show_frame)
240       •   $show_frame (boolean)
241
242       Sets whether to draw a frame around the image or not. When TRUE, a one
243       pixel wide frame is shown around the image. Setting this attribute
244       causes the widget to immediately repaint itself.
245
246       The default value is TRUE.
247
248   tool = $view->get_tool
249       Returns the currently bound image tool
250
251   $view->set_tool ($tool)
252       •   $tool (Gtk2::ImageView::Tool)
253
254       Set the image tool to use. If the new tool is the same as the current
255       tool, then nothing will be done. Otherwise
256       Gtk2::ImageView::Tool::pixbuf_changed() is called so that the tool has
257       a chance to generate initial data for the pixbuf.
258
259       Setting the tool causes the widget to immediately repaint itself.
260
261       The default image tool is a Gtk2::ImageView::Tool::Dragger instance.
262       See also Gtk2::ImageView::Tool.
263
264       view : a Gtk2::ImageView
265       tool : The image tool to use (must not be NULL)
266
267   $view->set_transp ($transp, $transp_color=0x000000)
268       •   $transp (Gtk2::ImageView::Transp)
269
270       •   $transp_color (integer)
271
272       Sets how the view should draw transparent parts of images with an alpha
273       channel.  If transp is GTK_IMAGE_TRANSP_COLOR, the specified color will
274       be used. Otherwise the transp_color argument is ignored. If it is
275       GTK_IMAGE_TRANSP_BACKGROUND, the background color of the widget will be
276       used. If it is GTK_IMAGE_TRANSP_GRID, then a grid with light and dark
277       gray boxes will be drawn on the transparent parts.
278
279       Calling this method causes the widget to immediately repaint. It also
280       causes the pixbuf-changed signal to be emitted. This is done so that
281       other widgets (such as GtkImageNav) will have a chance to render a view
282       of the pixbuf with the new transparency settings.
283
284       view : a Gtk2::ImageView
285       transp : The Gtk2::ImageView::Transp to use when drawing transparent
286       images, default GTK_IMAGE_TRANSP_GRID.
287       transp_color : Color to use when drawing transparent images, default
288       0x000000.
289
290   rectangle = $view->get_viewport
291       Returns a rectangle with the current viewport. If pixbuf is NULL or
292       there is no viewport, undef is returned.
293
294       The current viewport is defined as the rectangle, in zoomspace
295       coordinates as the area of the loaded pixbuf the Gtk2::ImageView is
296       currently showing.
297
298   double = $view->get_zoom
299       Get the current zoom factor of the view.
300
301   $view->zoom_in
302       Zoom in the view one step. Calling this method causes the widget to
303       immediately repaint itself.
304
305       view : a Gtk2::ImageView
306
307   $view->zoom_out
308       Zoom out the view one step. Calling this method causes the widget to
309       immediately repaint itself.
310
311       view : a Gtk2::ImageView
312
313   $view->set_zoom ($zoom)
314       •   $zoom (double)
315
316       Sets the zoom of the view.
317
318       Fitting is always disabled after this method has run. The zoom-changed
319       signal is unconditionally emitted.
320
321       view : a Gtk2::ImageView
322       zoom : the new zoom factor
323

SIGNALS

325       mouse-wheel-scroll (Gtk2::ImageView, Gtk2::Gdk::ScrollDirection)
326       pixbuf-changed (Gtk2::ImageView)
327       scroll (Gtk2::ImageView, Gtk2::ScrollType, Gtk2::ScrollType)
328       set-fitting (Gtk2::ImageView, integer)
329       set-scroll-adjustments (Gtk2::ImageView, Gtk2::Adjustment,
330       Gtk2::Adjustment)
331       set-zoom (Gtk2::ImageView, double)
332       zoom-changed (Gtk2::ImageView)
333       zoom-in (Gtk2::ImageView)
334       zoom-out (Gtk2::ImageView)
335

ENUMS AND FLAGS

337   enum Gtk2::Gdk::InterpType
338       •   'nearest' / 'GDK_INTERP_NEAREST'
339
340       •   'tiles' / 'GDK_INTERP_TILES'
341
342       •   'bilinear' / 'GDK_INTERP_BILINEAR'
343
344       •   'hyper' / 'GDK_INTERP_HYPER'
345
346   enum Gtk2::Gdk::ScrollDirection
347       •   'up' / 'GDK_SCROLL_UP'
348
349       •   'down' / 'GDK_SCROLL_DOWN'
350
351       •   'left' / 'GDK_SCROLL_LEFT'
352
353       •   'right' / 'GDK_SCROLL_RIGHT'
354
355   enum Gtk2::ImageView::Transp
356       •   'color' / 'GTK_IMAGE_TRANSP_COLOR'
357
358       •   'background' / 'GTK_IMAGE_TRANSP_BACKGROUND'
359
360       •   'grid' / 'GTK_IMAGE_TRANSP_GRID'
361
362   enum Gtk2::ScrollType
363       •   'none' / 'GTK_SCROLL_NONE'
364
365       •   'jump' / 'GTK_SCROLL_JUMP'
366
367       •   'step-backward' / 'GTK_SCROLL_STEP_BACKWARD'
368
369       •   'step-forward' / 'GTK_SCROLL_STEP_FORWARD'
370
371       •   'page-backward' / 'GTK_SCROLL_PAGE_BACKWARD'
372
373       •   'page-forward' / 'GTK_SCROLL_PAGE_FORWARD'
374
375       •   'step-up' / 'GTK_SCROLL_STEP_UP'
376
377       •   'step-down' / 'GTK_SCROLL_STEP_DOWN'
378
379       •   'page-up' / 'GTK_SCROLL_PAGE_UP'
380
381       •   'page-down' / 'GTK_SCROLL_PAGE_DOWN'
382
383       •   'step-left' / 'GTK_SCROLL_STEP_LEFT'
384
385       •   'step-right' / 'GTK_SCROLL_STEP_RIGHT'
386
387       •   'page-left' / 'GTK_SCROLL_PAGE_LEFT'
388
389       •   'page-right' / 'GTK_SCROLL_PAGE_RIGHT'
390
391       •   'start' / 'GTK_SCROLL_START'
392
393       •   'end' / 'GTK_SCROLL_END'
394

SEE ALSO

396       GtkImageView Reference Manual at http://trac.bjourne.webfactional.com/
397
398       perl(1), Glib(3pm), Gtk2(3pm), Gtk2::ImageViewer - an alternative image
399       viewer widget.
400

AUTHOR

402       Jeffrey Ratcliffe <Jeffrey dot Ratcliffe at gmail dot com>, with
403       patches from muppet <scott at asofyet dot org>, Torsten Schoenfeld
404       <kaffetisch at web dot de> and Emanuele Bassi <ebassi at gmail dot com>
405       Kevin Ryde <user42 at zip.com.au>
406
407       The DESCRIPTION section of this page is adapted from the documentation
408       of GtkImageView.
409
411       Copyright (c) 2007 -- 2008 by Jeffrey Ratcliffe
412       <Jeffrey.Ratcliffe@gmail.com> see AUTHORS for complete list of
413       contributors
414
415       This library is free software; you can redistribute it and/or modify it
416       under the terms of the GNU Lesser General Public License as published
417       by the Free Software Foundation; either version 3 of the License, or
418       (at your option) any later version.
419
420       This library is distributed in the hope that it will be useful, but
421       WITHOUT ANY WARRANTY; without even the implied warranty of
422       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
423       Library General Public License for more details.
424
425       You should have received a copy of the GNU Lesser General Public
426       License along with this program.  If not, see
427       <http://www.gnu.org/licenses/>.
428
430       Copyright (C) 2007 by Jeffrey Ratcliffe.
431
432       This software is licensed under the GPL-3; see Gtk2::ImageView for a
433       full notice.
434
435
436
437perl v5.32.1                      2021-01-27                Gtk2::ImageView(3)
Impressum