Rechercher une page de manuel
Prima::ImageViewer
Langue: en
Version: 2007-12-21 (debian - 07/07/09)
Section: 3 (Bibliothèques de fonctions)
Sommaire
NAME
Prima::ImageViewer - standard image, icon, and bitmap viewer class.DESCRIPTION
The module contains "Prima::ImageViewer" class, which provides image displaying functionality, including different zoom levels."Prima::ImageViewer" is a descendant of "Prima::ScrollWidget" and inherits its document scrolling behavior and programming interface. See Prima::ScrollWidget for details.
API
Properties
- alignment INTEGER
- One of the following "ta::XXX" constants:
ta::Left ta::Center ta::Right
Selects the horizontal image alignment.
Default value: "ta::Left"
- image OBJECT
- Selects the image object to be displayed. OBJECT can be an instance of "Prima::Image", "Prima::Icon", or "Prima::DeviceBitmap" class.
- imageFile FILE
- Set the image FILE to be loaded and displayed. Is rarely used since does not return a loading success flag.
- quality BOOLEAN
- A boolean flag, selecting if the palette of "image" is to be copied into the widget palette, providing higher visual quality on paletted displays. See also ``palette'' in Prima::Widget.
Default value: 1
- valignment INTEGER
- One of the following "ta::XXX" constants:
ta::Top ta::Middle or ta::Center ta::Bottom
Selects the vertical image alignment.
NB: "ta::Middle" value is not equal to "ta::Center"'s, however the both constants produce equal effect here.
Default value: "ta::Bottom"
- zoom FLOAT
- Selects zoom level for image display. The acceptable value range is between 0.01 and 100. The zoom value is rounded to the closest value divisible by 1/"zoomPrecision". For example, is "zoomPrecision" is 100, the zoom values will be rounded to the precision of hundredth - to fiftieth and twentieth fractional values - .02, .04, .05, .06, .08, and 0.1 . When "zoomPrecision" is 1000, the precision is one thousandth, and so on.
Default value: 1
- zoomPrecision INTEGER
- Zoom precision of "zoom" property. Minimal acceptable value is 10, where zoom will be rounded to 0.2, 0.4, 0.5, 0.6, 0.8 and 1.0 .
The reason behind this arithmetics is that when image of arbitrary zoom factor is requested to be displayed, the image sometimes must begin to be drawn from partial pixel - for example, 10x zoomed image shifted 3 pixels left, must be displayed so the first image pixel from the left occupies 3 screen pixels, and the next ones - 10 screen pixels. That means, that the correct image display routine must ask the system to draw the image ot offset -7 screen pixels. In case of a large image, such negative offsets become large, and the system will behave ineffectively trying to access all image pixels in system memory, slowing the drawing significantly, or in the worst case, failing the request. A workaround is to pre-calculate the zoom factor so that whatever image offset is requested, the negative screen offset will be fixed, and will impose fixed penalty on the system image scaling routine. For example, the default "zoomPrecision" value 100 means that for any given image offset, the screen offset will not exceed 100 pixels, and thus whatever the zoom factor is, the system will internally scale max. screen size / zoom factor + 100 pixels.
These considerations make sense for zoom factors greater than one only, but are applied also to those less than one for the consistency sake.
Default value: 100
Methods
- screen2point X, Y, [ X, Y, ... ]
- Performs translation of integer pairs integers as (X,Y)-points from widget coordinates to pixel offset in image coordinates. Takes in account zoom level, image alignments, and offsets. Returns array of same length as the input.
Useful for determining correspondence, for example, of a mouse event to a image point.
The reverse function is "point2screen".
- point2screen X, Y, [ X, Y, ... ]
- Performs translation of integer pairs as (X,Y)-points from image pixel offset to widget image coordinates. Takes in account zoom level, image alignments, and offsets. Returns array of same length as the input.
Useful for determining a screen location of an image point.
The reverse function is "screen2point".
- watch_load_progress IMAGE
- When called, image viewer watches as the IMAGE is loaded ( see ``load'' in Prima::Image ) and displays the progress. As soon IMAGE begins to load, it replaces the existing "image" property. Example:
$i = Prima::Image-> new; $viewer-> watch_load_progress( $i); $i-> load('huge.jpg'); $viewer-> unwatch_load_progress( $i);
Similar functionality is present in Prima::ImageDialog.
- unwatch_load_progress CLEAR_IMAGE=1
- Stops monitoring of image loading progress. If CLEAR_IMAGE is 0, the leftovers of the incremental loading stay intact in "image" propery. Otherwise, "image" is set to "undef".
- zoom_round ZOOM
- Rounds the zoom factor to "zoomPrecision" precision, returns the rounded zoom value. The algorithm is the same as used internally in "zoom" property.
AUTHOR
Dmitry Karasik, <dmitry@karasik.eu.org>.SEE ALSO
Prima, Prima::Image, Prima::ScrollWidget, Prima::ImageDialog, examples/iv.pl.Contenus ©2006-2024 Benjamin Poulain
Design ©2006-2024 Maxime Vantorre