forked from nique_372/GrapichsByLeo
//+------------------------------------------------------------------+
| |
//| Canvas.mqh |
| |
//| Copyright 2025, Niquel Mendoza. |
| |
//| https://www.mql5.com/es/users/nique_372/news |
| |
//+------------------------------------------------------------------+
| |
#property copyright "Copyright 2025, Niquel Mendoza."
| |
#property link "https://www.mql5.com/es/users/nique_372/news"
| |
#property strict
| |
| |
| |
#ifndef CANVAS_CANVAS_CUSTOM_BY_LEO_MQH
| |
#define CANVAS_CANVAS_CUSTOM_BY_LEO_MQH
| |
| |
#include <Canvas\\Canvas.mqh>
| |
| |
//+------------------------------------------------------------------+
| |
//| |
| |
//+------------------------------------------------------------------+
| |
class CCanvasCustom : public CCanvas
| |
{
| |
public:
| |
| |
//---
| |
__forceinline ENUM_OBJECT ObjectType() const { return m_objtype; }
| |
__forceinline bool TextOuTF(int x, int y, string text, const uint clr, uint alignment = 0) { return ::TextOut(text, x, y, alignment, m_pixels, m_width, m_height, clr, m_format);}
| |
void GetPixelsArray(uint& out_array_pixels[]) const;
| |
void SetPixelsArray(const uint& src_array_px[]);
| |
__forceinline int GetIndex(int x, int y) { return (y * m_width + x); }
| |
__forceinline int TotalPixels() const { return ::ArraySize(m_pixels); }
| |
__forceinline string RealResourceName() const { return StringSubstr(m_rcname, 2);}
| |
| |
| |
//---
| |
using CCanvas::PixelSet;
| |
uint PixelSet(const int index, uint clr) { return(m_pixels[index] = clr); }
| |
| |
using CCanvas::PixelGet;
| |
__forceinline uint PixelGet(const int index) const { return (m_pixels[index]); }
| |
| |
//---
| |
inline void PixelDecompress(const int px, int&x, int&y);
| |
};
| |
| |
//+------------------------------------------------------------------+
| |
void CCanvasCustom::GetPixelsArray(uint &out_array_pixels[]) const
| |
{
| |
::ArrayCopy(out_array_pixels, m_pixels);
| |
}
| |
//+------------------------------------------------------------------+
| |
void CCanvasCustom::SetPixelsArray(const uint &src_array_px[])
| |
{
| |
if(src_array_px.Size() != m_pixels.Size())
| |
return; // No son iguales
| |
::ArrayCopy(m_pixels, src_array_px);
| |
}
| |
| |
//+------------------------------------------------------------------+
| |
inline void CCanvasCustom::PixelDecompress(const int px, int &x, int &y)
| |
{
| |
y = int(px / m_width);
| |
x = (px - (y * m_width));
| |
}
| |
| |
//+------------------------------------------------------------------+
| |
#endif
| |
//+------------------------------------------------------------------+
|