How to insert an image to the static text in gui?

조회 수: 1 (최근 30일)
Jihad Chamseddine
Jihad Chamseddine 2014년 7월 16일
댓글: Jihad Chamseddine 2014년 7월 17일
hi, I want to insert an image to the static text in GUI, I tried to modify it in the property inspector and I used the following: imread('myimagefile.jpg') but it didn't work , so can that be done? thanks
  댓글 수: 1
Geoff Hayes
Geoff Hayes 2014년 7월 16일
I think that you want to insert the image into a axes control/widget. The static text widget is for text only.

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2014년 7월 16일
You must use an "axes" control, not a static text label control.
theImage = imread(filename);
axes(handles.axesImage); % Use actual variable names from your program!
imshow(theImage);
  댓글 수: 3
Image Analyst
Image Analyst 2014년 7월 16일
put the full filename, for example
folder = 'C:\Users\ziad\Desktop';
baseFileName = 'myimagefile.jpg';
fullFileName = fullfile(folder, baseFileName);
if exist(fullFileName, 'file')
theImage = imread(filename);
axes(handles.axesImage); % Use actual variable names from your program!
imshow(theImage);
else
message = sprintf('Image file not found:\n%s', fullFileName);
uiwait(warndlg(message));
end
I don't think you want to put anything in the CreateFcn of any function. You can put this in the OpeningFcn if you want. Or in the OutputFcn.
Jihad Chamseddine
Jihad Chamseddine 2014년 7월 17일
thank you now it works

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Language Support에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by