# HG changeset patch # User Rik # Date 1426703407 25200 # Node ID 2e7497ff25356d9acd24b4a286dad2a306aa235c # Parent 7f44ced38646e28116466e22cfb370201c7270aa image.m: Don't draw new image object twice for performance (bug #44567). * image.m: Set up axis values before calling __go_image__. Run 'axis tight' after creating image object only if this is a new object. diff -r 7f44ced38646 -r 2e7497ff2535 scripts/image/image.m --- a/scripts/image/image.m Wed Mar 18 13:25:25 2015 -0400 +++ b/scripts/image/image.m Wed Mar 18 11:30:07 2015 -0700 @@ -172,14 +172,13 @@ endif # ! isempty (img) - h = __go_image__ (hax, "cdata", img, "xdata", xdata, "ydata", ydata, - "cdatamapping", "direct", varargin{:}); - if (do_new && ! ishold (hax)) ## Set axis properties for new images - + ## NOTE: Do this before calling __go_image__ so that image is not drawn + ## once with default auto-scale axis limits and then a second time + ## with tight axis limits. if (! isempty (img)) - if (isscalar (get (hax, "children"))) + if (isempty (get (hax, "children"))) axis (hax, "tight"); endif @@ -198,6 +197,15 @@ endif # do_new + h = __go_image__ (hax, "cdata", img, "xdata", xdata, "ydata", ydata, + "cdatamapping", "direct", varargin{:}); + + if (do_new && ! ishold (hax) && ! isempty (img) + && isscalar (get (hax, "children"))) + ## Re-scale axis limits for an image in a new figure or axis. + axis (hax, "tight"); + endif + endfunction