Need to create Bitmap Object, but help documentation BitmapCreate function no works!

 

Hi.

I am trying to create an Bitmap Object using  BitmapCreate function of mql4 hqlp documentation... but nothing happens... can you help me?

 

//+------------------------------------------------------------------+ 
//| Create a bitmap in the chart window                              | 
//+------------------------------------------------------------------+ 
bool BitmapCreate(const long            chart_ID=0,        // chart's ID 
                  const string          name="Bitmap",     // bitmap name 
                  const int             sub_window=0,      // subwindow index 
                  datetime              time=0,            // anchor point time 
                  double                price=0,           // anchor point price 
                  const string          file="",           // bitmap file name 
                  const int             width=10,          // visibility scope X coordinate 
                  const int             height=10,         // visibility scope Y coordinate 
                  const int             x_offset=0,        // visibility scope shift by X axis 
                  const int             y_offset=0,        // visibility scope shift by Y axis 
                  const color           clr=clrRed,        // border color when highlighted 
                  const ENUM_LINE_STYLE style=STYLE_SOLID, // line style when highlighted 
                  const int             point_width=1,     // move point size 
                  const bool            back=false,        // in the background 
                  const bool            selection=false,   // highlight to move 
                  const bool            hidden=true,       // hidden in the object list 
                  const long            z_order=0)         // priority for mouse click 
  { 
//--- set anchor point coordinates if they are not set 
   //ChangeBitmapEmptyPoint(time,price); 
//--- reset the error value 
   ResetLastError(); 
//--- create a bitmap 
   if(!ObjectCreate(chart_ID,name,OBJ_BITMAP,sub_window,time,price)) 
     { 
      Print(__FUNCTION__, 
            ": failed to create a bitmap in the chart window! Error code = ",GetLastError()); 
      return(false); 
     } 
//--- set the path to the image file 
   if(!ObjectSetString(chart_ID,name,OBJPROP_BMPFILE,file)) 
     { 
      Print(__FUNCTION__, 
            ": failed to load the image! Error code = ",GetLastError()); 
      return(false); 
     } 
//--- set visibility scope for the image; if width or height values 
//--- exceed the width and height (respectively) of a source image, 
//--- it is not drawn; in the opposite case, 
//--- only the part corresponding to these values is drawn 
   ObjectSetInteger(chart_ID,name,OBJPROP_XSIZE,width); 
   ObjectSetInteger(chart_ID,name,OBJPROP_YSIZE,height); 
//--- set the part of an image that is to be displayed in the visibility scope 
//--- the default part is the upper left area of an image; the values allow 
//--- performing a shift from this area displaying another part of the image 
   ObjectSetInteger(chart_ID,name,OBJPROP_XOFFSET,x_offset); 
   ObjectSetInteger(chart_ID,name,OBJPROP_YOFFSET,y_offset); 
//--- set the border color when object highlighting mode is enabled 
   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr); 
//--- set the border line style when object highlighting mode is enabled 
   ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style); 
//--- set a size of the anchor point for moving an object 
   ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,point_width); 
//--- display in the foreground (false) or background (true) 
   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back); 
//--- enable (true) or disable (false) the mode of moving the label by mouse 
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection); 
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection); 
//--- hide (true) or display (false) graphical object name in the object list 
   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden); 
//--- set the priority for receiving the event of a mouse click in the chart 
   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order); 
//--- successful execution 
   return(true); 
  } 

 

Here my call to create the object 

string filename="\\Images\my_image.bmp";

if( !BitmapCreate(0,"logo",0,0,0,filename,
                     10, /* width */
                     10, /* height */
                     0, /*x_offset*/
                     0, /*y_offset*/
                     clrRed, /*clr*/
                     STYLE_SOLID, /*style*/
                     1, /*point_width*/
                     false, /*back*/
                     false, /*selection*/
                     true, /*hidden*/
                     0, /*z_order*/)
){

   Alert(filename, " not created!");

}
 

You seem to miss the modifier in ObjectSetString(chart_ID,name,OBJPROP_BMPFILE,file) 

 The other possible reason might be the file - it must be a 24-bit bmp (not 32-bit)

 
Ovo:

You seem to miss the modifier in ObjectSetString(chart_ID,name,OBJPROP_BMPFILE,file) 

 The other possible reason might be the file - it must be a 24-bit bmp (not 32-bit)

 

Hi, i've make some testes now and do not miss. Just change filename to a wrong filename and then get the message BitmapCreate: failed to load the image! Error code = 5020, but when i set filename currect not gives me any error, then the function was all executed. but nothing is shown on window.

 

I try to test with 24 bit colors and 256 colors... and nothing!

 

I found it!

 

I was using  OBJ_BITMAP then need to put time and price coordinates... as i was using 0 , the element was created but outside the visible candles...

 

Now i change it to OBJ_BITMAP_LABEL and works fine! Just get it from code suggested on help documentation. thanks!

Reason: