# HG changeset patch # User Rik # Date 1374732748 25200 # Node ID db90efd8f32b15f5c85937159a10b6a1146c93eb # Parent f694f791709b16e0a708864133fc4e07de65bc29 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. diff -r f694f791709b -r db90efd8f32b scripts/image/image.m --- a/scripts/image/image.m Mon Jul 22 23:45:34 2013 +0200 +++ b/scripts/image/image.m Wed Jul 24 23:12:28 2013 -0700 @@ -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)