OUTPUT:
RETVAL
-void
+undef_int
i_gaussian(im,stdev)
Imager::ImgRaw im
- float stdev
+ double stdev
void
i_unsharp_mask(im,stdev,scale)
int y
int ch
+Imager::ImgRaw
+i_img_to_rgb16(im)
+ Imager::ImgRaw im
+
Imager::ImgRaw
i_img_double_new(x, y, ch)
int x
/* image processing functions */
-void i_gaussian (i_img *im,float stdev);
+int i_gaussian (i_img *im, double stdev);
void i_conv (i_img *im,const float *coeff,int len);
void i_unsharp_mask(i_img *im, double stddev, double scale);
int w, int h);
extern i_img *i_img_16_new(int x, int y, int ch);
extern i_img *i_img_16_new_low(i_img *im, int x, int y, int ch);
+extern i_img *i_img_to_rgb16(i_img *im);
extern i_img *i_img_double_new(int x, int y, int ch);
extern i_img *i_img_double_new_low(i_img *im, int x, int y, int ch);
return im;
}
+/*
+=item i_img_to_rgb16(im)
+
+=category Image creation
+
+Returns a 16-bit/sample version of the supplied image.
+
+Returns the image on success, or NULL on failure.
+
+=cut
+*/
+
+i_img *
+i_img_to_rgb16(i_img *im) {
+ i_img *targ;
+ i_fcolor *line;
+ int y;
+
+ targ = i_img_16_new(im->xsize, im->ysize, im->channels);
+ if (!targ)
+ return NULL;
+ line = mymalloc(sizeof(i_fcolor) * im->xsize);
+ for (y = 0; y < im->ysize; ++y) {
+ i_glinf(im, 0, im->xsize, y, line);
+ i_plinf(targ, 0, im->xsize, y, line);
+ }
+
+ myfree(line);
+
+ return targ;
+}
+
static int i_ppix_d16(i_img *im, int x, int y, const i_color *val) {
int off, ch;
require Exporter;
use vars qw(@ISA @EXPORT_OK);
@ISA = qw(Exporter);
-@EXPORT_OK = qw(diff_text_with_nul test_image_raw test_image_16 is_color3 is_color1 is_image);
+@EXPORT_OK = qw(diff_text_with_nul test_image_raw test_image_16 test_image is_color3 is_color1 is_image is_image_similar);
sub diff_text_with_nul {
my ($desc, $text1, $text2, @params) = @_;
$img;
}
+sub test_image {
+ my $green = Imager::Color->new(0, 255, 0, 255);
+ my $blue = Imager::Color->new(0, 0, 255, 255);
+ my $red = Imager::Color->new(255, 0, 0, 255);
+ my $img = Imager->new(xsize => 150, ysize => 150);
+ $img->box(filled => 1, color => $green, box => [ 70, 25, 130, 125 ]);
+ $img->box(filled => 1, color => $blue, box => [ 20, 25, 80, 125 ]);
+ $img->arc(x => 75, y => 75, r => 30, color => $red);
+ $img->filter(type => 'conv', coef => [ 0.1, 0.2, 0.4, 0.2, 0.1 ]);
+
+ $img;
+}
+
sub test_image_16 {
my $green = Imager::Color->new(0, 255, 0, 255);
my $blue = Imager::Color->new(0, 0, 255, 255);
$img;
}
-sub is_image($$$) {
- my ($left, $right, $comment) = @_;
+sub is_image_similar($$$$) {
+ my ($left, $right, $limit, $comment) = @_;
my $builder = Test::Builder->new;
return;
}
my $diff = Imager::i_img_diff($left->{IMG}, $right->{IMG});
- unless ($diff == 0) {
+ if ($diff > $limit) {
$builder->ok(0, $comment);
- $builder->diag("image data different - $diff");
+ $builder->diag("image data difference > $limit - $diff");
return;
}
return $builder->ok(1, $comment);
}
+sub is_image($$$) {
+ my ($left, $right, $comment) = @_;
+
+ local $Test::Builder::Level = $Test::Builder::Level + 1;
+
+ return is_image_similar($left, $right, 0, $comment);
+}
+
+
1;
__END__
#!perl -w
use strict;
-use Test::More tests => 85;
+use Test::More tests => 87;
BEGIN { use_ok(Imager=>qw(:all :handy)) }
require "t/testtools.pl";
use Imager::Color::Float;
+use Imager::Test qw(test_image is_image);
my $im_g = Imager::i_img_16_new(100, 101, 1);
mask_tests($im, 1.0/65535);
}
+
+{ # convert to rgb16
+ my $im = test_image();
+ my $im16 = $im->to_rgb16;
+ print "# check conversion to 16 bit\n";
+ is($im16->bits, 16, "check bits");
+ is_image($im, $im16, "check image data matches");
+}