Download MetaTrader 5

Scaling Bitmap

To add comments, please log in or register
Ex Ovo Omnia
3416
Ex Ovo Omnia  

How do you guys rescale the bitmap label objects in your graphical interfaces, if the display DPI settings differs from default?

It seems like a simple question, but I am not an expert for picture formats, so some help would be appreciated. I can rescale the other objects, but I got no idea how to treat the bitmaps.

Amir Yacoby
1355
Amir Yacoby  

One way is to scale into groups:

96 DPI base group (usually 16 pixels images)
120 DPI 1.25  (usually 20 pixel images)
144 DPI 1.5    (usually 24 pixel images)
192 DPI 2       (usually 32 pixel images)
288 DPI 3   
384 DPI 4       (usually 64 pixel images)

You calculate first upon your DPI what is the closest lower group and scale to that (you have icon folders for each group already scaled)
and just load from the correct group.

I'm no expert in pictures also, but the groups are something I read that microsoft use.





Ex Ovo Omnia
3416
Ex Ovo Omnia  
Amir Yacoby:

One way is to scale into groups:

96 DPI base group (usually 16 pixels images)
120 DPI 1.25  (usually 20 pixel images)
144 DPI 1.5    (usually 24 pixel images)
192 DPI 2       (usually 32 pixel images)
288 DPI 3   
384 DPI 4       (usually 64 pixel images)

You calculate first upon your DPI what is the closest lower group and scale to that (you have icon folders for each group already scaled)
and just load from the correct group.

I'm no expert in pictures also, but the groups are something I read that microsoft use.


Thank you, that could be a way indeed. 

However even Microsoft must scale icons when the proper resolutions are missing, and in fact the icons in the MT terminal toolbar are also upscaled in a raw manner.

I believed I could also supply a single resolution bitmap and scale it on the fly, it would be safer to handle, and the image size would naturally fit to the already scaled layout.

Amir Yacoby
1355
Amir Yacoby  
Ex Ovo Omnia:


Thank you, that could be a way indeed. 

However even Microsoft must scale icons when the proper resolutions are missing, and in fact the icons in the MT terminal toolbar are also upscaled in a raw manner.

I believed I could also supply a single resolution bitmap and scale it on the fly, it would be safer to handle, and the image size would naturally fit to the already scaled layout.

Maybe, I just tried to use some upscaling software I downloaded which you can take an icon and upscale or downscale to the size you want. There is always a loss in the quality of the icon.

I don't know of a way to upscale on the fly without losing quality, you mean an algorithm?

It's not a 16 mega pixel picture that can be zoomed in, it's just 16x16 pixels and it is very hard to upscale 4 times (to 64).

If I think about it it is something very hard to do, not sure if possible.
Ex Ovo Omnia
3416
Ex Ovo Omnia  
Amir Yacoby:
Maybe, I just tried to use some upscaling software I downloaded which you can take an icon and upscale or downscale to the size you want. There is always a loss in the quality of the icon.

I don't know of a way to upscale on the fly without losing quality, you mean an algorithm?

It's not a 16 mega pixel picture that can be zoomed in, it's just 16x16 pixels and it is very hard to upscale 4 times (to 64).

If I think about it it is something very hard to do, not sure if possible.

Sure no, I am not aiming the quality but the proper image size. And i do not think only of icons, but of any size of bitmap labels.

I would like to achieve solution, that i could scale the entire graphic layout according to the DPI. So far I have it working for the graphic objects but images. They are my problem.

Marco vd Heijden
Moderator
6138
Marco vd Heijden  

You can create multiple of the same images of different sizes then load the appropriate one depending on screen size.

The same as with Android development for small phones and ipad / etc

Ex Ovo Omnia
3416
Ex Ovo Omnia  
Marco vd Heijden:

You can create multiple of the same images of different sizes then load the appropriate one depending on screen size.


Yes, that is what Amir suggested in the 2nd post. That is fine, just it wont scale properly with non-standard user DPI settings (like 231 DPI) and it always includes additional graphic editor effort.

Amir Yacoby
1355
Amir Yacoby  

I really think there is no escape other then creating multiple sized images. 
Even if just examine the ObjectCreate order for creating a bitmap label object, there is nothing that can intervene in the image size (except for viewing a part of the image which is possible).

Scaling images from my limited knowledge is done that way everywhere, it does not target any non standard user DPI (like 231) but to groups of DPI with ready made image which is the closest to 231.

Taras Slobodyanik
22884
Taras Slobodyanik  
There is another way - to draw bitmaps yourself - vector graphics the best solution)
Amir Yacoby
1355
Amir Yacoby  
Taras Slobodyanik:
There is another way - to draw bitmaps yourself - vector graphics the best solution)

Yes, but you need some talent and a lot of work to draw a bitmap of for instance coins image in one size. 
How do you scale a vector graphic in mql5?

Taras Slobodyanik
22884
Taras Slobodyanik  
Amir Yacoby:

Yes, but you need some talent and a lot of work to draw a bitmap of for instance coins image in one size. 
How do you scale a vector graphic in mql5?

Create a canvas of the right size — draw a circle — fill it with the color of a shadow — then draw a circle with a shift — fill it with the color of gold.
In the center we print a symbol of currency — the coin is ready.

(the second circle can be filled with a gradient color)

123
To add comments, please log in or register