]> git.imager.perl.org - imager.git/commitdiff
i_get_file_background[f]?() now return int
authorTony Cook <tony@develop-help.com>
Mon, 16 Apr 2012 09:04:59 +0000 (19:04 +1000)
committerTony Cook <tony@develop-help.com>
Sun, 29 Apr 2012 01:52:55 +0000 (11:52 +1000)
Changes
image.c
imager.h
imexttypes.h
lib/Imager/APIRef.pod

diff --git a/Changes b/Changes
index 53feb27779e4f562c1ee32bd3608a499dfd657f7..1fe7376596a513207eb7210490747cff25441ad3 100644 (file)
--- a/Changes
+++ b/Changes
@@ -66,6 +66,9 @@ Other changes:
 
  - a little more documentation for Imager::Probe.
 
+ - the i_get_file_background() and i_get_file_backgroundf() APIs now
+   return int to indicate whether the i_background tag was found.
+
 Imager 0.89 - 18 Mar 2012
 ===========
 
diff --git a/image.c b/image.c
index 4369bd52da6790a486bd2efff806410a53ef376e..a8045f24f884e845c8a7477293234ad1b9b50eb4 100644 (file)
--- a/image.c
+++ b/image.c
@@ -1728,19 +1728,24 @@ i_img_is_monochrome(i_img *im, int *zero_is_white) {
 
 Retrieve the file write background color tag from the image.
 
-If not present, returns black.
+If not present, C<bg> is set to black.
+
+Returns 1 if the C<i_background> tag was found and valid.
 
 =cut
 */
 
-void
+int
 i_get_file_background(i_img *im, i_color *bg) {
-  if (!i_tags_get_color(&im->tags, "i_background", 0, bg)) {
+  int result = i_tags_get_color(&im->tags, "i_background", 0, bg);
+  if (!result) {
     /* black default */
     bg->channel[0] = bg->channel[1] = bg->channel[2] = 0;
   }
   /* always full alpha */
   bg->channel[3] = 255;
+
+  return result;
 }
 
 /*
@@ -1753,20 +1758,23 @@ floating point color.
 
 Implemented in terms of i_get_file_background().
 
-If not present, returns black.
+If not present, C<bg> is set to black.
+
+Returns 1 if the C<i_background> tag was found and valid.
 
 =cut
 */
 
-void
+int
 i_get_file_backgroundf(i_img *im, i_fcolor *fbg) {
   i_color bg;
-
-  i_get_file_background(im, &bg);
+  int result = i_get_file_background(im, &bg);
   fbg->rgba.r = Sample8ToF(bg.rgba.r);
   fbg->rgba.g = Sample8ToF(bg.rgba.g);
   fbg->rgba.b = Sample8ToF(bg.rgba.b);
   fbg->rgba.a = 1.0;
+
+  return result;
 }
 
 /*
index 66602e3f0f84ba72f75760f51bf4e8dabfe0e7cd..8cb2bfbb4bbacf27705317237b213076a3ebb70b 100644 (file)
--- a/imager.h
+++ b/imager.h
@@ -261,8 +261,8 @@ extern i_img *i_img_double_new(i_img_dim x, i_img_dim y, int ch);
 extern i_img *i_img_to_drgb(i_img *im);
 
 extern int i_img_is_monochrome(i_img *im, int *zero_is_white);
-extern void i_get_file_background(i_img *im, i_color *bg);
-extern void i_get_file_backgroundf(i_img *im, i_fcolor *bg);
+extern int i_get_file_background(i_img *im, i_color *bg);
+extern int i_get_file_backgroundf(i_img *im, i_fcolor *bg);
 
 const char * i_test_format_probe(io_glue *data, int length);
 
index 69836c9ff06576287a89c8e30350486052b6591f..9fd1a0c045c253c57cbac68727a8e231fae534ce 100644 (file)
  Version 4 added i_psamp() and i_psampf() pointers to the i_img
  structure.
 
+ Version 5 changed the return types of i_get_file_background() and
+ i_get_file_backgroundf() from void to int.
+
 */
-#define IMAGER_API_VERSION 4
+#define IMAGER_API_VERSION 5
 
 /*
  IMAGER_API_LEVEL is the level of the structure.  New function pointers
@@ -175,8 +178,8 @@ typedef struct {
                      int out_channels, i_color const * bg);
   int (*f_i_gsampf_bg)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fsample_t *samples,
                      int out_channels, i_fcolor const * bg);
-  void (*f_i_get_file_background)(i_img *im, i_color *bg);
-  void (*f_i_get_file_backgroundf)(i_img *im, i_fcolor *bg);
+  int (*f_i_get_file_background)(i_img *im, i_color *bg);
+  int (*f_i_get_file_backgroundf)(i_img *im, i_fcolor *bg);
   unsigned long (*f_i_utf8_advance)(char const **p, size_t *len);
   i_render *(*f_i_render_new)(i_img *im, i_img_dim width);
   void (*f_i_render_delete)(i_render *r);
@@ -215,7 +218,7 @@ typedef struct {
   void (*f_io_glue_destroy)(i_io_glue_t *ig);
 
   /* IMAGER_API_LEVEL 8 functions will be added here */
-  
+
 } im_ext_funcs;
 
 #define PERL_FUNCTION_TABLE_NAME "Imager::__ext_func_table"
index 0d28ad720455d58a80df63f976d374c9bd68c9e8..87fcfa9f4b45db1425428ea8157a1c3bbe59273c 100644 (file)
@@ -905,7 +905,9 @@ From: File error.c
 
 Retrieve the file write background color tag from the image.
 
-If not present, returns black.
+If not present, C<bg> is set to black.
+
+Returns 1 if the C<i_background> tag was found and valid.
 
 
 =for comment
@@ -919,7 +921,9 @@ floating point color.
 
 Implemented in terms of i_get_file_background().
 
-If not present, returns black.
+If not present, C<bg> is set to black.
+
+Returns 1 if the C<i_background> tag was found and valid.
 
 
 =for comment