image
在模块封装图标上显示图像
说明
image(
在模块封装图标上显示图像 maskImage
)maskImage
。
image(
提供图像在模块封装图标内的位置和大小。maskImage
,positionAndSize
)
image(
指定图像是随图标一起旋转还是保持静止。maskImage
,positionAndSize
,rotation
)
示例
在模块封装图标上显示图像
在此封装模块中使用多个图像命令来指示模块功能。
模块封装图标由四个单独的图像组成:
模块封装图标中心的图像,存储在
block_icon_controller.png
中。右下角的公司徽标,存储在
company_logo.png
中。左下角的两个图标表示您可以编译和构造存储在
block_capability_compile.png
和block_capability_build.png
中的模块的代码。
使用以下代码显示模块封装图标中的图像。
% 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]);
输入参数
maskImage
— 在模块封装图标上显示的图像
矩阵 | 字符向量 | 字符串标量
在模块封装图标上显示的图像,指定为以下选项之一:
由 RGB 值组成的 m×n×3 数组。其中 m 和 n 是图像的像素大小。
图像文件的名称,指定为字符串标量或字符向量。
注意
.cur
、.hdf4
、.ico
、.pcx
、.ras
、.xwd
格式的图像不能用作模块封装图像。
示例: image('icon.jpg')
数据类型: matrix
| string
| char
positionAndSize
— 图像的位置和大小
居中 (默认) | 数值数组 | 字符串标量
图像的位置和大小,指定为 [x, y, w, h]
形式的数值数组,其中,
x
- 图像从图标左下角开始的水平位移,以图标总宽度的百分比形式表示。y
- 图像从图标左下角开始的垂直位移,以图标总高度的百分比形式表示。w
- 图像的宽度,指定为由图标单位定义h
- 图像的高度,指定为由图标单位定义
如果使用这些值,则当调整模块大小时,图像的大小不会随模块封装图标的大小而缩放。
您还能够以 [a, b, c, d, w, h]
形式的数值数组形式指定图像对齐的详细信息,包括与左边距、右边距、顶边距和底边距对齐。此外,您还可以指定图像的宽度和高度百分比,确保整个图像在模块中可见。
a
- 以图标单位指定的图像左边距b
- 以图标单位指定的图像顶边距c
- 以图标单位指定的图像右边距d
- 以图标单位指定的图像底边距w
- 图像宽度,以图标总宽度的百分比形式表示h
- 图像高度,以图标总高度的百分比形式表示
您还可以指定 position
,如下表所示。
图像位置
值 | 模块封装图标中的位置 |
---|---|
"center" | 居中 |
"top-left" | 左上角 |
"bottom-left" | 左下角 |
"top-right" | 右上角 |
"bottom-right" | 右下角 |
示例: image('company_logo.png',[95,2,10,10])
示例: image("block_icon_controller.png","center")
数据类型: array
| string
| char
rotation
— 用于允许图像随图标旋转的选项
'off'
(默认) | 'on'
用于指定图像是随图标的旋转而旋转还是保持静止的选项,指定为 'off'
或 'on'
。
示例: image('company_logo.png',[95,2,10,10],'off')
版本历史记录
在 R2006a 中推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
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)