BSEImg.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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(CRect); // constructor
  12. CBSEImg(const CBSEImg&); // copy constructor
  13. CBSEImg(CBSEImg*); // copy constructor
  14. CBSEImg& operator=(const CBSEImg&); // =operator
  15. virtual ~CBSEImg(); // destructor
  16. // sterilizations
  17. void Serialize(CArchive& ar);
  18. //virtual void Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode);
  19. // image rectangle
  20. CRect GetImageRect() const { return m_rectImage; }
  21. void SetImageRect(const CRect& a_rectImage);
  22. int GetWidth() { return m_rectImage.Width(); }
  23. int GetHeight() { return m_rectImage.Height(); }
  24. // how to use this value??
  25. CSize GetImageSize() const { return m_rectImage.Size(); }
  26. // image data
  27. void InitImageData(int imgwidth, int imgheight);
  28. BYTE* GetImageDataPointer() const { return m_pnImageData; }
  29. void SetImageData(BYTE* a_pnImageData,int imgwidth,int imgheight);
  30. void SetImageDataPointer(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. void SetBSEValue(const int a_nX, const int a_nY, int value);
  41. int GetValueDirect(const CPoint& a_position) const;
  42. inline int GetValueDirectF(int inX, int inY) const
  43. {
  44. return ((inX >= 0) && (inX < m_rectImage.Width()) && (inY >= 0) && (inY < m_rectImage.Height()))
  45. ? m_pnImageData[inY * m_rectImage.Width() + inX]
  46. : 0;
  47. }
  48. bool DoesContainPixelValue(int inValue, int a_nPixel = 1) const;
  49. // cal area
  50. DWORD CalArea();
  51. protected:
  52. CBSEImg();
  53. // image rectangle
  54. CRect m_rectImage;
  55. // image data
  56. BYTE* m_pnImageData;
  57. // BSE chart
  58. WORD m_nBSEChart[MAXBYTE];
  59. void InitChartData();
  60. // cleanup
  61. void Cleanup();
  62. // Initialization
  63. void Init();
  64. // duplication
  65. void Duplicate(const CBSEImg& a_oSource);
  66. };
  67. typedef std::shared_ptr<CBSEImg> __declspec(dllexport) CBSEImgPtr;
  68. typedef std::vector<CBSEImgPtr> __declspec(dllexport) CBSEImgPtrVec;
  69. }