imagesimulinkmasksubsystem

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:clarification

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.


Solution

  • 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
    

    See the result

    Hope this helps.