0

I am researching about Bitmap object that how I can use Bitmap Objects with Alpha 32bit file, but have found nothing. I already asked in few forums still nothing there about this Bitmap Alpha 32bit file.

Just my purpose how I can use my alpha image? I hope below screen shot could help me to clarify my issue. How can I use my alpha image in Chart?

Below code which is I am trying to use Bitmap Object with Alpha Channel, but I can't.

#property strict

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

//---
int OnInit()
{
    ObjectCreate( 0, "bitmap alpha", OBJ_BITMAP, 0, TimeCurrent(), Ask );
    ObjectSetString( 0, "bitmap alpha", OBJPROP_BMPFILE, filename );
    //---
    return(0);
}

void OnDeinit(const int reason)
{
    ObjectDelete( "bitmap alpha" );
    //---
    return;
}

enter image description here

halfer
  • 19,824
  • 17
  • 99
  • 186
Max-Enrik
  • 61
  • 13
  • 1
    What have you tried so far? Have you also tried to rotate **`[RGB|A]`**-bit-plane layers as from `RGB->` `RGBA->` `ARGB->` `BGRA->` ( or even all possible ordering of them, incl. Alpha ) as some ComputerVision packages do not follow the RGB-ordering + MT4 default alignment of **`(color)`** cast 4B-data about a pixel is **`0x00RRGGBB`** which introduces one more degree of freedom? ( ***cit.:*** "The `color` type is intended for storing information about color and occupies 4 bytes in memory. The first byte is ignored, the remaining 3 bytes contain the RGB-components." ) – user3666197 Apr 17 '17 at 18:07
  • I have already seen colortoargb() and resourcecreate() functions ( even I already researched about that functions ) - but absolutely I do not understand how I can use them for my image file that covert it to alpha image. That functions documentations does not much clearly just for me that I can use them... Thank you so much for your reply. ( P.S you meant I can convert my bitmap object image to alpha image, please? ) https://docs.mql4.com/common/resourcecreate https://docs.mql4.com/convert/colortoargb – Max-Enrik Apr 18 '17 at 12:22
  • What do you receive for [7[ as the GetLastError() values? – user3666197 Apr 18 '17 at 17:55
  • Did you try Wikipedia / Wikimedia published ARGB-32-bit bmp example file to start with a knowingly correct file? – user3666197 Apr 18 '17 at 17:56
  • **#1** I do not get any error message - I see my image file but it shows black background color - I need to remove it. **#2** I am not sure about that but I believe I use correct alpha .bmp image file format for it. Sorry do you ever tried .bmp alpha image file, please? If you need I can share that file here. – Max-Enrik Apr 18 '17 at 18:23
  • 1
    Review detail format specification >>> https://en.wikipedia.org/wiki/BMP_file_format#Example_2 – user3666197 Apr 19 '17 at 11:53
  • I believe my .bmp image file format is alpha file format. I need to share it here, but do not know how I can put it here. – Max-Enrik Apr 19 '17 at 12:36
  • I am getting be sure MT4 does not support .bmp alpha channel. Like image file shows without black background color. – Max-Enrik Apr 19 '17 at 13:51

3 Answers3

2

no idea what to advise you, maybe you can find quite a lot of different arrows in the wingdings section so that not to use any custom pictures. This is the reason why i never thought of your problem, and since you have no reply on other forums - probably other developers do not care of such option too.

Daniel Kniaz
  • 4,603
  • 2
  • 14
  • 20
  • I think if Alpha does not work but why there is documentation about the Alpha Channel. Thanks for your reply. – Max-Enrik Apr 17 '17 at 10:58
  • 1
    do you mean this https://docs.mql4.com/constants/objectconstants/enum_object/obj_bitmap_label documentation? if yes, please try `ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);` with `back= TRUE and FALSE`, maybe one of the cases is what you need. – Daniel Kniaz Apr 18 '17 at 09:11
  • Oh no, it's not a issue about OBJPROP_BACK, it's absolutely different things. Thanks for your reply. https://docs.mql4.com/constants/objectconstants/enum_object/obj_bitmap – Max-Enrik Apr 18 '17 at 12:01
  • Daniel - Special thank to you, because you mentioned Wingdings - that if I won't find solution to my issue - at least I will use it. Regards. ( your reply close to answer if I won't get answer better then it ) – Max-Enrik Apr 18 '17 at 12:17
1

Implementation Summary:

MQL4 as of build 1065 does not support any specific graphic manipulation tools but allow to transform a specifically formatted bitmap-file to be later used via a so called RESOURCE.

0. no other but .BMP file format is supported
1. no other but color depth of { 24 | 32 }-bits is supported
2. no RGB-color-plane manipulation is available, so all preparations are to be performed externally to MQL4 ( be it via a programmable tool like popular OpenCV or PIL modules in python, ImageMagick or manually via a bitmap manipulation editor )
3. no other but a file-interface is supported, so bitmap array-content must be pre-formatted and physically stored as a disk file in relative to a terminal_data_folder\MQL4\ so as to get loaded via ResourceReadImage()
4. some trivial pixel-array clipping is available in an extended format of ResourceCreate() as an update on initially imported RESOURCE
5. if Alpha-channel ought be processed under [4], an option from { COLOR_FORMAT_ARGB_RAW | COLOR_FORMAT_ARGB_NORMALIZE }-Color processing methods is to be used in
6. yet errors may appear { ERR_RESOURCE_UNSUPPORTED_TYPE | ... } and ResetLastError(); ... GetLastError(); ought be used accordingly with further debugging details.
7. upon error-free progress up to [6], one may try to deploy the such prepared RESOURCE for use in an { OBJ_BITMAP_LABEL | OBJ_BITMAP } graph-objects.

Given some previous experience with curious color-management artifacts with overlaying objects one atop another, with arbitrarily setup HSV-coded colours, the GUI results need not easily yield to an expected and/or pleasing visual composition ( in commercial projects my team has rather used an external, remote GUI-Display & MMI-Interactions Facility ( independent remote Trading Terminal with multi-windowed, fully independent, composable MVC-architecture ), that is under a full programmable-control, irrespective of MT4/MQL4 facilities both in Linux / Windows ecosystems ). enter image description here

user3666197
  • 1
  • 6
  • 50
  • 92
  • Thank you so much more for your more clearly and more informative reply. **#0** and **#1** - Can you make a example for me, please? I just need be know how could I use Bitmap object alpha. – Max-Enrik Apr 18 '17 at 14:47
  • Could you kindly confirm some your previous use-case which was implemented with an alpha-channel feature? You seem to have some more extensive non-MQL4 experience to borrow from. Feel free to show some examples, where you have used bitmap graphics with actively using Alpha-channel, to start from, ok? – user3666197 Apr 18 '17 at 15:23
1

Alpha channel bitmaps must be set to #resource or not displayed. This is not found in the MQL4 documentation, but it was the only way it worked for me.

Example - If your image is located inside the /TERMINAL/MQL4/Images/ ... ... Then you would use the following: #resource "\\Images\\alpha.bmp" and then you can call #define filename "::Images\\alpha.bmp"

Then add the image to the chart using "filename" as the path.

  • 3
    While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value. – Donald Duck Dec 16 '17 at 19:54