BSEImg.h 2.3 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. // image rectangle
  19. CRect GetImageRect() const { return m_rectImage; }
  20. void SetImageRect(const CRect& a_rectImage);
  21. int GetWidth() { return m_rectImage.Width(); }
  22. int GetHeight() { return m_rectImage.Height(); }
  23. // how to use this value??
  24. CSize GetImageSize() const { return m_rectImage.Size(); }
  25. // image data
  26. void InitImageData(int imgwidth, int imgheight);
  27. BYTE* GetImageDataPointer() const { return m_pnImageData; }
  28. void SetImageData(BYTE* a_pnImageData,int imgwidth,int imgheight);
  29. void SetImageDataPointer(BYTE* a_pnImageData, int imgwidth, int imgheight);
  30. // BSE chart
  31. // NOTE: to use chart data, call SetChartData method first!
  32. void InitChartData();
  33. WORD* GetBSEChart() { return m_nBSEChart; }
  34. long CalBSEChartHigh();
  35. long CalBSEChartLow();
  36. // cal BSE value by position
  37. int GetBSEValue(const CPoint& a_position);
  38. int GetBSEValue(const int a_nX, const int a_nY);
  39. void SetBSEValue(const int a_nX, const int a_nY, int value);
  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. CBSEImg();
  52. // image rectangle
  53. CRect m_rectImage;
  54. // image data
  55. BYTE* m_pnImageData;
  56. // BSE chart
  57. WORD m_nBSEChart[MAXBYTE];
  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. }