This class is designed for creation of bmp images.
Examples:
An example of DrawTriangle() method
An example of DrawRectangle() method
An example of DrawCircle() method
An example of Fill() method
Usage:
The cIntBMP.mqh file should be located in MQL5/Include folder. The demo of cIntBMP class usage is located in the eBMP.mq5 file. Copy this file to the MQL5/Experts folder, open it in MetaEditor, compile and attach to the chart.
Using cIntBMP class:
1. Include file with class:
#include <cIntBMP.mqh>
2. Delcare the cIntBMP class variable, for example “bmp”:
cIntBMP bmp;
3. Set image size and background color (using Create(…) method, see below).
4. Draw on the image.
5. Save (using the Save(…) method).
6. Show (using the Show(…) method);
When finished:
1. Delete graphic object (using the Hide(…) method).
2. Delete the file (using the Delete(…) method).
Class Methods:
- Create(int aSizeX, int aSizeY, int aBGColor) – Sets image size and background color.
aSizeX – width (in pixels);
aSizeY – height (in pixels);
aBGColor – background color;
- SetDrawWidth(int aWidth) – Sets pen width.
aWidth – pen width.
- DrawDot(int aX, int aY, int aColor) – Draws a dot.
aX – X coordinate;
aY – Y cooordinate;
aColor – color;
- DrawLine(int aX1,int aY1, int aX2, int aY2, int aColor) – Draws a line.
aX1, aY1 – starting coordinates;
aX2, aY2 – ending coordinates;
aColor – color;
- DrawRectangle(int aX1, int aY1, int aX2, int aY2, int aColor, bool aSolid=false) – Draws a rectangle.
aX1, aY1 – coordinates of the upper left corner;
aX2, aY2 – coordinates of the lower right corner;
aColor – color;
aSolid – true – filled.
- DrawTriangle(int aX1, int aY1, int aX2, int aY2, int aX3, int aY3, int aColor, bool aSolid=false) – Draws a triangle.
aX1, aY1, aX2, aY2, aX3, aY3 – edge coordinates;
aColor – color;
aSolid – true – filled.
- DrawCircle(int aX, int aY, int aRadius1, int aRadius2, int aColor, double aRatio=1.0, double aAngleFrom=0.0, double aAngleTo, bool aSolid=false) – Draws a circle.
aX – X coordinate;
aY – Y coordinate;
aRadius1 – radius of the 1st circle;
aRadius2 – radius of the 2nd circle;
aColor – color;
aRatio – ratio (ratio=1, circle, overwise ellipse).
aAngleFrom – starting angle;
aAngleTo – ending angle. if aAngleFrom=aAngleTo, it will draw a circle;
aSolid – true – filled circle/ellipse.
- Fill(int aX, int aY, int aColor) – Fills the area.
aX, aY – coordinates of the fill area;
aColor – fill color.
- TypeText(int aX, int aY, int aColor) – Prints text on the image.
aX, aY – coordinates of the left upper corner of the text;
aColor – text color.
- Save(string aFileName, bool aToImages=true) – saves the created image to file.
aFileName – File name (it isn’t necessary to specify the extension) ;
aToImages – file will be saved to the MQL5\Images\ folder, overwise it will be saved to the MQL5\Files\ folder.
- Show(int aX, int aY, string aBMPFileName, string aObjectName) – Shows the image on the chart.
aX, aY – coodinates;
aBMPFileName – file name of the image;
aObjectName – graphic object of OBJ_BITMAP_LABEL type.
- Hide(string aObjectName) – Deletes graphic object with the specified name.
aObjectName – name of the object to delete.
- Delete(string aFileName, bool aFromImages=true) – Deletes a file.
aFileName – Name of the bmp file to delete (without path, it isn’t necessary to specify the extension);
aFromImages – if true, the file will be deleted from MQL5\Images\ folder, overwise it will be deleted from MQL5\Files\ folder.