# HG changeset patch # User Carnë Draug # Date 1373675597 -3600 # Node ID 4660d047955e21ed170fcb8afba688ad3c6268c9 # Parent badc46a0a2307a451c6c81bef84e1c51391720ab 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++. diff -r badc46a0a230 -r 4660d047955e libinterp/dldfcn/__magick_read__.cc --- a/libinterp/dldfcn/__magick_read__.cc Sun Jul 14 08:12:53 2013 -0700 +++ b/libinterp/dldfcn/__magick_read__.cc Sat Jul 13 01:33:17 2013 +0100 @@ -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; }