Canvas is cool! - page 88

 
Vitaliy Kuznetsov #:

I also noticed an error

This image caused an error. It is definitely a PNG, but it has no DPI in the data

//upd. Some of them also have no PDI data, but they work.

As I've already written that PNG decompression algorithm was not developed by me, I'm Zorro 7 years ago. To be more precise, he must have ported it from some C++ code. Moreover, this code always gave an error, and I just bypassed this error by simply ignoring it, after which decompression worked. That's why there may be some joints. I didn't understand the specification of the PNG format and its versions. Maybe you need to dive into this format or jpg format in more detail.

Especially this png file is crooked with squares without transparency with 8-bit colour mask instead of 24-bit.

 
Renat Akhtyamov setting indicators....

like this

I suppose it will go down well in the market.

That's why I made an example with parsing and scaling of icons on transparent background.


 
Nikolai Semko #:

As I've already written, the PNG decompression algorithm was developed not by me, but by Zorro 7 years ago. To be more precise, he must have ported it from some C++ code. Moreover, this code always gave an error, and I just bypassed this error by simply ignoring it, after which decompression worked. That's why there may be some joints. I didn't understand the specification of the PNG format and its versions. Perhaps you need to dive into this format or the jpg format in more detail.

Especially this png file is crooked with squares without transparency with 8-bit colour mask instead of 24-bit.

Nikolai Semko #:

I tried it. I noticed squares only in case of resizing. That's why my resize algorithm is probably not perfect. I've already written once that this algorithm was created on the fly literally in half a day quite a long time ago. Now I would do this algorithm quite differently. But, unfortunately, I don't have time yet.

I understand myself that writing a code for 3+ is a day and for 5+ it is a month. And if the project is large, the terms can be in even larger ranges.

On what we have, thank you. This is enough for now.

 

Is there any way in kanvas to fill the screen with a circular gradient from the centre?

There was an example of a vertical gradient here - https://www.mql5.com/ru/code/31689

 
Vitaliy Kuznetsov #:

Does canvas have a way to fill the screen with a circular gradient from the centre?

There was an example of a vertical gradient here - https://www.mql5.com/ru/code/31689

it's easy to do.
you only need one formula:

R2 = X2+Y2

I think I even gave the function

 
Vitaliy Kuznetsov #:

Does canvas have a way to fill the screen with a circular gradient from the centre?

There was an example of a vertical gradient here - https://www.mql5.com/ru/code/31689

you can use this option:

void iCanvas::RadiusGrad(double x, double y, double r, uint clr_center, uint clr_end){
   int x_left = Floor(x-r);
   int x_right = Ceil(x+r);
   int y_top = Floor(y-r);
   int y_bottom = Ceil(y+r);
   double r2=r*r;
   if (x_left<0) x_left = 0;
   if (x_left>=m_width) return;
   if (x_right>m_width) x_right = m_width;
   if (x_right<0) return;
   
   if (y_top<0) y_top = 0;
   if (y_top>=m_height) return;
   if (y_bottom>m_height) y_bottom = m_height;
   if (y_bottom<0) return;
   
   argb c1,c2, c;
   c1.clr =clr_center;
   c2.clr =clr_end;
   
   for(int i_y=y_top;i_y<y_bottom;i_y++) {
      for(int i_x=x_left;i_x<x_right;i_x++) {
         int adr = i_y*m_width+i_x;
         double r1 = (i_x-x)*(i_x-x)+(i_y-y)*(i_y-y);
         if (r1<=r2) {
            double k = sqrt(r1)/r;
            for (int i=0;i<4;i++) c.c[i] = uchar(c1.c[i] + k*((int)c2.c[i]-c1.c[i]));
            MixColor(c.clr,m_pixels[adr]);
         }
      }
   }
}
gradient goes also by alpha channel (transparency)
Files:
 
Nikolai Semko #:

you can use this option:

gradient goes also by alpha channel(transparency)

Thanks, I'll give it a try.

 

Nikolai, hi!

Once I asked you to create sliders to make it convenient to choose the period of viewing the graph

I meant this:


very convenient!
 
Renat Akhtyamov #:

Nikolai, hi!

Once I asked you to create sliders to make it convenient to choose the period of viewing the graph

I meant this:


very convenient!
Firstly, it's not very convenient (IMHO).
Secondly, such realisations are time-consuming
 
Nikolai Semko #:
Firstly, it is not very convenient (IMHO)
The thing is that when implementing something like this, you will inevitably face a catastrophic lack of slider length.
As a rule, this is implemented in a single slider, not in one, the width of which can be changed by dragging the button by its edges, thus changing the scale. But this approach does not solve the problem of slider length, although it is more convenient.