简体   繁体   中英

How to bind an image used in a mask of a simulink block to said block?

To clarify this at the beginning:

With image inside the mask of subsystem i do NOT mean an image drawn onto the block, but rather an image one can add to the mask: 澄清

Is there a way to bind the image to the block? In case I want to distribute my model, I don't want to have to share every image used in it.

For an image drawn onto the block I found a solution here , that is storing the image inside the UserData of the block, but I can't find an option to change the properties of images used inside a mask.

Quote out of my correspondence with the MathWorks Technical Support:

Unfortunately, it is currently not possible to specify a mask dialog image without providing a file path and a separate image file. This has been brought to the attention of the development team as a possible enhancement for a future release.

This refers to Matlab / Simulink 9 (2016a).

This might be a bit too late, but having the same problem I 'fixed' it by including the image and its alpha values in the 'UserData' parameter, checking if the image already exists in the current folder, and if not creating it from the userdata:

if ~exist('ARMicon.png','file')
    maskParams = Simulink.Mask.get(gcb);
    armim = maskParams.getDialogControl('armPic');
    ud = get_param(gcb,'UserData');
    imwrite(ud.ARM,'ARMicon.png','Alpha',ud.alpha);
    armim.FilePath = 'ARMicon.png';
end

查看结果

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM