]> git.imager.perl.org - imager.git/blobdiff - lib/Imager/Draw.pod
- corrected a reference leak where writing GIFs would leak memory.
[imager.git] / lib / Imager / Draw.pod
index 3daa9fe9d1b2bad0d9b6539029c87a49a94ae821..60ac552e86de837b618994f8baa4736c260dca80 100644 (file)
@@ -823,7 +823,7 @@ done with convert too:
 
 =item getscanline
 
-Read all or part of a horizonatal line of pixels from an image.  This
+Read all or part of a horizontal line of pixels from an image.  This
 method is most useful in conjunction with L</setscanline>.
 
 The parameters you can pass are:
@@ -922,11 +922,22 @@ type - the type of sample data to return.  Default: C<8bit>.
 
 Permited values are C<8bit> and C<float>.
 
+As of Imager 0.61 this can be C<16bit> only for 16 bit images.
+
 =item *
 
 channels - a reference to an array of channels to return, where 0 is
 the first channel.  Default: C< [ 0 .. $self->getchannels()-1 ] >
 
+=item *
+
+target - if an array reference is supplied in target then the samples
+will be stored here instead of being returned.
+
+=item *
+
+offset - the offset within the array referenced by I<target>
+
 =back
 
 In list context this will return a list of integers between 0 and 255
@@ -937,6 +948,9 @@ In scalar context this will return a string of packed bytes, as with
 C< pack("C*", ...) > when I<type> is C<8bit> or a string of packed
 doubles as with C< pack("d*", ...) > when I<type> is C<float>.
 
+If the I<target> option is supplied then only a count of samples is
+returned.
+
 Example: Check if any pixels in an image have a non-zero alpha
 channel:
 
@@ -960,6 +974,59 @@ Example: Convert a 2 channel grey image into a 4 channel RGBA image:
     $out->setscanline(y=>$y, pixels=>$data);
   }
 
+Retrieve 16-bit samples:
+
+  if ($img->bits == 16) {
+    my @samples;
+    $img->getsamples(x => 0, y => $y, target => \@samples, type => '16bit');
+  }
+
+=item setsamples
+
+This allows writing of samples back to some images.  Currently this is
+only supported for 16-bit/sample images.
+
+Parameters:
+
+=over
+
+=item *
+
+y - vertical position of the scanline.  This parameter is required.
+
+=item *
+
+x - position to start on the scanline.  Default: 0
+
+=item *
+
+width - number of pixels to write.  Default: $img->getwidth - x.  The
+minimum of this and the number of pixels represented by the samples
+provided will be written.
+
+=item *
+
+type - the type of sample data to write.  This parameter is required.
+
+As of Imager 0.61 this can only be C<16bit> only for 16 bit images.
+
+=item *
+
+channels - a reference to an array of channels to return, where 0 is
+the first channel.  Default: C< [ 0 .. $self->getchannels()-1 ] >
+
+=item *
+
+data - a reference to an array of samples to write.  Required.
+
+=item *
+
+offset - the starting offset within the array referenced by I<data>
+
+=back
+
+Returns the number of samples written.
+
 =back
 
 =head1 Packed Color Data
@@ -993,9 +1060,94 @@ color indexes, not sample values:
   my $packed_index_data = pack("C*", $black_index, $red_index);
   $im->setscanline(y => $y, pixels => $packed_index_data, type => 'index');
 
+=head1 Combine Types
+
+Some methods accept a C<combine> parameter, this can be any of the
+following:
+
+=over
+
+=item none
+
+The fill pixel replaces the target pixel.
+
+=item normal
+
+The fill pixels alpha value is used to combine it with the target pixel.
+
+=item multiply
+
+=item mult
+
+Each channel of fill and target is multiplied, and the result is
+combined using the alpha channel of the fill pixel.
+
+=item dissolve
+
+If the alpha of the fill pixel is greater than a random number, the
+fill pixel is alpha combined with the target pixel.
+
+=item add
+
+The channels of the fill and target are added together, clamped to the range of the samples and alpha combined with the target.
+
+=item subtract
+
+The channels of the fill are subtracted from the target, clamped to be
+>= 0, and alpha combined with the target.
+
+=item diff
+
+The channels of the fill are subtracted from the target and the
+absolute value taken this is alpha combined with the target.
+
+=item lighten
+
+The higher value is taken from each channel of the fill and target
+pixels, which is then alpha combined with the target.
+
+=item darken
+
+The higher value is taken from each channel of the fill and target
+pixels, which is then alpha combined with the target.
+
+=item hue
+
+The combination of the saturation and value of the target is combined
+with the hue of the fill pixel, and is then alpha combined with the
+target.
+
+=item sat
+
+The combination of the hue and value of the target is combined
+with the saturation of the fill pixel, and is then alpha combined with the
+target.
+
+=item value
+
+The combination of the hue and value of the target is combined
+with the value of the fill pixel, and is then alpha combined with the
+target.
+
+=item color
+
+The combination of the value of the target is combined with the hue
+and saturation of the fill pixel, and is then alpha combined with the
+target.
+
+=back
+
+=over
+
+=item combines
+
+Returns a list of possible combine types.
+
+=back
+
 =head1 BUGS
 
-box, arc, do not support antialiasing yet.  Arc, is only filled as of
+box() does not support antialiasing yet.  Arc, is only filled as of
 yet.  Default color is not unified yet.
 
 =head1 AUTHOR