Mercurial > hg > octave-terminal
changeset 10778:6035bf68a755
Support imread('file', 'frames', 'all') (Feature Request #30365)
author | David Bateman <dbateman@free.fr> |
---|---|
date | Thu, 08 Jul 2010 20:25:17 +0200 |
parents | f2a8f68d9c2b |
children | add87b12e63c |
files | src/ChangeLog src/DLD-FUNCTIONS/__magick_read__.cc |
diffstat | 2 files changed, 32 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2010-07-08 David Bateman <dbateman@free.fr> + + * DLD-FUNCTIONS/__magick_read__,cc (F__magick_read__): Add the syntax + __magick_read__ ("file", "frames", "all"). + 2010-07-08 Rik <octave@nomad.inbox5.com> * DLD_FUNCTIONS/eigs.cc: Initialize random number generator in test
--- a/src/DLD-FUNCTIONS/__magick_read__.cc +++ b/src/DLD-FUNCTIONS/__magick_read__.cc @@ -403,7 +403,7 @@ initialized = true; } - if (args.length () > 2 || args.length () < 1 || ! args(0).is_string () + if (args.length () > 3 || args.length () < 1 || ! args(0).is_string () || nargout > 3) { print_usage (); @@ -411,9 +411,19 @@ } Array<int> frameidx; + bool all_frames = false; if (args.length () == 2 && args(1).is_real_type ()) frameidx = args(1).int_vector_value(); + else if (args.length () == 3 && args(1).is_string () + && args(1).string_value() == "frames") + { + if (args(2).is_string () + && args(2).string_value() == "all") + all_frames = true; + else if (args(2).is_real_type ()) + frameidx = args(2).int_vector_value(); + } else { frameidx = Array<int> (1, 1); @@ -441,16 +451,24 @@ return output; } - for (int i = 0; i < frameidx.length(); i++) + int nframes = imvec.size (); + if (all_frames) { - frameidx(i) = frameidx(i) - 1; + frameidx = Array<int> (1, nframes); + for (int i = 0; i < frameidx.length(); i++) + frameidx(i) = i; + } + else + { + for (int i = 0; i < frameidx.length(); i++) + { + frameidx(i) = frameidx(i) - 1; - int nframes = imvec.size (); - - if (frameidx(i) >= nframes || frameidx(i) < 0) - { - error ("__magick_read__: invalid index vector"); - return output; + if (frameidx(i) >= nframes || frameidx(i) < 0) + { + error ("__magick_read__: invalid index vector"); + return output; + } } }