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
| function im2paint()
if exist(fullfile(getenv('windir'), 'system32', 'mspaint.exe'), 'file')~=2
error('Paint not found');
end
fig = figure;
ax = axes('parent', fig);
[filename, pathname] = uigetfile({'*.*';'*.png';'*.jpg';'*.bmp';'*.gif'});
if ~filename
return
end
I = imread(fullfile(pathname, filename));
image(I, 'Parent', ax);
axis(ax, 'image', 'off')
uicontrol(fig, 'String', '=> Paint', ...
'Callback', @copytopaint);
end
function copytopaint(obj, event)
h = findobj('type', 'image');
if isempty(h)
return
end
C = get(h, 'cdata');
imwrite(C, fullfile(tempdir, 'image.bmp'), 'bmp')
cmd = sprintf('%s %s', ...
fullfile(getenv('windir'), 'system32', 'mspaint'), ...
fullfile(tempdir, 'image.bmp'));
system(cmd)
end |
Partager