Hi guys, can someone expain me how to put a gif please?
I need put this gif:
gifmathlab.gif here.png

 Réponse acceptée

Walter Roberson
Walter Roberson le 16 Sep 2019

0 votes

GUIDE does not directly support playing GIFs.
What you can do is read the frames of the GIF and store them in an accessible place. Create an image() object in the appropriate axes with data initialized to all 0 and store the handle in an accessible place. Initialize an index to 1 in an accessible place. Then start a timer with a time interval equal to 1 divided by the desired frame rate.
The timer callback should retrieve the index, and retrieve the saved images, and retrieve the handle of the image object. It should set the CData property of the image object to the frames indexed at the current index. It should then increment the index by one, and if the result is greater than the number of frames, set it to 1, and it should save the updated frame index.

8 commentaires

Jhon Rackham
Jhon Rackham le 16 Sep 2019
Thanks a lot Mr Roberson, but you seen me crying because i was trying my little program, put a gif sounds so dificult. :(
Jhon Rackham
Jhon Rackham le 16 Sep 2019
Is it difficult to put only a picture?
Putting only a picture is not difficult at all.
In your GUI OpenFcn callback:
img = imread('PathToFileToPresent');
ax = handles.TagOfTheAxesYouAlreadyCreated;
image(ax, img);
Jhon Rackham
Jhon Rackham le 16 Sep 2019
Dear Mr Roberson, i didn't find the "OpenFcn callback"?
Where is it? I'am working with R2018a Mathlab version.no hay.png
Tell GUIDE to save what you have. Ask to edit the .m file.
The very first line of the file with be a function definition, with function name the same as the GUI name, such as
function varargout = HW2B11(varargout)
for GUI named HW2B11 .
Scroll past that down to about line 47 or so. You will see the second function line. It will look something like
function HW2B11_OpeningFcn(hObject, eventdata, handles, varargin)
with HW2B11 replaced by the name of your GUI.
Edit that function. Put the new code before the line
% Choose default command line output for untitled
Jhon Rackham
Jhon Rackham le 16 Sep 2019
Oh, i see Mr Roberson, thanks.
Do you know how to put 2 pictures in the same GUIDE?
I wanna put a pic as background and a little one as logo.
img = imread('PathToBackground');
ax = handles.TagOfTheBackgroundAxesYouAlreadyCreated;
image(ax, img);
img = imread('PathToLogoImage');
ax = handles.TagOfTheLogoAxesYouAlreadyCreated;
image(ax, img);
Jhon Rackham
Jhon Rackham le 16 Sep 2019
Thanks a lot Mr Roberson.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by