Scripts: Demo_BitmapOffset (OBJPROP_XOFFSET and OBJPROP_YOFFSET)

 

Demo_BitmapOffset (OBJPROP_XOFFSET and OBJPROP_YOFFSET):

If you need to show just a part of the image at the moment and hide other, you can use the moving window by specifying the visible area of the image.

This is an example of use of the OBJPROP_XOFFSET and OBJPROP_YOFFSET properties. See video: https://www.mql5.com/en/forum/3509/page1#comment_55145.

This feature will allow you to use the image with a set of several images (like CSS-sprites used in web).

Recommendations:

  • The use of the resources allows to serve all the necessary objects in a single .EX5 file.

Demo_BitmapOffset (OBJPROP_XOFFSET and OBJPROP_YOFFSET)

Author: MetaQuotes


 
//--- find out the size of the loaded image to set the size of the scope correctly
   long y_size=ObjectGetInteger(0,bitmap_label,OBJPROP_YSIZE);

   long visual_y_size=y_size/3;
//--- set the width of the scope equal to the width of the loaded image
   ObjectSetInteger(0,bitmap_label,OBJPROP_YSIZE,visual_y_size);

Such change of OBJPROP_YSIZE-property completely deprives the normal possibility to find out the height of the source image?

Now, to find out the size of a (custom) resource in a BITMAP-object, you need to create an auxiliary graphic object of the same size on the basis of OBJPROP_BMPFILE-source and read OBJPROP_XSIZE/OBJPROP_YSIZE properties in it, deleting then the temporary object.

Isn't that too crutchy?