Permalink
Browse files

i_get_file_background[f]?() now return int

  • Loading branch information...
1 parent c2545c8 commit 594f59333231e26596aa23418531c0e71bd8fc22 @tonycoz committed Apr 16, 2012
Showing with 33 additions and 15 deletions.
  1. +3 −0 Changes
  2. +15 −7 image.c
  3. +2 −2 imager.h
  4. +7 −4 imexttypes.h
  5. +6 −2 lib/Imager/APIRef.pod
View
@@ -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
===========
View
22 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;
}
/*
View
@@ -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);
View
@@ -22,8 +22,11 @@
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"
View
@@ -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

0 comments on commit 594f593

Please sign in to comment.