/usr/share/freemat/toolbox/graph/zoom.m is in freemat-data 4.0-5build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | % ZOOM ZOOM Image Zoom Function
%
% Usage
%
% This function changes the zoom factor associated with the currently active
% image. It is a legacy support function only, and thus is not quite equivalent
% to the zoom function from previous versions of FreeMat. However, it should
% achieve roughly the same effect. The generic syntax for its use is
%
% zoom(x)
%
% where x is the zoom factor to be used. The exact behavior of the zoom
% factor is as follows:
% - x>0 The image is zoomed by a factor x in both directions.
%
% - x=0 The image on display is zoomed to fit the size of the image window, but
% the aspect ratio of the image is not changed. (see the Examples section for
% more details). This is the default zoom level for images displayed with the
% image command.
%
% - x<0 The image on display is zoomed to fit the size of the image window, with
% the zoom factor in the row and column directions chosen to fill the entire window.
% The aspect ratio of the image is not preserved. The exact value of x is
% irrelevant.
%
% Copyright (c) 2002-2006 Samit Basu
% Licensed under the GPL
function zoom(factor)
% Get the current axis handle
ax = gca;
% It should contain an image object
imhan = get_image_child(ax);
if (isempty(imhan)) return; end;
% Get the size of the image objects Cdata
C = get(imhan,'cdata');
newsize = size(C);
if (factor > 0)
newsize = newsize * factor;
elseif (factor == 0)
axis image;
return;
elseif (factor < 0)
axis normal;
return;
end
% Get the axis position vector
position = get(ax,'position');
new_width = newsize(2)/position(3);
new_height = newsize(1)/position(4);
sizefig(new_width,new_height);
function handle = get_image_child(ax)
children = get(ax,'children');
handle = [];
for i=1:numel(children)
if (ishandle(children(i),'image'))
handle = children(i);
return;
end
end
|