BitMap Label not working

 

Hello 


I am trying to Create a bitmap label but its not working , i checked the object list on chart (CTRL+b) i can see that it created a label but the image isnt visible on chart.

Here is the code :

   string   name =  "label 1";
   ObjectCreate(0,name,OBJ_BITMAP_LABEL,0,0,0);
   ObjectSetString(0,name,OBJPROP_BMPFILE,"Images\\lab.bmp");
  
   ObjectSetInteger(0,name,OBJPROP_XDISTANCE,300);
   ObjectSetInteger(0,name,OBJPROP_YDISTANCE,300);
   ObjectSetInteger(0,name,OBJPROP_XSIZE,300);
   ObjectSetInteger(0,name,OBJPROP_YSIZE,300);
   ObjectSetInteger(0,name,OBJPROP_XOFFSET,300);
   ObjectSetInteger(0,name,OBJPROP_YOFFSET,300);
   ObjectSetInteger(0,name,OBJPROP_STATE,false);
   ObjectSetInteger(0,name,OBJPROP_CORNER,CORNER_LEFT_UPPER);
   ObjectSetInteger(0,name,OBJPROP_ANCHOR,ANCHOR_CENTER);
   ObjectSetInteger(0,name,OBJPROP_COLOR,clrRed);
   ObjectSetInteger(0,name,OBJPROP_STYLE,STYLE_SOLID);
   ObjectSetInteger(0,name,OBJPROP_WIDTH,1);
   ObjectSetInteger(0,name,OBJPROP_BACK,false);
   ObjectSetInteger(0,name,OBJPROP_SELECTABLE,false);
   ObjectSetInteger(0,name,OBJPROP_SELECTED,false);
   ObjectSetInteger(0,name,OBJPROP_HIDDEN,false);

 What i have tried: 
I have tried This   and This  but these solution dint work for me .

Can someone please point out what am i doing wrong ?

Thanks 

 
I would guess with the offset you are pushing the BMP outside the visible area defined by size.
 
Start with small values so that you can see the image on the screen and then adjust them gradually until you see what you want it to be.
 
Dominik Egert:
I would guess with the offset you are pushing the BMP outside the visible area defined by size.t

@Dominik Egert and @@Marco vd Heijden  Thank you for your reply i did try to change the ofsets and still nothing is visible ,I am attaching a screenshot as well

another strange thing i noticed is when i give the bmp image name to something that does not exist in images folder , i dont get any error ? it should give some sort of error that the image does not exist or something ?

Files:
 
arads237:

@Dominik Egert and @@Marco vd Heijden  Thank you for your reply i did try to change the ofsets and still nothing is visible ,I am attaching a screenshot as well

another strange thing i noticed is when i give the bmp image name to something that does not exist in images folder , i dont get any error ? it should give some sort of error that the image does not exist or something ?

Click on Edit... to get the properties, this is not really showing any details at the moment. - Screenshot not heplful.

To get an error, you need to check the return value of ObjectSet...()

Something like this maybe:

if(!ObjectSetString(0,name,OBJPROP_BMPFILE,"Images\\lab.bmp"))
{ printf("Error creating bmp. Error code: %i", GetLastError()); }

Here is a snippet of my code and how I am doing it:

            // Create Canvas resource 

                const int add_data = ArraySize(obj_data);
                ArrayResize(obj_data, add_data + 1);
                obj_list[object_idx(obj_name)].data_idx     = add_data;
                obj_data[add_data].width                    = _c_width;
                obj_data[add_data].height                   = _c_height;
                obj_data[add_data].clr                      = txtColor;
                obj_data[add_data].bgclr                    = (color)bg_clr;
                obj_data[add_data].flags                   |= (0x01 * bottom_up); 
                obj_data[add_data].flags                   |= (0x02 * term_colors); 
                obj_data[add_data].flags                   |= (font_size << 56); 
                obj_list[object_idx(obj_name)].chart_id     = chart_id;
                obj_list[object_idx(obj_name)].window_id    = window_id;
                
                ResourceFree("::" + obj_name);
                ResourceCreate("::" + obj_name, textfield_bmp, width, height, NULL, NULL, width, COLOR_FORMAT_ARGB_RAW);


            // Create console output field

                ObjectCreate(chart_id, obj_name, OBJ_BITMAP_LABEL, window_id, NULL, NULL);
                
                ObjectSetInteger(chart_id, obj_name, OBJPROP_COLOR,         clrNONE);
                ObjectSetInteger(chart_id, obj_name, OBJPROP_XDISTANCE,     x_pos);
                ObjectSetInteger(chart_id, obj_name, OBJPROP_YDISTANCE,     y_pos);
                ObjectSetInteger(chart_id, obj_name, OBJPROP_XSIZE,         width);
                ObjectSetInteger(chart_id, obj_name, OBJPROP_YSIZE,         height);
                ObjectSetInteger(chart_id, obj_name, OBJPROP_CORNER,        CORNER_LEFT_UPPER);
                ObjectSetString(chart_id,  obj_name, OBJPROP_TOOLTIP,       (tooltip == NULL) ? "\n" : tooltip);
                ObjectSetInteger(chart_id, obj_name, OBJPROP_BACK,          false);
                ObjectSetInteger(chart_id, obj_name, OBJPROP_SELECTABLE,    false);
                ObjectSetInteger(chart_id, obj_name, OBJPROP_SELECTED,      false);
                ObjectSetInteger(chart_id, obj_name, OBJPROP_HIDDEN,        true);
                ObjectSetInteger(chart_id, obj_name, OBJPROP_ZORDER,        NULL);
                ObjectSetString(chart_id,  obj_name, OBJPROP_BMPFILE,       NULL, "::" + obj_name);

Its incomlete code, but maybe it gives you an idea on how to do it. It works perfectly for me this way. (Used to render text)

Reason: