MQL4 Reference Common Functions ResourceReadImage


The function reads data from the graphical resource created by ResourceCreate() function or saved in EX4 file during compilation.

bool  ResourceReadImage(
   const string      resource_name,       // graphical resource name for reading
   uint&             data[],              // array for receiving data from the resource
   uint&             width,               // for receiving the image width in the resource
   uint&             height               // for receiving the image height in the resource



[in]  Name of the graphical resource containing an image. To gain access to its own resources, the name is used in brief form "::resourcename". If we download a resource from a compiled EX4 file, the full name should be used with the path relative to MQL4 directory, file and resource names — "path\\filename.ex4::resourcename".


[in]  One- or two-dimensional array for receiving data from the graphical resource.


[out]  Graphical resource image width in pixels.


[out]  Graphical resource image height in pixels.

Returned value

true if successful, otherwise false. To get information about the error, call the GetLastError() function.


If data[] array is then to be used for creating a graphical resource, COLOR_FORMAT_ARGB_NORMALIZE or COLOR_FORMAT_XRGB_NOALPHA color formats should be used.

If data[] array is two-dimensional and its second dimension is less than X(width) graphical resource size, ResourceReadImage() function returns false and reading is not performed. But if the resource exists, actual image size is returned to width and height parameters. This will allow making another attempt to receive data from the resource.

See also

Resource, ObjectCreate(), ObjectSetString(), OBJPROP_BMPFILE