Is it possible to output text on multiple lines in an OBJ_TEXT object? - page 5

 
Nikolai Semko:

There's another problem here.
If you don't have access to the code that generated the kanvas, then you don't have access to the resource of that kanvas either. You can see the list of bitmap objects, but not the list of resources. If you don't know the resource name, you can only find it out by matching or brute-force, which is beyond practical use.
How do you get an array of points for recognition? If only through a screenshot, which is also nonsense.
Or am I wrong?

The code is of course mine, which means it's open source. I just thought that if there's a date on the screen, why else save it somewhere if you can get it ... Provided you can get it. Ha-ha-ha, "beautifully" said.

Well sort of like how you can get a string from a text field and pull part of the string from there. But, alas, no so no.

 
Andrey Barinov:

The bitmap property has the path to the resource. I don't know if you can get it programmatically.


Exactly. After all, the question was not to get it from an image, but from a resource. And then I myself lost what I was looking for. I'll experiment and see what properties I can get.


It's not working for me...

  string resource = "\\Scripts\\Test\\Canvas\\00.ex5::aaa";     // получили путь к ресурсу созданному другим скриптом

//  if(ObjectGetString(0, "aaa", OBJPROP_BMPFILE, 0, resource))
  if(ObjectSetString(0, "aaa", OBJPROP_BMPFILE, 0, resource))   // работает любая строка, хоть эта, хоть закомментированная выше
   {
    Print(ObjectGetString(0, "aaa", OBJPROP_NAME));             // имя есть
    Print(ObjectGetString(0, "aaa", OBJPROP_BMPFILE));          // путь к ресурсу есть
    Print(ObjectGetString(0, "aaa", OBJPROP_TEXT));             // текста нету.....
    Print(ObjectGetInteger(0, "aaa", OBJPROP_XDISTANCE));       // это значение тоже есть
   }

And how to get an array I can't find. Is it even possible???

 
Alexey Viktorov:

Exactly. After all, the question was not to get from a picture, but from a resource. And then I lost what I was looking for myself. I'm going to experiment and see what properties I can get.


It's not working for me...

And I can't find how to get an array. Is it even possible???

I think ResourceReadImage() or something like that should help

 
Alexey Viktorov:

The code is of course mine, which means it's open. I just thought that if there's a date on the screen, why else save it somewhere when you can get ... Provided you can get it. Ha-ha-ha, nice one.

Well sort of like how you can get a string from a text box and pull part of the string out of it. But, alas, no such thing.

You're really something :))
A suitcase of batteries to a scientific watch is really not the best solution, although creative.
 
Andrey Barinov:
I think ResourceReadImage() or something like that should help

I found it, but nothing worked for me. I tried to convert an array to a string, but the array types don't match. No matter how I twisted it, it didn't work. Maybe I'm doing something wrong, but no new ideas yet.

 
Alexey Viktorov:

I found it, but nothing worked for me. I tried to convert an array to a string, but the array types don't match. No matter how I turned it around, it just won't work. Maybe I'm doing something wrong, but no new ideas yet.

How do I translate pixel colour data into a string? And most importantly, why?
You get a bitmap image and then you can try to recognise it, but that's a separate science :)
 
Nikolai Semko:
You're really something :)))
A suitcase full of batteries for a science clock is really not the best solution, although it is creative.

Nikolai, but it's not a solution that's necessarily applicable. After all, your cartoons are from the same series, beautiful, but without the possibility of application in trading.

 
Andrey Barinov:
How do you translate pixel colour data into a string? And most importantly, why?
You get a bitmap image and then you can try to recognise it, but that's a separate science :)

Ah, well, that's... I don't know.))

In general, I'll probably give up the idea. Maybe it's really not that kind of thing.

 

Forum on trading, automated trading systems and trading strategies testing

Features of mql5 language, subtleties and tricks

fxsaber, 2017.10.31 08:11

// Сохранение Bitmap-объекта в bmp/gif/png-файле (прозрачность не учитывается)
bool BitmapObjectToFile( const long chartID, const string ObjName, const string FileName, const bool FullImage = false )
{  
  const ENUM_OBJECT Type = (ENUM_OBJECT)ObjectGetInteger(chartID, ObjName, OBJPROP_TYPE);  
  bool Res = (Type == OBJ_BITMAP_LABEL) || (Type == OBJ_BITMAP);
             
  if (Res)
  {
    const string Name = __FUNCTION__ + (string)MathRand();

    ObjectCreate(chartID, Name, OBJ_CHART, 0, 0, 0);
    ObjectSetInteger(chartID, Name, OBJPROP_XDISTANCE, -1 e3);
    
    const long chart = ObjectGetInteger(chartID, Name, OBJPROP_CHART_ID);
        
    Res = ChartSetInteger(chart, CHART_SHOW, false) && ObjectCreate(chart, Name, OBJ_BITMAP_LABEL, 0, 0, 0) &&
          ObjectSetString(chart, Name, OBJPROP_BMPFILE, ObjectGetString(chartID, ObjName, OBJPROP_BMPFILE)) &&
          (FullImage || (ObjectSetInteger(chart, Name, OBJPROP_XSIZE, ObjectGetInteger(chartID, ObjName, OBJPROP_XSIZE)) &&
                         ObjectSetInteger(chart, Name, OBJPROP_YSIZE, ObjectGetInteger(chartID, ObjName, OBJPROP_YSIZE)) &&
                         ObjectSetInteger(chart, Name, OBJPROP_XOFFSET, ObjectGetInteger(chartID, ObjName, OBJPROP_XOFFSET)) &&
                         ObjectSetInteger(chart, Name, OBJPROP_YOFFSET, ObjectGetInteger(chartID, ObjName, OBJPROP_YOFFSET)))) &&
                         ChartScreenShot(chart, FileName, (int)ObjectGetInteger(chart, Name, OBJPROP_XSIZE),
                                                          (int)ObjectGetInteger(chart, Name, OBJPROP_YSIZE));
    ObjectDelete(chartID, Name);
  }                    

  return(Res);
}


Application

// Сохраняет в png-файлах все Bitmap-объекты текущего чарта
void OnStart()
{  
  for (int i = ObjectsTotal(0) - 1; i >= 0; i--)
  {
    const string Name = ObjectName(0, i);
    
    BitmapObjectToFile(0, Name, (string)ChartID() + "\\" + Name + ".png");    
  }      
}


SZY The BMP->GIF/PNG file converter is also implemented.

 
Alexey Viktorov:

New question: Can I read text from a resource in a canvas?

For example these lines, or any of them.

Purpose: With the kanvas there is a line that contains a date. This is the date you want to read.

Or use one of the old tried and tested methods, GV, file, graphic or something else.

You can read data from a resource using ResourceReadImage, but to do this you need to write it there using ResourceCreate. The ResourceCreate function only accepts an array of uint data and if we want to write an array of another data type, we have to use union. Declare several arrays of different types in it. After that, we can store any data in the resource, including strings. To convert the string to char type use StringToCharArray and vice versa use CharArrayToString. So, it's not about the kanvas at all, but about the resource into which you can write any type of data with the help of unions.