- unless ($opts{type} && $opts{type} =~ /^(\d+)bit$/) {
- $self->_set_error('setsamples: type parameter missing or invalid');
- return;
+ 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, $opts{offset}, $width);
+ }
+ elsif ($type eq 'float') {
+ $count = i_psampf($self->{IMG}, $opts{x}, $opts{y}, $opts{channels},
+ $data, $opts{offset}, $width);