You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
well that's true but it Is only for simple images, and still not an easy work.
If you have just simple icons that are composed of circles, triangles and so on then of course it can be done.
The problem is painting more complex stuff.
I don't say it's bad, I considered that way too but found it a little limited for my needs (going this way means bmp images can no more be used by this kind of GUI setting).
** P.S.: Maybe if there were image libraries available of MQL5 canvas made bitmaps that someone can provide it would be more worthwhile in my case.
Well, you can type in Google "Pixel art scaling algorithms c++" and use what you like in your mql-code.
Thanks for that Taras. But it is for scaling algorithms of a ready made bitmap, or I missed something?
for instance, classes that inherit CCanvas like this:In my eyes the disadvantage of vectors is their creation. If I was to settle for simple images, it would be the best solution, I agree. And it might fit the OPO.
But what I am missing is algorithms creating the bitmaps themselves, for instance an algorithm for creating a clock icon, or things like that.
If there was a library of ready made images built from canvas bitmaps in MQL5 (or other language that can be translated to MQL algorithm) that would be perfect.
class CCanvasClock : public CCanvas ...
and then using it in the desired width,height
and so on for many images.
The advantage for it is color and size enhancements are easy, and the drawback is their creation.
Here are some links that I found.
Of course, this requires rework and testing, but I do not see any problems in it.
Bilinear scaling (interpolation) byte by byte 24-bit images
https://stackoverflow.com/questions/21250099/c-bilinear-scaling-interpolation-byte-by-byte
Bicubic Interpolation for Image Resizing
https://www.gamedev.net/topic/229145-bicubic-interpolation-for-image-resizing/
Here are some links that I found.
Of course, this requires rework and testing, but I do not see any problems in it.
Bilinear scaling (interpolation) byte by byte 24-bit images
https://stackoverflow.com/questions/21250099/c-bilinear-scaling-interpolation-byte-by-byte
Bicubic Interpolation for Image Resizing
https://www.gamedev.net/topic/229145-bicubic-interpolation-for-image-resizing/
Nice info Taras.
But again, those algorithms take a bitmap as their input parameter, not a bmp file.
How do you make this bitmap in the first place?
For instance, as I understand, these algos take a bitmap of a cat representation, and they can rescale the cat image to the desired size (I think it will lose a lot of quality, but it's a different story).
How do you create this cat representation in the first place in order to give it to the function?
Ok, made some reading and here is what I came up with:
Vector graphics and bitmaps are two different things. Bitmaps are what Taras pointing at. They are arrays of two dimensions of bits, representing an image. Those bitmaps are resolution dependent,
and though you can rescale them (with these kind of algorithms) you will always lose quality and in our case of 16x16 rescaled to 64x64 it is 4 times so you will lose a lot of quality.
Vector graphics on the other hand is something different. It is not built from bit mapping, but from mathematichal smaller shapes (like the example Taras gave to creating a coins image using circles and filling with colors) - lines, curves, triangles etc. Those are fully scalable and do not lose quality. The way to build them is using Canvas class, but then again, it will take some effort to build nice images.
This is why I pointed out that a library of vector graphics based on CCAnvas can be useful.
Nice info Taras.
But again, those algorithms take a bitmap as their input parameter, not a bmp file.
How do you make this bitmap in the first place?
Read about:
ResourceCreate ();
ResourceReadImage ();
ResourceSave ();
Read about:
ResourceCreate ();
ResourceReadImage ();
ResourceSave ();
Again, I already read those before, but in all those functions the data[] array is an input parameter, not an output one, which means you still need to create it somehow and supply it to those functions. There is not for my best knowledge a function that takes a bmp image file and outputs a data[] array.
The ResourceReadImage() should have done it, but it says in documentation that the data[] is an input.
Well, I tried ResourceReadImage() and you were right, Taras. Seems like an error in documentation, but it fills the data[] array.
Now there is only the scaling of images.
Scaling with non integer factor is problematic, its not done correctly.
For instance, if you have a control which is a rectangular label of width=10 and you scale it by a factor of 1.6 you get the new width = 16.
If for instance, you have inside that control, some dependent controls, let's say 5 of them, each is 1 pixel width and between each 2 controls 1 pixel of space,
so you have something like (subcontrol1 1px,space 1px,subcontrol2 1px,space 1 px.. subcontrol5 1px,space 1px) then you scale it also by 1.6 and you get each component to a new width of
2 px (because 1px * 1.6 scale factor = 2 right?) so you have 20 pixels in the dependent controls (5 controls of 2px and 5 spaces of 2px).
The only thing that works correctly is scaling by an integer factor.