Mercurial > octave-antonio
changeset 19962:2e7497ff2535
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.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 18 Mar 2015 11:30:07 -0700 |
parents | 7f44ced38646 |
children | 8ba35b7b355d |
files | scripts/image/image.m |
diffstat | 1 files changed, 13 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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