Libraries: cIntBMP - a library for creation of BMP images

 

cIntBMP - a library for creation of BMP images:

A class for creation and output of BMP images.

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.

Author: Дмитрий

An example of DrawTriangle() method of cIntBMP class

An example of DrawTriangle() method

An example of DrawRectangle() method of cIntBMP class

An example of DrawRectangle() method

An example of DrawCircle() method of cIntBMP class

An example of DrawCircle() method

An example of Fill() method of cIntBMP class

An example of Fill() method

 
On Windows 7 64 bit don't work.
 
barnix:
On Windows 7 64 bit don't work.
Fixed. Please download it again.
[Deleted]  

I'm trying to create a transparent one. But it doesn't work. You could find a bug. Or one cIntBMP Trasnparent Add functions.

//+------------------------------------------------------------------+
//|test.mq5 |
//| Copyright 2011, MetaQuotes Software Corp. | |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2011, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script programme start function|
//+------------------------------------------------------------------+

#import "user32.dll"
   int GetDC(int hwnd);
   int ReleaseDC(int hwnd,int hdc);
#import "gdi32.dll"
 int GetPixel(int hdc,int x,int y);
 int SetPixel(int hdc,int x,int y, int c); 
#import

void OnStart()
  {
   
int i, H, V, shH=0, shV=0, header;
  double hgh;
  color screen [80][80];
  color r, g, b, cv=Red;

//---
long  hwnd=ChartGetInteger(ChartID(),CHART_WINDOW_HANDLE);
int   hdc=GetDC((int)hwnd);
   
 

for(V=0; V<80; V++)
{
   for(H=0; H<80; H++)
   {
   screen[V][H]=GetPixel(hdc,V,H); 
   
   }
}

for(V=0; V<80; V++)
{
   for(H=0; H<80; H++)
   {

   cv=screen[V][H];
   
     cv=AlphaBlend(cv ,clrRed );

   SetPixel(hdc, V+shV,H+shH,cv);
  
   }
}


Sleep(3000);


  }
//+------------------------------------------------------------------+

/* alpha blend routine */
int AlphaBlend(int bg, int src)
{
int alpha = 100;
return (src * alpha / 255 + bg * (255 - alpha) / 255);

   int a = src >> 24;    /* alpha */
 
   /* If source pixel is transparent, just return the background */
   if (0 == a) return (bg);

   /* alpha blending the source and background colours */
 int rb = (((src & 0x00ff00ff) * a) +  
      ((bg & 0x00ff00ff) * (0xff - a))) & 0xff00ff00;
 int    g  = (((src & 0x0000ff00) * a) + 
      ((bg & 0x0000ff00) * (0xff - a))) & 0x00ff0000;
 
    return (  (src & 0xff000000) | ((rb | g) >> 8)   );
}
 
FinGeR:

Or one cIntBMP Trasnparent Add function.

You don't need such a function, you will need to recalculate and update the whole image on every tick. The machine is iron, but let it deal with more useful tasks.
 
Is there any possibility to use this library WITHOUT the dll it calls? (file functions inside the code)
 
Guys, maybe there are other ways to make the picture better?
 
Dmitry Fedoseev #:
You don't need such a function, you will need to recalculate and update the whole image on every tick. The machine is iron, but let it deal with more useful tasks.

You mean, the only way to have transparency on those rectangle and triangle objects are by reproducing the solution we have here in this article? Studying the CCanvas Class. How to Draw Transparent Objects - MQL5 Articles

Studying the CCanvas Class. How to Draw Transparent Objects
Studying the CCanvas Class. How to Draw Transparent Objects
  • www.mql5.com
Do you need more than awkward graphics of moving averages? Do you want to draw something more beautiful than a simple filled rectangle in your terminal? Attractive graphics can be drawn in the terminal. This can be implemented through the CСanvas class, which is used for creating custom graphics. With this class you can implement transparency, blend colors and produce the illusion of transparency by means of overlapping and blending colors.