RealImage.hpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. //**************************************************************************
  2. // FILENAME : RealImage.h
  3. //
  4. // CLASSES : RealImage
  5. //
  6. // ECOMPACS DICOM Network Transport Libraries * Version 0.1 Beta
  7. //**************************************************************************
  8. #ifndef _DICOM_REALIMAGE_
  9. #define _DICOM_REALIMAGE_
  10. #include "LookupTable.hpp"
  11. class RealImage8;
  12. //**************************************************************************
  13. // class RealImage
  14. //**************************************************************************
  15. class DICOM_API RealImage
  16. {
  17. public:
  18. enum RotateAngle { alpha0, alpha90, alpha180, alpha270 };
  19. char PhotometricInterpretation[65];
  20. int NumberOfFrames;
  21. int FrameIndex;
  22. int PixelRepresentation; // = 1 : signed, = 0 : unsigned
  23. LookupTable LUT;
  24. RGBQUAD Colors[256];
  25. public:
  26. ImageProcess * ImgProc;
  27. UINT32 lParam;
  28. UINT32 ImageHandle0; // Used for display system, such as HBITMAP or HDIB
  29. UINT32 ImageHandle1; // Used for display system, such as HPALETTE or Palette index
  30. UINT32 ImageHandle2; // Other handles
  31. UINT32 ImageHandle3;
  32. public:
  33. RealImage (
  34. int width, int height, int depth,
  35. int min, int max,
  36. int minSet, int maxSet,
  37. float offset = 0, float slope = 1);
  38. RealImage (const RealImage & OrgRealImage);
  39. virtual ~RealImage ();
  40. //************************************************************************
  41. // Purpose: to get the 8 bits image (240 gray levels) from the image data.
  42. //************************************************************************
  43. virtual unsigned char * GetPixmap (BOOL relativMode) const = 0;
  44. virtual unsigned char * GetPixmap (unsigned char *colortable) const = 0;
  45. virtual unsigned char * GetPixmapEx (unsigned char *colortable) const = 0;
  46. virtual unsigned char * GetPixmap (void) const = 0;
  47. virtual RealImage8 * Remap (void) const ;
  48. virtual void Invert (); // invert the original image
  49. virtual void FlipVertical (void) = 0;
  50. virtual void FlipHorizontal (void) = 0;
  51. virtual void Rotate (RotateAngle angle) = 0; // rotates the original image
  52. int GetMinImage () const {return MinImage;}; // gets the minimum pixel value of the image
  53. int GetMaxImage () const {return MaxImage;};
  54. int GetMinSet () const {return MinSet;}; // gets the minimum pixel value of the image
  55. int GetMaxSet () const {return MaxSet;};
  56. int GetDepth () const {return Depth;}; // gets the depth
  57. int GetWidth () const {return Width; }; // gets the width
  58. int GetHeight() const {return Height;};
  59. float GetIntercept() const {return Intercept;}; // gets the Intercept from 0 (pixel value)
  60. float GetSlope () const {return Slope;}; // get the slope of the gray levels
  61. //************************************************************************
  62. // Purpose: returns the value of pixel (x,y).
  63. // Purpose: set the value of pixel (x,y).
  64. //************************************************************************
  65. virtual int GetPixelValue (int x, int y) const = 0;
  66. virtual void SetPixelValue (int x, int y, short val) = 0;
  67. //************************************************************************
  68. // Purpose: returns the value of pixel (x,y) without calibration factor
  69. // Purpose: set the value of pixel (x,y) without calibration factor
  70. //************************************************************************
  71. virtual short GetInternalPixel (int x, int y) const = 0;
  72. virtual void SetInternalPixel (int x, int y, short val) = 0;
  73. //************************************************************************
  74. // Purpose: an abstract method for returning a image.
  75. //************************************************************************
  76. virtual unsigned short * GetImage () const = 0;
  77. virtual UINT32 GetImageLength () const = 0;
  78. virtual unsigned short * Attach (void * PixelData) = 0;
  79. virtual unsigned short * Detach () = 0;
  80. virtual RealImage * GetImagePart (const DRect * lpRect) const = 0;
  81. // (x, y) is top-left corner
  82. virtual BOOL SetImagePart (int x, int y, const RealImage * realImage, int nOPCode = 0) = 0;
  83. virtual BOOL SaveAsWindowsBitmap (const char * filename) const = 0;
  84. virtual BOOL SaveAsRaw (const char * filename) const = 0;
  85. virtual void Scale (UINT NewWidth, UINT NewHeight) = 0;
  86. virtual void CalcHistogram (UINT32 HistogramData[256]) ;
  87. virtual void CalcMinMaxPixelValue (void) ;
  88. virtual HANDLE CreateDIB (void) const = 0;
  89. virtual HBITMAP CreateBitmap (void) const = 0;
  90. private:
  91. friend class ImageProcess;
  92. friend class DICOMImage;
  93. protected:
  94. int Width;
  95. int Height;
  96. int Depth;
  97. float Intercept; // intercept from 0
  98. float Slope; // factor
  99. int MinImage; // min pixel raw value of the image
  100. int MaxImage; // max pixel raw value of the image
  101. int MinSet; // min pixel value of the set of images
  102. int MaxSet; // max pixel value of the set of images
  103. };
  104. #endif // _DICOM_REALIMAGE_