Mercurial > hg > octave-nkf
changeset 17038:db90efd8f32b
image.m: Update to use new __plt_get_axis_arg__ without using "axes" and "newplot" function.
Added an axes handle argument to __img__ so that currentfigure/axes properties
don't have to be changed. Removed unwind_protect block which is not needed any more.
* scripts/image/image.m: Update to use new __plt_get_axis_arg__ without using
"axes" and "newplot" function.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 24 Jul 2013 23:12:28 -0700 |
parents | f694f791709b |
children | 854cfc72c64f |
files | scripts/image/image.m |
diffstat | 1 files changed, 15 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/image/image.m +++ b/scripts/image/image.m @@ -53,7 +53,11 @@ function h = image (varargin) - [ax, varargin, nargin] = __plt_get_axis_arg__ ("image", varargin{:}); + [hax, varargin, nargin] = __plt_get_axis_arg__ ("image", varargin{:}); + + if (isempty (hax)) + hax = gca (); + endif chararg = find (cellfun ("isclass", varargin, "char"), 1, "first"); @@ -71,15 +75,9 @@ img = varargin{3}; chararg = 4; endif - - oldax = gca (); - unwind_protect - axes (ax); - htmp = __img__ (x, y, img, varargin{chararg:end}); - set (ax, "layer", "top"); - unwind_protect_cleanup - axes (oldax); - end_unwind_protect + + htmp = __img__ (hax, x, y, img, varargin{chararg:end}); + set (hax, "layer", "top"); if (nargout > 0) h = htmp; @@ -97,9 +95,7 @@ ## Created: July 1994 ## Adapted-By: jwe -function h = __img__ (x, y, img, varargin) - - newplot (); +function h = __img__ (hax, x, y, img, varargin) if (isempty (img)) error ("__img__: matrix is empty"); @@ -136,9 +132,7 @@ endif endif - ca = gca (); - - htmp = __go_image__ (ca, "cdata", img, "xdata", xdata, "ydata", ydata, + htmp = __go_image__ (hax, "cdata", img, "xdata", xdata, "ydata", ydata, "cdatamapping", "direct", varargin {:}); px = __image_pixel_size__ (htmp); @@ -162,22 +156,22 @@ ## explicitly setting the values here. But then what information is ## available to axes::update_axis_limits to determine that the ## adjustment is necessary? - set (ca, "xlim", xlim, "ylim", ylim); + set (hax, "xlim", xlim, "ylim", ylim); if (ndims (img) == 3) if (isinteger (img)) cls = class (img); mn = intmin (cls); mx = intmax (cls); - set (ca, "clim", double ([mn, mx])); + set (hax, "clim", double ([mn, mx])); endif endif - set (ca, "view", [0, 90]); + set (hax, "view", [0, 90]); - if (strcmp (get (ca, "nextplot"), "replace")) + if (strcmp (get (hax, "nextplot"), "replace")) # Always reverse y-axis for images, unless hold is on - set (ca, "ydir", "reverse"); + set (hax, "ydir", "reverse"); endif if (nargout > 0)