Mercurial > octave-nkf
comparison scripts/image/image.m @ 19997: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 | 4197fc428c7d |
children | 7503499a252b |
comparison
equal
deleted
inserted
replaced
19996:7f44ced38646 | 19997:2e7497ff2535 |
---|---|
170 endif | 170 endif |
171 endif | 171 endif |
172 | 172 |
173 endif # ! isempty (img) | 173 endif # ! isempty (img) |
174 | 174 |
175 h = __go_image__ (hax, "cdata", img, "xdata", xdata, "ydata", ydata, | |
176 "cdatamapping", "direct", varargin{:}); | |
177 | |
178 if (do_new && ! ishold (hax)) | 175 if (do_new && ! ishold (hax)) |
179 ## Set axis properties for new images | 176 ## Set axis properties for new images |
180 | 177 ## NOTE: Do this before calling __go_image__ so that image is not drawn |
178 ## once with default auto-scale axis limits and then a second time | |
179 ## with tight axis limits. | |
181 if (! isempty (img)) | 180 if (! isempty (img)) |
182 if (isscalar (get (hax, "children"))) | 181 if (isempty (get (hax, "children"))) |
183 axis (hax, "tight"); | 182 axis (hax, "tight"); |
184 endif | 183 endif |
185 | 184 |
186 if (ndims (img) == 3) | 185 if (ndims (img) == 3) |
187 if (isinteger (img)) | 186 if (isinteger (img)) |
195 endif # ! isempty (img) | 194 endif # ! isempty (img) |
196 | 195 |
197 set (hax, "view", [0, 90], "ydir", "reverse", "layer", "top"); | 196 set (hax, "view", [0, 90], "ydir", "reverse", "layer", "top"); |
198 | 197 |
199 endif # do_new | 198 endif # do_new |
199 | |
200 h = __go_image__ (hax, "cdata", img, "xdata", xdata, "ydata", ydata, | |
201 "cdatamapping", "direct", varargin{:}); | |
202 | |
203 if (do_new && ! ishold (hax) && ! isempty (img) | |
204 && isscalar (get (hax, "children"))) | |
205 ## Re-scale axis limits for an image in a new figure or axis. | |
206 axis (hax, "tight"); | |
207 endif | |
200 | 208 |
201 endfunction | 209 endfunction |
202 | 210 |
203 | 211 |
204 %!demo | 212 %!demo |