From 365ea84296cb88c684922ca92c07cab52ceb8429 Mon Sep 17 00:00:00 2001 From: Tony Cook Date: Sun, 7 Oct 2001 22:46:49 +0000 Subject: [PATCH] added double/sample image support --- Changes | 1 + Imager.pm | 20 +++++++++++++++----- Imager.xs | 6 ++++++ MANIFEST | 2 ++ Makefile.PL | 2 +- datatypes.h | 2 +- image.h | 2 ++ img16.c | 2 ++ t/t021sixteen.t | 2 +- 9 files changed, 31 insertions(+), 8 deletions(-) diff --git a/Changes b/Changes index 68ecdc24..420acd9b 100644 --- a/Changes +++ b/Changes @@ -522,6 +522,7 @@ Revision history for Perl extension Imager. arial.ttf at 14pixels) - Added tga.c to read targa images - Added i_bumpmap_complex to do more accurate bumpmapping + - added an image type with doubles as samples ================================================================= diff --git a/Imager.pm b/Imager.pm index 3ba16cf6..a6231c71 100644 --- a/Imager.pm +++ b/Imager.pm @@ -562,6 +562,9 @@ sub img_set { $self->{IMG} = i_img_pal_new($hsh{xsize}, $hsh{ysize}, $hsh{channels}, $hsh{maxcolors} || 256); } + elsif ($hsh{bits} eq 'double') { + $self->{IMG} = i_img_double_new($hsh{xsize}, $hsh{ysize}, $hsh{channels}); + } elsif ($hsh{bits} == 16) { $self->{IMG} = i_img_16_new($hsh{xsize}, $hsh{ysize}, $hsh{channels}); } @@ -2237,15 +2240,22 @@ Warning: if you draw on a paletted image with colors that aren't in the palette, the image will be internally converted to a normal image. For improved color precision you can use the bits parameter to specify -16 bites per channel: +16 bit per channel: $img = Imager->new(xsize=>200, ysize=>200, channels=>3, bits=>16); -Note that as of this writing all functions should work on 16-bit -images, but at only 8-bit/channel precision. +or for even more precision: + + $img = Imager->new(xsize=>200, ysize=>200, channels=>3, bits=>'double'); + +to get an image that uses a double for each channel. + +Note that as of this writing all functions should work on images with +more than 8-bits/channel, but many will only work at only +8-bit/channel precision. -Currently only 8 and 16/bit per channel image types are available, -this may change later. +Currently only 8-bit, 16-bit, and double per channel image types are +available, this may change later. Color objects are created by calling the Imager::Color->new() method: diff --git a/Imager.xs b/Imager.xs index 17683fc5..b8fe9384 100644 --- a/Imager.xs +++ b/Imager.xs @@ -2788,6 +2788,12 @@ i_img_16_new(x, y, ch) int y int ch +Imager::ImgRaw +i_img_double_new(x, y, ch) + int x + int y + int ch + undef_int i_tags_addn(im, name, code, idata) Imager::ImgRaw im diff --git a/MANIFEST b/MANIFEST index f4d7804d..c9183a2b 100644 --- a/MANIFEST +++ b/MANIFEST @@ -23,6 +23,7 @@ datatypes.h datatypes.c feat.h img16.c +imgdouble.c Implements double/sample images io.c io.h log.c @@ -72,6 +73,7 @@ t/t00basic.t t/t01introvert.t t/t020masked.t t/t021sixteen.t +t/t022double.t Test double/sample images t/t05error.t t/t101jpeg.t t/t102png.t diff --git a/Makefile.PL b/Makefile.PL index b4d2817c..84e9611b 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -63,7 +63,7 @@ if (defined $Config{'d_dlsymun'}) { $OSDEF .= ' -DDLSYMUN'; } filters.o dynaload.o stackmach.o datatypes.o regmach.o trans2.o quant.o error.o convert.o map.o tags.o palimg.o maskimg.o img16.o rotate.o - bmp.o tga.o color.o fills.o); + bmp.o tga.o color.o fills.o imgdouble.o); %opts=( 'NAME' => 'Imager', diff --git a/datatypes.h b/datatypes.h index 78f6398f..13bdbe82 100644 --- a/datatypes.h +++ b/datatypes.h @@ -57,7 +57,7 @@ typedef enum { /* a paletted image might have one bit per sample */ i_8_bits = 8, i_16_bits = 16, - i_double_bits = 64 + i_double_bits = sizeof(double) * 8, } i_img_bits_t; typedef struct { diff --git a/image.h b/image.h index b9a6fa4c..11d83e75 100644 --- a/image.h +++ b/image.h @@ -511,6 +511,8 @@ extern i_img *i_img_masked_new(i_img *targ, i_img *mask, int x, int y, 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_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); #ifdef HAVE_LIBJPEG i_img * diff --git a/img16.c b/img16.c index 3d8f2c5d..3d02b1e9 100644 --- a/img16.c +++ b/img16.c @@ -135,6 +135,8 @@ typedef unsigned short i_sample16_t; =item i_img_16_new(int x, int y, int ch) Creates a new 16-bit per sample image. + +=cut */ i_img *i_img_16_new_low(i_img *im, int x, int y, int ch) { mm_log((1,"i_img_16_new(x %d, y %d, ch %d)\n", x, y, ch)); diff --git a/t/t021sixteen.t b/t/t021sixteen.t index 09a8b5b9..3f55b3fc 100644 --- a/t/t021sixteen.t +++ b/t/t021sixteen.t @@ -7,7 +7,7 @@ use Imager qw(:all :handy); #use Data::Dumper; $loaded = 1; print "ok 1\n"; -init_log("testout/t021sixteen.t", 1); +init_log("testout/t021sixteen.log", 1); use Imager::Color::Float; -- 2.39.5