]> git.imager.perl.org - imager.git/commitdiff
- i_readraw_wiol() now checks for image creation failure
authorTony Cook <tony@develop=help.com>
Thu, 2 Dec 2004 04:07:27 +0000 (04:07 +0000)
committerTony Cook <tony@develop=help.com>
Thu, 2 Dec 2004 04:07:27 +0000 (04:07 +0000)
- i_readrgb_wiol() now checks for image creation failure
- i_writergb_wiol() was an empty stub, it now pushes an error message
  and explicitly returns failure.
- i_readrgb_wiol() now sets i_format to rgb.
- set i_format to raw when reading tga files and test for it
- document i_format tag

Changes
lib/Imager/ImageTypes.pod
raw.c
rgb.c
t/t103raw.t

diff --git a/Changes b/Changes
index e74e42995d0f5b9880c24b664702e4e410abfda1..f1fb5d6f66cc3036053f3678c4aeda4d10d9d53b 100644 (file)
--- a/Changes
+++ b/Changes
@@ -926,6 +926,13 @@ Revision history for Perl extension Imager.
 - added information on reporting bugs to the SUPPORT section of Imager.pm
 - regops.perl now sorts the dumped data structure to produce minimal diffs
 - quant.c now checks for integer overflow allocating its image data
+- i_readraw_wiol() now checks for image creation failure
+- i_readrgb_wiol() now checks for image creation failure
+- i_writergb_wiol() was an empty stub, it now pushes an error message
+  and explicitly returns failure.
+- i_readrgb_wiol() now sets i_format to rgb.
+- set i_format to raw when reading tga files and test for it
+- document i_format tag
 
 =================================================================
 
index 8f4d7f426d5beb268bdf15d6dc15b39b7fcfbf26..d24333fcd3a81e4d1c8666e8134d245a55cf4450 100644 (file)
@@ -423,11 +423,11 @@ then this is scaled so the smaller value is 72dpi.
 If this tag is present then the whole image could not be read.  This
 isn't implemented for all images yet.
 
-=back
-
-
+=item i_format
 
+The file format this file was read from.
 
+=back
 
 =head2 Quantization options
 
diff --git a/raw.c b/raw.c
index 0d0868b303644326a9d8a939800d2765f0d21016..90eb487b77a5b6fb92c8c427fb72f758332d30e0 100644 (file)
--- a/raw.c
+++ b/raw.c
@@ -65,6 +65,8 @@ i_readraw_wiol(io_glue *ig, int x, int y, int datachannels, int storechannels, i
          ig, x, y, datachannels, storechannels, intrl));
   
   im = i_img_empty_ch(NULL,x,y,storechannels);
+  if (!im)
+    return NULL;
   
   inbuflen = im->xsize*datachannels;
   ilbuflen = inbuflen;
@@ -92,6 +94,9 @@ i_readraw_wiol(io_glue *ig, int x, int y, int datachannels, int storechannels, i
   myfree(inbuffer);
   if (intrl != 0) myfree(ilbuffer);
   if (datachannels != storechannels) myfree(exbuffer);
+
+  i_tags_add(&im->tags, "i_format", 0, "raw", -1, 0);
+
   return im;
 }
 
diff --git a/rgb.c b/rgb.c
index 8941a5017d8b6db811cc7001ec12f8f187646eb8..ae886169b17e735cc7555142da32b510ed0fbc1f 100644 (file)
--- a/rgb.c
+++ b/rgb.c
@@ -226,9 +226,11 @@ i_readrgb_wiol(io_glue *ig, int length) {
   channels = header.zsize;
 
   img = i_img_empty_ch(NULL, width, height, channels);
+  if (!img)
+    return NULL;
   
   i_tags_add(&img->tags, "rgb_namestr", 0, header.name, 80, 0);
-
+  i_tags_add(&img->tags, "i_format", 0, "rgb", -1, 0);
 
   switch (header.storagetype) {
   case 0: /* uncompressed */
@@ -343,6 +345,8 @@ i_readrgb_wiol(io_glue *ig, int length) {
     break;
   }
 
+  i_tags_add(&img->tags, "i_format", 0, "rgb", -1, 0);
+
   i_mempool_destroy(&mp);
   return img;
 
@@ -367,9 +371,9 @@ Writes an image in targa format.  Returns 0 on error.
 
 undef_int
 i_writergb_wiol(i_img *img, io_glue *ig, int wierdpack, int compress, char *idstring, size_t idlen) {
-  
-
-
+  i_clear_error();
+  i_push_error(0, "writing SGI RGB files is not implemented");
 
+  return 0;
 }
 
index 63a45660d3b918a7e3e0fb177c14704954ad218b..5c6ecfe0a1119da39a193cea36a82c6165e79fb4 100644 (file)
@@ -1,5 +1,5 @@
 #!perl -w
-print "1..15\n";
+print "1..16\n";
 use Imager qw(:all);
 use strict;
 init_log("testout/t103raw.log",1);
@@ -137,6 +137,17 @@ print "# difference for virtual image $diff\n";
 $diff and print "not ";
 print "ok 15\n";
 
+# check that i_format is set correctly
+my $index = Imager::i_tags_find($cmpimgmask, 'i_format', 0);
+
+if ($index) {
+  my $value = Imager::i_tags_get($cmpimgmask, $index);
+  print $value eq 'raw' ? "ok 16\n" : "not ok 16 - bad value for i_format tag\n";
+}
+else {
+  print "not ok 16 - no i_format tag set\n";
+}
+
 sub read_test {
   my ($in, $xsize, $ysize, $data, $store, $intrl, $base, $test) = @_;
   open FH, $in or die "Cannot open $in: $!";