Save an image snapshot of a GUI
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I have created a GUI which enables a user to load an image. This image is then displayed in an axes. The user then highlights a region of interest within the image using the roipoly tool.
However, I would like to include a button which enables the user to take a 'snapshot' of the GUI which is then saved to a folder. I have tried using the following functions;
print('-djpeg','-r1200',filePath)
and
saveas(handles.figure1,filePath,'jpg');
both of which result in quite low quality images. More importantly, the location of most of the UI controls are changed resulting in an output which does not mirror the GUI's state.
I have tried using the, set(gcf,'PaperPositionMode','auto'); and set(gcf,'InvertHardcopy','off'); options however these resulted in an error.
Any ideas?
kind regards, John
1 commentaire
Adam Danz
le 20 Oct 2020
In anyone is looking for a solution to taking snapshots with uifigures and apps, exportapp() was released in r2020b (see community highlight).
Réponses (2)
Image Analyst
le 3 Mai 2012
Ah, our daily "how do I save a figure?" question. Try the FAQ: http://matlab.wikia.com/wiki/FAQ#How_do_I_save_my_figure.2C_axes.2C_or_image.3F_I.27m_having_trouble_with_the_built_in_MATLAB_functions.
And don't use JPEG - it gives crappy images. Use PNG instead.
0 commentaires
Juan Conde
le 22 Oct 2024
Modifié(e) : Walter Roberson
le 22 Oct 2024
Although exportapp() is a good option, it does not work in older GUIs created with the figure function.
A workaround is given in:
where it shows how to use getframe and imwrite to this purpose:
plot(1:10)
F = getframe(gcf);
imwrite(F.cdata,"myplot.bmp")
0 commentaires
Voir également
Catégories
En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!