MQL4 ResourceCreate Function

Overview

Creates an image resource based on a data set. Supports two variants:

1. **From File:** bool ResourceCreate(const string resource_name, const string path) 2. **From Pixel Array:** bool ResourceCreate(const string resource_name, const uint& data[], uint img_width, uint img_height, uint data_xoffset, uint data_yoffset, uint data_width, ENUM_COLOR_FORMAT color_format)

Parameters

  • resource_name (string): Name for the resource.
  • path (string): Relative path to the resource file. \ prefix means relative to terminal_data_folder\MQL4\, otherwise relative to the program's folder.
  • data[] (uint[]): Array of pixels for dynamic image creation.
  • img_width (uint): Width of the image in pixels. Cannot exceed data_width.
  • img_height (uint): Height of the image in pixels.
  • data_xoffset (uint): Horizontal offset from the top-left corner of the image data.
  • data_yoffset (uint): Vertical offset from the top-left corner of the image data.
  • data_width (uint): Total width of the image in the data set. If 0, equals img_width. Ignored for 2D arrays (uses second dimension).
  • color_format (ENUM_COLOR_FORMAT): Method for color processing.
  • ENUM_COLOR_FORMAT

  • COLOR_FORMAT_XRGB_NOALPHA: Alpha channel ignored.
  • COLOR_FORMAT_ARGB_RAW: Color components not handled by terminal.
  • COLOR_FORMAT_ARGB_NORMALIZE: Color components handled by terminal.
  • Return Value

  • true: Success.
  • false: Failure. Use GetLastError() for error details.
  • Errors

  • 4015: ERR_RESOURCE_NAME_DUPLICATED
  • 4016: ERR_RESOURCE_NOT_FOUND
  • 4017: ERR_RESOURCE_UNSUPPORTED_TYPE
  • 4018: ERR_RESOURCE_NAME_IS_TOO_LONG
  • Notes

  • Updating an existing resource with different dimensions/offsets does not create a new resource.
  • File version is for images (BMP, 24/32-bit color) and sounds (WAV).
  • Pixel array version is for dynamic image creation.
  • Maximum resource size: 16 MB.
  • Related Functions

  • ResourceFree()
  • ResourceReadImage()
  • ResourceSave()
  • GetLastError()
  • ObjectCreate()
  • ObjectSetString()