+ my $type = $opts{type};
+ defined $type or $type = '8bit';
+
+ my $width = defined $opts{width} ? $opts{width}
+ : $self->getwidth() - $opts{x};
+
+ my $count;
+ if ($type eq '8bit') {
+ $count = i_psamp($self->{IMG}, $opts{x}, $opts{y}, $opts{channels},
+ $_[$data_index], $opts{offset}, $width);
+ }
+ elsif ($type eq 'float') {
+ $count = i_psampf($self->{IMG}, $opts{x}, $opts{y}, $opts{channels},
+ $_[$data_index], $opts{offset}, $width);
+ }
+ elsif ($type =~ /^([0-9]+)bit$/) {
+ my $bits = $1;
+
+ unless (ref $_[$data_index]) {
+ $self->_set_error("setsamples: data must be an array ref for type not 8bit or float");
+ return;
+ }
+
+ $count = i_psamp_bits($self->{IMG}, $opts{x}, $opts{y}, $bits,
+ $opts{channels}, $_[$data_index], $opts{offset},
+ $width);
+ }
+ else {
+ $self->_set_error('setsamples: type parameter invalid');
+ return;