#pragma once #include "afx.h" #include "XMLSerialization.h" namespace OTSDATA { // CBSEImage command target class __declspec(dllexport) CBSEImg : public CObject { protected: DECLARE_SERIAL(CBSEImg) public: CBSEImg(); // constructor CBSEImg(CRect); // constructor CBSEImg(const CBSEImg&); // copy constructor CBSEImg(CBSEImg*); // copy constructor CBSEImg& operator=(const CBSEImg&); // =operator virtual ~CBSEImg(); // destructor // sterilizations void Serialize(CArchive& ar); //virtual void Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode); // image rectangle CRect GetImageRect() const { return m_rectImage; } void SetImageRect(const CRect& a_rectImage); int GetWidth() { return m_rectImage.Width(); } int GetHeight() { return m_rectImage.Height(); } // how to use this value?? CSize GetImageSize() const { return m_rectImage.Size(); } // image data void InitImageData(int imgwidth, int imgheight); BYTE* GetImageDataPointer() const { return m_pnImageData; } void SetImageData(BYTE* a_pnImageData,int imgwidth,int imgheight); // BSE chart // NOTE: to use chart data, call SetChartData method first! void SetChartData(); WORD* GetBSEChart() { return m_nBSEChart; } long CalBSEChartHigh(); long CalBSEChartLow(); // cal BSE value by position int GetBSEValue(const CPoint& a_position); int GetBSEValue(const int a_nX, const int a_nY); int GetValueDirect(const CPoint& a_position) const; inline int GetValueDirectF(int inX, int inY) const { return ((inX >= 0) && (inX < m_rectImage.Width()) && (inY >= 0) && (inY < m_rectImage.Height())) ? m_pnImageData[inY * m_rectImage.Width() + inX] : 0; } bool DoesContainPixelValue(int inValue, int a_nPixel = 1) const; // cal area DWORD CalArea(); protected: // image rectangle CRect m_rectImage; // image data BYTE* m_pnImageData; // BSE chart WORD m_nBSEChart[MAXBYTE]; void InitChartData(); // cleanup void Cleanup(); // Initialization void Init(); // duplication void Duplicate(const CBSEImg& a_oSource); }; typedef std::shared_ptr __declspec(dllexport) CBSEImgPtr; typedef std::vector __declspec(dllexport) CBSEImgPtrVec; }