Insert a PNG image on a table on App Designer

3 次查看(过去 30 天)
I'm trying to insert a local PNG image on the 5 column of a table and I don't konw how to do it. I tryed to do it using an UI axes but I can´t insert that axes to the table.
% Button pushed function: B_AgregarImagen
function B_AgregarImagenButtonPushed(app, event)
global image1;
[filename pathname] = uigetfile({'".png'},"Open file");
fullpathname = strcat(pathname,filename);
image1 = imread(fullpathname);
imshow(image1,'parent',app.Tabla.Data(:,5));
end

回答(1 个)

Abhishek Chakram
Abhishek Chakram 2023-10-3
Hi Iñigo Idigoras,
It is my understanding that you are facing difficulty in inserting image in the table in the App Designer. Here is a sample code on how to achieve this functionality:
[fileNames, filePath] = uigetfile('*.jpg', 'Select JPG files');
% Construct the full file path
fullFilePath = fullfile(filePath, fileNames);
% Read and display the image
image = imread(fullFilePath);
imgStyle = uistyle("Icon",image);
addStyle(app.UITable, imgStyle, 'cell', [1,1]);
In this example, the image is converted to an icon using ‘uistyle’ to display it in the “uitable” of the app.
You can refer to the following documentation to know more about the functions used:
Best Regards,
Abhishek Chakram

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by