NAME

Prima::Dialog::ImageDialog - image file open and save dialogs

DESCRIPTION

The module provides standard dialogs specially adjusted for image loading and saving.

Prima::Dialog::ImageOpenDialog

Provides a preview widget, allowing the user to view the image file before loading, and the selection of a frame index for the multi-framed image files. Instead of the execute call, the load method is used to invoke the dialog and returns the loaded image as a Prima::Image object. The loaded object contains the {extras} hash with the file and image information filled by the loader. See Prima::image-load for more information.

SYNOPSIS

        use Prima qw(Application Dialog::ImageDialog);
        my $dlg = Prima::Dialog::ImageOpenDialog-> new;
        my $img = $dlg-> load;
        return unless $img;
        print "$_:$img->{extras}->{$_}\n" for sort keys %{$img-> {extras}};

Properties

preview BOOLEAN

Selects if the preview functionality is active. The user can switch it on and off interactively.

Default value: 1

Methods

load %PROFILE

Executes the dialog, and, if successful, loads the image file and frame selected by the user. Returns the loaded image as a Prima::Image object. PROFILE is a hash, passed to the Prima::Image::load method. In particular, it can be used to disable the default loading of extra information in the {extras} hash variable or to specify a non-default loading option. For example, {extras}->{className} = 'Prima::Icon' would return the loaded image as an icon object. See Prima::image-load for more.

load can report the progress of the image loading to the caller, and/or to an instance of Prima::ImageViewer, if desired. If either (or both) onHeaderReady and onDataReady notifications are specified, these are called from the respective event handlers of the image being loaded ( see "Loading with progress indicator" in Prima::image-load for details). If the profile key progressViewer is supplied, its value is treated as a Prima::ImageViewer instance, and it is used to display the loading progress. See "watch_load_progress" in Prima::ImageViewer.

Events

HeaderReady IMAGE

See "HeaderReady" in Prima::Image.

DataReady IMAGE, X, Y, WIDTH, HEIGHT

See "DataReady" in Prima::Image.

Prima::Dialog::ImageSaveDialog

Provides the standard image save dialog where the user can select the desired image format, the bit depth, and other format-specific options. The format-specific options can be set if a dialog for the file format is provided by the toolkit. The standard toolkit dialogs reside under the Prima::Image namespace, in the Prima/Image subdirectory. For example, Prima::Image::gif provides the selection of a transparent color, and Prima::Image::jpeg provides the image quality control. If the image passed to the image property contains the {extras} hash variable, its data are used as the default values. In particular, the {extras}->{codecID} field, responsible for the file format, affects the default file format selection.

SYNOPSIS

        my $dlg = Prima::Dialog::ImageSaveDialog-> new;
        return unless $dlg-> save( $image );
        print "saved as ", $dlg-> fileName, "\n";

Properties

image IMAGE

Selects the image to be saved. The property is to be used for the standard invocation of dialog, via the execute method. It is not needed when the execution and saving are invoked via the save method.

Methods

save IMAGE, %PROFILE

Invokes the dialog, and, if the execution is successful, saves the IMAGE according to the user selection and PROFILE hash. PROFILE is not used as a source of the default options, but is passed directly to the Prima::Image::save call, possibly overriding the selection of the user.

Returns 1 on success, 0 on error. If the error occurs, the user is notified before the method returns.

AUTHOR

Dmitry Karasik, <dmitry@karasik.eu.org>.

SEE ALSO

Prima, Prima::Window, Prima::codecs, Prima::image-load, Prima::Image, Prima::Dialog::FileDialog, Prima::ImageViewer, examples/iv.pl.