Download MetaTrader 5

OBJ_BITMAP_LABEL BMP's alpha channel don't work

To add comments, please log in or register
meiti
115
meiti  

Hello everyone!

I wanted to try something new today.
I tried to render BMP image to chart, which worked fine yet when i try 32bit bmp with alpha channel the image won't appear transparent.

I double checked my bmp with hex editor and it has alpha channel with correct value.
Hm i guess i must be missing something in code

 

void SPimg(string name, int x, int y, string file_on, string file_off, const int width, const int height,const bool back=false,const bool selection=false)
{
   ObjectCreate(0,name,OBJ_BITMAP_LABEL,0,0,0);
   ObjectSetString(0,name,OBJPROP_BMPFILE,0,file_on);
   ObjectSetString(0,name,OBJPROP_BMPFILE,1,file_off);
   ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);
   ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y);
   ObjectSetInteger(0,name,OBJPROP_XSIZE,width);
   ObjectSetInteger(0,name,OBJPROP_YSIZE,height);
   ObjectSetInteger(0,name,OBJPROP_XOFFSET,0);
   ObjectSetInteger(0,name,OBJPROP_YOFFSET,0);
   ObjectSetInteger(0,name,OBJPROP_STATE,1);
   ObjectSetInteger(0,name,OBJPROP_CORNER,CORNER_LEFT_UPPER);
   ObjectSetInteger(0,name,OBJPROP_ANCHOR,ANCHOR_LEFT_UPPER);
   ObjectSetInteger(0,name,OBJPROP_COLOR,C'0,0,0');
   ObjectSetInteger(0,name,OBJPROP_STYLE,0);
   ObjectSetInteger(0,name,OBJPROP_WIDTH,0);
   ObjectSetInteger(0,name,OBJPROP_BACK,back);
   ObjectSetInteger(0,name,OBJPROP_SELECTABLE,selection);
   ObjectSetInteger(0,name,OBJPROP_SELECTED,0);
   ObjectSetInteger(0,name,OBJPROP_HIDDEN,0);
   ObjectSetInteger(0,name,OBJPROP_ZORDER,0);
}

int OnInit()
{
   SPimg("testbmp", 128, 128, "\\Images\\5.bmp", "\\Images\\5.bmp", 128, 128);
   return(INIT_SUCCEEDED);
}

void OnDeinit(const int reason)
{
   ObjectDelete("testbmp");
}

 
Just in case i attached my bmp what i was using.

Files:
5.zip 11 kb
Alexander Puzanov
32704
Alexander Puzanov  

MT supports alpha channel only if the picture is inserted as a resource. Add #resource "\\Images\\5.bmp"; to code

meiti
115
meiti  
Thannk you! it works now.
To add comments, please log in or register