BSEImg.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #pragma once
  2. #include "afx.h"
  3. #include "XMLSerialization.h"
  4. namespace OTSDATA {
  5. // CBSEImage command target
  6. class __declspec(dllexport) CBSEImg : public CObject
  7. {
  8. protected:
  9. DECLARE_SERIAL(CBSEImg)
  10. public:
  11. CBSEImg(); // constructor
  12. CBSEImg(CRect); // constructor
  13. CBSEImg(const CBSEImg&); // copy constructor
  14. CBSEImg(CBSEImg*); // copy constructor
  15. CBSEImg& operator=(const CBSEImg&); // =operator
  16. virtual ~CBSEImg(); // destructor
  17. // sterilizations
  18. void Serialize(CArchive& ar);
  19. //virtual void Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode);
  20. // image rectangle
  21. CRect GetImageRect() const { return m_rectImage; }
  22. void SetImageRect(const CRect& a_rectImage);
  23. int GetWidth() { return m_rectImage.Width(); }
  24. int GetHeight() { return m_rectImage.Height(); }
  25. // how to use this value??
  26. CSize GetImageSize() const { return m_rectImage.Size(); }
  27. // image data
  28. void InitImageData(int imgwidth, int imgheight);
  29. BYTE* GetImageDataPointer() const { return m_pnImageData; }
  30. void SetImageData(BYTE* a_pnImageData,int imgwidth,int imgheight);
  31. // BSE chart
  32. // NOTE: to use chart data, call SetChartData method first!
  33. void SetChartData();
  34. WORD* GetBSEChart() { return m_nBSEChart; }
  35. long CalBSEChartHigh();
  36. long CalBSEChartLow();
  37. // cal BSE value by position
  38. int GetBSEValue(const CPoint& a_position);
  39. int GetBSEValue(const int a_nX, const int a_nY);
  40. int GetValueDirect(const CPoint& a_position) const;
  41. inline int GetValueDirectF(int inX, int inY) const
  42. {
  43. return ((inX >= 0) && (inX < m_rectImage.Width()) && (inY >= 0) && (inY < m_rectImage.Height()))
  44. ? m_pnImageData[inY * m_rectImage.Width() + inX]
  45. : 0;
  46. }
  47. bool DoesContainPixelValue(int inValue, int a_nPixel = 1) const;
  48. // cal area
  49. DWORD CalArea();
  50. protected:
  51. // image rectangle
  52. CRect m_rectImage;
  53. // image data
  54. BYTE* m_pnImageData;
  55. // BSE chart
  56. WORD m_nBSEChart[MAXBYTE];
  57. void InitChartData();
  58. // cleanup
  59. void Cleanup();
  60. // Initialization
  61. void Init();
  62. // duplication
  63. void Duplicate(const CBSEImg& a_oSource);
  64. };
  65. typedef std::shared_ptr<CBSEImg> __declspec(dllexport) CBSEImgPtr;
  66. typedef std::vector<CBSEImgPtr> __declspec(dllexport) CBSEImgPtrVec;
  67. }