Main Content

image

Display image on block mask icon

    Description

    example

    image(maskImage) displays the image maskImage on the block mask icon.

    image(maskImage,positionAndSize) provides the position and size of the image within the block mask icon.

    image(maskImage,positionAndSize,rotation) specifies whether the image rotates along with the icon or remains stationary.

    Examples

    collapse all

    Multiple image commands are used in this masked block to indicate the block capabilities.

    The block mask icon consists of four separate images:

    • The image in the center of the block mask icon, stored in block_icon_controller.png.

    • A company logo in the bottom right, stored in company_logo.png.

    • Two icons in the bottom left indicating that you can compile and build code for the block, stored in block_capability_compile.png and block_capability_build.png.

    Block mask icon

    Use this code to display the images in the block mask icon.

    % The second argument of the image command specifies
    % the location and size of the image on the block mask icon
    % in the format [x,y,w,h] where:
    %
    %   x is the horizontal displacement with respect to the bottom left corner.
    %   y is the vertical displacement with respect to the bottom left corner.
    %   w is the width of the image.
    %   h is the height of the image.
    %
    %  Compute the width and height relative to the total block mask icon size
    %  to make sure that images scale with block resizing.
    
    image('block_icon_controller.png',[10,10,85,40]);
    
    image('company_logo.png',[95,2,10,10]);
    
    image('block_capability_compile.png',[7,2,8,8]);
    
    image('block_capability_build.png',[18,2,10,10]);
    
    

    Input Arguments

    collapse all

    Image that is displayed on the block mask icon, specified as one of these options:

    • An m-by-n-by-3 array of RGB values. Where m and n are the size of the image in pixels.

    • The name of an image file, specified as a string scalar or character vector.

    Note

    Images in formats .cur, .hdf4, .ico, .pcx, .ras, .xwd, cannot be used as block mask images.

    Example: image('icon.jpg')

    Data Types: matrix | string | char

    Position and size of the image, specified as a numeric array of the form [x, y, w, h] where,

    • x— Horizontal displacement of the image from the bottom left corner of the icon as a percentage of the total width of the icon.

    • y— Vertical displacement of the image from the bottom left corner of the icon as a percentage of the total height of the icon.

    • w — Width of the image specified as defined by the Icon Units

    • h — Height of the image specified as defined by the Icon Units

    When you use these values, the size of image does not scale with the size of the block mask icon when you resize the block.

    You can also specify image alignment details including alignment to the left, right, top, and bottom margins as a numeric array of the form [a, b, c, d, w, h]. Additionally, you can specify the percentage of width and height for the image, ensuring that the entire image is visible within the block.

    • a — Left margin of the image specified in Icon Units

    • b — Top margin of the image specified in Icon Units

    • c — Right margin of the image specified in Icon Units

    • d — Bottom margin of the image specified in Icon Units

    • w — Width of the image as a percentage of the total width of the icon

    • h — Height of the image as a percentage of the total height of the icon

    You can also specify position as shown in the table.

    Image Position

    ValuePosition in the block mask icon
    "center"Center
    "top-left"Top left corner
    "bottom-left"Bottom left corner
    "top-right"Top right corner
    "bottom-right"Bottom right corner

    Example: image('company_logo.png',[95,2,10,10])

    Example: image("block_icon_controller.png","center")

    Data Types: array | string | char

    Option to specify whether the image rotates or remains stationary as the icon rotates, specified as 'off' or 'on'.

    Example: image('company_logo.png',[95,2,10,10],'off')

    Version History

    Introduced in R2006a