Azzera filtri
Azzera filtri

How can I add a third or more gif in my gui. but if I add one more my gui is unresponsive when I run it. I create my axes on 11 for my third gif. please help me

1 visualizzazione (ultimi 30 giorni)
% --- Executes just before GUILAPL is made visible.
function GUILAPL_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to GUILAPL (see VARARGIN)
% Choose default command line output for GUILAPL
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% Load background image
bg_image = imread('C:\Users\PC\OneDrive\Desktop\Lab Feedback\Lab 1\wp1913256.jpg'); % Replace with the correct file path
% Display background image
axes(handles.axes8); % Replace axes8 with the name of your axes component
imshow(bg_image, 'Parent', handles.axes8);
set(handles.axes8, 'Visible', 'on');
disp('Background image loaded successfully.'); % Debug message
% Load first GIF image
gif_image1 = 'C:\Users\PC\OneDrive\Desktop\Lab Feedback\Lab 1\Mr3W.gif'; % Replace with the correct file path
[gif_data1, map1] = imread(gif_image1, 'Frames', 'all');
num_frames1 = size(gif_data1, 4);
% Load second GIF image
gif_image2 = 'C:\Users\PC\OneDrive\Desktop\Lab Feedback\Lab 1\bilog.gif';
[gif_data2, map2] = imread(gif_image2, 'Frames', 'all');
num_frames2 = size(gif_data2, 4);
% Determine the maximum number of frames
max_frames = max(num_frames1, num_frames2);
% Loop the GIF animations
while ishandle(handles.figure1) % Keep looping until the figure is closed
for i = 1:max_frames
% Display each frame of the first GIF in axes9
if i <= num_frames1
axes(handles.axes9);
imshow(gif_data1(:,:,:,i), map1, 'Parent', handles.axes9);
set(handles.axes9, 'Visible', 'on');
end
% Display each frame of the second GIF in axes10
if i <= num_frames2
axes(handles.axes10);
imshow(gif_data2(:,:,:,i), map2, 'Parent', handles.axes10);
set(handles.axes10, 'Visible', 'on');
end
% Pause for a short duration to create animation effect
pause(0.1);
drawnow; % Force MATLAB to render the frame immediately
end
end
  1 Commento
Rik
Rik il 18 Mar 2024
You should probably consider using a timer object to start the infinite loop. That way you can also more easily stop the loop.
And what do you mean exactly? You mean the figure window doesn't respond to resizing if you have two gifs displayed? But with only one gif it works?

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Environment and Settings in Help Center e File Exchange

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by