- Added tga.c to read targa images
- Added i_bumpmap_complex to do more accurate bumpmapping
- added an image type with doubles as samples
+ - change i_copy() and i_sametype() to handle double/sample images
=================================================================
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 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.
myfree(pv);
}
else {
- /* currently the only other depth is 16 */
i_fcolor *pv;
- i_img_16_new_low(im, x1, y1, src->channels);
+ if (src->bits == i_16_bits)
+ i_img_16_new_low(im, x1, y1, src->channels);
+ else if (src->bits == i_double_bits)
+ i_img_double_new_low(im, x1, y1, src->channels);
+ else {
+ fprintf(stderr, "i_copy(): Unknown image bit size %d\n", src->bits);
+ return; /* I dunno */
+ }
+
pv = mymalloc(sizeof(i_fcolor) * x1);
for (y = 0; y < y1; ++y) {
i_glinf(src, 0, x1, y, pv);
if (src->bits == 8) {
return i_img_empty_ch(NULL, xsize, ysize, src->channels);
}
- else if (src->bits == 16) {
+ else if (src->bits == i_16_bits) {
return i_img_16_new(xsize, ysize, src->channels);
}
+ else if (src->bits == i_double_bits) {
+ return i_img_double_new(xsize, ysize, src->channels);
+ }
else {
i_push_error(0, "Unknown image bits");
return NULL;
#!perl -w
use strict;
-BEGIN { $| = 1; print "1..29\n"; }
+BEGIN { $| = 1; print "1..30\n"; }
my $loaded;
END {print "not ok 1\n" unless $loaded;}
use Imager qw(:all :handy);
ok(4, Imager::i_img_virtual($im_g) == 0,
"1 channel image thinks it is virtual");
my $double_bits = length(pack("d", 1)) * 8;
+print "# $double_bits double bits\n";
ok(5, Imager::i_img_bits($im_g) == $double_bits,
"1 channel image has bits != $double_bits");
ok(6, Imager::i_img_type($im_g) == 0, "1 channel image isn't direct");
($redf) x 20, ($greenf) x 60, ($redf) x 20);
# basic OO tests
-my $oo16img = Imager->new(xsize=>200, ysize=>201, bits=>16)
- or print "not ";
-print "ok 28\n";
-$oo16img->bits == 16 or print "not ";
-print "ok 29\n";
+my $ooimg = Imager->new(xsize=>200, ysize=>201, bits=>'double');
+ok(28, $ooimg, "couldn't make double image");
+ok(29, $ooimg->bits eq 'double', "oo didn't give double image");
+# check that the image is copied correctly
+my $oocopy = $ooimg->copy;
+ok(30, $oocopy->bits eq 'double', "oo copy didn't give double image");
sub NCF {
return Imager::Color::Float->new(@_);