Prima
view release on metacpan or search on metacpan
pod/Prima/Image.pod view on Meta::CPAN
with support of more than 1 pixel).
Fills empty pixels with optional fill color.
Resulting images can be 1 pixel too wide due to horizontal shearing applied
twice, where in worst cases 1 pixel from the original image can take 3
horizontal pixels on the result.
=item save (FILENAME or FILEGLOB), [ %PARAMETERS ]
Stores image data into image file FILENAME or stream FILEGLOB, and returns the success flag.
The semantics of C<save()> is extensive, and can be influenced by
PARAMETERS hash. If error occurs, C<$@> variable
contains error description string.
Note that when saving to a stream, C<codecID> must be explicitly given in C<%PARAMETERS>.
See L<Prima::image-load> for details.
NB! When saving to streams on win32, mind C<binmode>.
=item save_stream BASE64_STRING, %OPTIONS
Saves image into a datastream and return it encoded in base64.
Unless C<$OPTIONS{codecID}> or C<$image->{extras}->{codecID}> is set, tries to find the best codec for the job.
Returns encoded content on success, or C<undef> on failure; C<$@> is set in the latter case.
=item scanline Y
Returns a scanline from Y in the same raw format as C<data>
=item shear X, Y
Applies shearing to the image. If the shearing is needed only for one axis, set
shear factor for the other one to zero.
=item convert_to_icon $MASK_DEPTH, $MASK_TEMPLATE
Creates an icon from image, with C<$MASK_DEPTH> integer (can be either 1 or 8),
and $C<$MASK_TEMPLATE> scalar used for newly populate mask.
=item to_rgba TYPE=undef
Creates a new icon with type set to 24 or 8 gray bits and mask type to 8 bit.
If TYPE is set, uses this type instead.
=item to_region
Creates a new L<Prima::Region> object with the image as the data source.
=item transform matrix => [a,b,c,d,x,y], [ fill => color ]
Applies generic 2D transform matrix to the image, fills empty pixels with
optional fill color.
Required option C<matrix> should point to an array of 6 float numbers,
where these represent a standard 3x2 matrix for 2D transformation, f ex a
C<Prima::matrix> object.
Tries first to split matrix into series of shear and scale transforms using LDU
decomposition; if an interim image is calculated to be too large, fails and
returns C<false>.
The last two members (X and Y translation) only use mantissa and ignore the
rest, so setting them f ex to 10.5 will not produce an image 11 pixels larger,
but only 1. The translation is thus effectively sub-pixel.
Rotation matrices can be applied too, however, when angles are close to 90 and
270, either interim images become too big, or defects introduced by shearing
become too visible. Therefore the method specifically detects for rotation
cases, and uses Paeth rotation algorithm instead, which yields better results.
Also, if the angle is detected to be 90, 180, or 270 degrees, fast pixel
flipping is used.
Eventual resampling can be controlled by C<scaling> property.
=item ui_scale %OPTIONS
Resizes the image with smooth scaling. Understands C<zoom> and C<scaling>
options. The C<zoom> default value is the one in C<< $::application->uiScaling >>,
the C<scaling> default value is C<ist::Quadratic> .
See also: L<Application/uiScaling>
=back
=head2 Prima::Image events
C<Prima::Image>-specific events occur only from inside L<load> call, to report
image loading progress. Not all codecs (currently JPEG,PNG,TIFF only) are able
to report the progress to the caller. See L<Prima::image-load/"Loading with
progress indicator"> for details, L<Prima::ImageViewer/watch_load_progress> and
L<Prima::Dialog::ImageDialog/load> for suggested use.
=over
=item HeaderReady EXTRAS
Called whenever image header is read, and image dimensions and pixel type
is changed accordingly to accommodate image data.
C<EXTRAS> is the hash to be stored later in C<{extras}> key on the object.
=item DataReady X, Y, WIDTH, HEIGHT
Called whenever image data that cover area designated by X,Y,WIDTH,HEIGHT
is acquired. Use C<load> option C<eventDelay> to limit the rate of C<DataReady>
event.
=back
=head2 Prima::Icon methods
=over
=item alpha ALPHA <X1, Y1, X2, Y2>
Same as C<Drawable::alpha> but can be used also outside of the paint state.
=item combine DATA, MASK
( run in 0.704 second using v1.01-cache-2.11-cpan-71847e10f99 )