$self->{IMG} = i_img_pal_new($hsh{xsize}, $hsh{ysize}, $hsh{channels},
$hsh{maxcolors} || 256);
}
+ elsif ($hsh{bits} eq 'double') {
+ $self->{IMG} = i_img_double_new($hsh{xsize}, $hsh{ysize}, $hsh{channels});
+ }
elsif ($hsh{bits} == 16) {
$self->{IMG} = i_img_16_new($hsh{xsize}, $hsh{ysize}, $hsh{channels});
}
sub bits {
my $self = shift;
- $self->{IMG} and i_img_bits($self->{IMG});
+ my $bits = $self->{IMG} && i_img_bits($self->{IMG});
+ if ($bits && $bits == length(pack("d", 1)) * 8) {
+ $bits = 'double';
+ }
+ $bits;
}
sub type {
the palette, the image will be internally converted to a normal image.
For improved color precision you can use the bits parameter to specify
-16 bites per channel:
+16 bit per channel:
$img = Imager->new(xsize=>200, ysize=>200, channels=>3, bits=>16);
-Note that as of this writing all functions should work on 16-bit
-images, but at only 8-bit/channel precision.
+or for even more precision:
+
+ $img = Imager->new(xsize=>200, ysize=>200, channels=>3, bits=>'double');
-Currently only 8 and 16/bit per channel image types are available,
-this may change later.
+to get an image that uses a double for each channel.
+
+Note that as of this writing all functions should work on images with
+more than 8-bits/channel, but many will only work at only
+8-bit/channel precision.
+
+Currently only 8-bit, 16-bit, and double per channel image types are
+available, this may change later.
Color objects are created by calling the Imager::Color->new()
method:
}
The bits() method retrieves the number of bits used to represent each
-channel in a pixel, typically 8. The type() method returns either
+channel in a pixel, 8 for a normal image, 16 for 16-bit image and
+'double' for a double/channel image. The type() method returns either
'direct' for truecolor images or 'paletted' for paletted images. The
virtual() method returns non-zero if the image contains no actual
pixels, for example masked images.
=head2 Rotating images
-Use the rotate() method to rotate an image.
+Use the rotate() method to rotate an image. This method will return a
+new, rotated image.
To rotate by an exact amount in degrees or radians, use the 'degrees'
or 'radians' parameter:
my $rot20 = $img->rotate(degrees=>20);
my $rotpi4 = $img->rotate(radians=>3.14159265/4);
+Exact image rotation uses the same underlying transformation engine as
+the matrix_transform() method.
+
To rotate in steps of 90 degrees, use the 'right' parameter:
my $rotated = $img->rotate(right=>270);