Mercurial > hg > octave-lyh
changeset 16983:4660d047955e
Make use of gripe_disabled_feature() for image IO functions.
* __magick_read__.cc: use gripe_disabled_feature() instead of error()
to fail due to missing features. Comment code instead of CPP "#if 0".
Enclose maybe_initialize_magick() in the more general #ifdef HAVE_MAGICK.
It was the only function outside it, instead having a separate condition
inside the function causing a warning about empty function in systems
without Magick++.
author | Carnë Draug <carandraug+dev@gmail.com> |
---|---|
date | Sat, 13 Jul 2013 01:33:17 +0100 |
parents | badc46a0a230 |
children | 997efb8d0b19 |
files | libinterp/dldfcn/__magick_read__.cc |
diffstat | 1 files changed, 25 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/dldfcn/__magick_read__.cc +++ b/libinterp/dldfcn/__magick_read__.cc @@ -151,21 +151,19 @@ switch (type) { case Magick::PaletteMatteType: -#if 0 - warning ("palettematte"); - Matrix map (mapsize, 3); - Matrix alpha (mapsize, 1); - for (i = 0; i < mapsize; i++) - { - warning ("%d", i); - Magick::ColorRGB c = imvec[0].colorMap (i); - map(i,0) = c.red (); - map(i,1) = c.green (); - map(i,2) = c.blue (); - alpha(i,1) = c.alpha (); - } - break; -#endif +// warning ("palettematte"); +// Matrix map (mapsize, 3); +// Matrix alpha (mapsize, 1); +// for (i = 0; i < mapsize; i++) +// { +// warning ("%d", i); +// Magick::ColorRGB c = imvec[0].colorMap (i); +// map(i,0) = c.red (); +// map(i,1) = c.green (); +// map(i,2) = c.blue (); +// alpha(i,1) = c.alpha (); +// } +// break; case Magick::PaletteType: alpha = Matrix (0, 0); @@ -372,13 +370,9 @@ return retval; } -#endif - static void maybe_initialize_magick (void) { -#ifdef HAVE_MAGICK - static bool initialized = false; if (! initialized) @@ -400,8 +394,8 @@ initialized = true; } +} #endif -} DEFUN_DLD (__magick_read__, args, nargout, "-*- texinfo -*-\n\ @@ -415,7 +409,9 @@ { octave_value_list output; -#ifdef HAVE_MAGICK +#ifndef HAVE_MAGICK + gripe_disabled_feature ("imread", "Image IO"); +#else maybe_initialize_magick (); @@ -525,12 +521,8 @@ error ("__magick_read__: image depths greater than 16-bit are not supported"); } } -#else - - error ("imread: image reading capabilities were disabled when Octave was compiled"); #endif - return output; } @@ -882,7 +874,10 @@ { octave_value_list retval; -#ifdef HAVE_MAGICK +#ifndef HAVE_MAGICK + gripe_disabled_feature ("imwrite", "Image IO"); +#else + maybe_initialize_magick (); int nargin = args.length (); @@ -915,13 +910,9 @@ } else print_usage (); -#else - - error ("__magick_write__: not available in this version of Octave"); #endif - -return retval; + return retval; } /* @@ -1017,7 +1008,9 @@ { octave_value retval; -#ifdef HAVE_MAGICK +#ifndef HAVE_MAGICK + gripe_disabled_feature ("imfinfo", "Image IO"); +#else maybe_initialize_magick (); @@ -1137,13 +1130,7 @@ error ("Magick++ exception: %s", e.what ()); return retval; } - -#else - - error ("imfinfo: not available in this version of Octave"); - #endif - return retval; }