ResourceCreate
ResourceCreate
根据数据集创建图像资源。该函数有两种实现方式: 基于文件创建资源
bool ResourceCreate(
const string resource_name, // Resource name
const string path // A relative path to the file
);基于像素数组创建资源
bool ResourceCreate(
const string resource_name, // Resource name
const uint& data[], // Data set as an array
uint img_width, // The width of the image resource
uint img_height, // The height of the image resource
uint data_xoffset, // The horizontal rightward offset of the upper left corner of the image
uint data_yoffset, // The vertical downward offset of the upper left corner of the image
uint data_width, // The total width of the image based on the data set
ENUM_COLOR_FORMAT color_format // Color processing method
);参数
- resource_name
[in] 资源名称。
- path
[in] 文件的相对路径,包含资源数据。如果路径以“\”开始(写作“\”),则假设文件路径相对于terminal_data_folder\MQL4;否则,假设文件指定相对于 .EX4 程序文件夹。
- data[]
[in] 用于创建完整图像的一维或二维数组。
- img_width
[in] 要放入资源中的矩形图像区域的宽度,以像素为单位。其值不能大于data_width的值。
- img_height
[in] 要放入资源中的矩形图像区域的高度,以像素为单位。
- data_xoffset
[in] 图像矩形区域的向右水平偏移量。
- data_yoffset
[in] 图像矩形区域的向下垂直偏移量。
- data_width
[in] 仅对一维数组 required。它表示从数据集中获取的图像的完整宽度。如果data_width=0,则假设其等于img_width。对于二维数组,此参数被忽略,并假设其等于data[]数组的第二个维度。
- color_format
[in] 颜色处理方式,来自ENUM_COLOR_FORMAT枚举值。
返回值
成功则返回true,否则返回false。要获取错误信息,请调用GetLastError()函数。可能出现以下错误:
- 4015 – ERR_RESOURCE_NAME_DUPLICATED(动态资源和静态资源名称相同)
- 4016 – ERR_RESOURCE_NOT_FOUND(未找到资源)
- 4017 – ERR_RESOURCE_UNSUPPORTED_TYPE(不支持此类型的资源)
- 4018 – ERR_RESOURCE_NAME_IS_TOO_LONG(资源名称过长)
注意
如果调用函数的第二个版本来创建具有不同宽度、高度和偏移参数的相同资源,它不会创建新的资源,而是仅更新现有资源。
函数的第一个版本用于从文件上传图像和声音,第二个版本仅用于动态创建图像。
图像必须是BMP格式,颜色深度为24或32位。声音只能为WAV格式。资源的大小不应超过16 Mb。
ENUM_COLOR_FORMAT
| 标识符 | 描述 |
|---|---|
| COLOR_FORMAT_XRGB_NOALPHA | 忽略alpha通道的组件 |
| COLOR_FORMAT_ARGB_RAW | 终端不处理颜色组件(必须由用户正确设置) |
| COLOR_FORMAT_ARGB_NORMALIZE | 终端处理颜色组件 |
另请参阅
Resources, ObjectCreate(), ObjectSetString(), OBJPROP_BMPFILE
最后更新于