image
Display image on block mask icon
Description
image(
displays the image
maskImage
)maskImage
on the block mask icon.
image(
provides the position and size of the image within the block mask icon.maskImage
,positionAndSize
)
image(
specifies whether the image rotates along with the icon or remains stationary.maskImage
,positionAndSize
,rotation
)
Examples
Display Image on Block Mask Icon
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
andblock_capability_build.png
.
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
maskImage
— Image displayed on block mask icon
matrix | character vector | string scalar
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
positionAndSize
— Position and size of image
center (default) | numeric array | string scalar
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 Unitsh
— 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 Unitsb
— Top margin of the image specified in Icon Unitsc
— Right margin of the image specified in Icon Unitsd
— Bottom margin of the image specified in Icon Unitsw
— Width of the image as a percentage of the total width of the iconh
— 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
Value | Position 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
rotation
— Option to allow image to rotate with the icon
'off'
(default) | 'on'
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
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)