Mercurial > octave-antonio
comparison libinterp/dldfcn/__magick_read__.cc @ 16944:1b3b3ee88284
Add optional extension argument to image IO functions.
* imfinfo.m, private/core_imfinfo.m, imread.m, private/core_imread.m,
imwrite.m: added support for optional EXT argument.
* imwrite.m: in addition to support the extra EXT argument, removed list
of supported image formats from help text, and suggested to use
imformats() instead.
* private/core_imwrite.m: remove usage of __magick_format_list__() which
is being replaced by imformats(). Check validity of colormap earlier on.
Removed tests that are repeated in imwrite.m (leftovers from copying
the file).
* private/imageIO.m: deal with separate filename and extension and ignore
file existence checking if we are writing.
* __magic_read__.cc: remove private function __magick_format_list__()
that was only being used by core_imwrite.m and is being replaced by
imformats().
author | Carnë Draug <carandraug@octave.org> |
---|---|
date | Wed, 10 Jul 2013 18:18:21 +0100 |
parents | 5c25f7ed080c |
children | 4660d047955e |
comparison
equal
deleted
inserted
replaced
16943:0dab17e69a55 | 16944:1b3b3ee88284 |
---|---|
1204 | 1204 |
1205 /* | 1205 /* |
1206 ## No test needed for internal helper function. | 1206 ## No test needed for internal helper function. |
1207 %!assert (1) | 1207 %!assert (1) |
1208 */ | 1208 */ |
1209 | |
1210 // Determine the file formats supported by GraphicsMagick. This is | |
1211 // called once at the beginning of imread or imwrite to determine | |
1212 // exactly which file formats are supported, so error messages can be | |
1213 // displayed properly. | |
1214 | |
1215 DEFUN_DLD (__magick_format_list__, args, , | |
1216 "-*- texinfo -*-\n\ | |
1217 @deftypefn {Loadable Function} {} __magick_format_list__ (@var{formats})\n\ | |
1218 Undocumented internal function.\n\ | |
1219 @end deftypefn") | |
1220 { | |
1221 octave_value retval; | |
1222 | |
1223 #ifdef HAVE_MAGICK | |
1224 maybe_initialize_magick (); | |
1225 | |
1226 std::list<std::string> accepted_formats; | |
1227 | |
1228 if (args.length () == 1) | |
1229 { | |
1230 Cell c = args (0).cell_value (); | |
1231 | |
1232 if (! error_state) | |
1233 { | |
1234 for (octave_idx_type i = 0; i < c.nelem (); i++) | |
1235 { | |
1236 try | |
1237 { | |
1238 std::string fmt = c.elem (i).string_value (); | |
1239 | |
1240 Magick::CoderInfo info(fmt); | |
1241 | |
1242 if (info.isReadable () && info.isWritable ()) | |
1243 accepted_formats.push_back (fmt); | |
1244 } | |
1245 catch (Magick::Exception& e) | |
1246 { | |
1247 // Do nothing: exception here are simply missing formats. | |
1248 } | |
1249 } | |
1250 } | |
1251 else | |
1252 error ("__magick_format_list__: expecting a cell array of image format names"); | |
1253 } | |
1254 else | |
1255 print_usage (); | |
1256 | |
1257 retval = Cell (accepted_formats); | |
1258 | |
1259 #else | |
1260 | |
1261 error ("__magick_format_list__: not available in this version of Octave"); | |
1262 | |
1263 #endif | |
1264 | |
1265 return retval; | |
1266 } | |
1267 | |
1268 /* | |
1269 ## No test needed for internal helper function. | |
1270 %!assert (1) | |
1271 */ |