RealImage16.hpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //**************************************************************************
  2. // FILENAME : RealImage16.h
  3. //
  4. // CLASSES : RealImage16
  5. //
  6. //* ECOMPACS DICOM Network Transport Libraries * Version 0.1 Beta
  7. //**************************************************************************
  8. #ifndef _DICOM_REALIMAGE_16_
  9. #define _DICOM_REALIMAGE_16_
  10. #include "RealImage.hpp"
  11. //**************************************************************************
  12. // class RealImage16
  13. //**************************************************************************
  14. class DICOM_API RealImage16 : public RealImage
  15. {
  16. public:
  17. RealImage16 (unsigned short *theImage,
  18. int width, int height, int depth, int min, int max,
  19. int minSet, int maxSet, float offset = 0, float slope = 1);
  20. RealImage16 (const RealImage16 & OrgImage16);
  21. virtual ~RealImage16();
  22. virtual void Invert ();
  23. virtual void FlipVertical (void) ;
  24. virtual void FlipHorizontal (void) ;
  25. virtual void Rotate (RotateAngle angle) ;
  26. //************************************************************************
  27. // Purpose: to get the 8 bits image (240 gray levels) from the image data.
  28. //************************************************************************
  29. virtual unsigned char * GetPixmap(BOOL relativMode) const;
  30. //************************************************************************
  31. // Purpose: to get the 8 bits image (240 gray levels) from the image data.
  32. // corresponding to the given colortable.
  33. //************************************************************************
  34. virtual unsigned char * GetPixmap (unsigned char *colortable) const;
  35. virtual unsigned char * GetPixmapEx (unsigned char *colortable) const;
  36. virtual unsigned char * GetPixmap (void) const ;
  37. //************************************************************************
  38. // Purpose: returns the value of pixel (x,y).
  39. // Purpose: set the value of pixel (x,y).
  40. //************************************************************************
  41. int GetPixelValue (int x, int y) const
  42. { return (int) ((float)(*(PixelData+ ((long)y)*Width + x) * Slope) + Intercept); };
  43. void SetPixelValue (int x, int y, short val)
  44. { *(PixelData + ((long)y)*Width + x) = (unsigned short)((float)(val - Intercept)/Slope); };
  45. //************************************************************************
  46. // Purpose: returns the value of pixel (x,y) without calibration factor
  47. // Purpose: set the value of pixel (x,y) without calibration factor
  48. //************************************************************************
  49. short GetInternalPixel (int x, int y) const
  50. { return (short) *(PixelData + ((long)y) * Width + x); };
  51. void SetInternalPixel (int x, int y, short val);
  52. //************************************************************************
  53. // Purpose: an abstract method for returning a image.
  54. //************************************************************************
  55. unsigned short* GetImage () const { return (unsigned short *) PixelData; }
  56. virtual UINT32 GetImageLength () const { return Width * Height * 2; }
  57. virtual unsigned short * Attach (void * pixelData)
  58. { unsigned short * t = (unsigned short *) PixelData; PixelData = (unsigned short *) pixelData; return t; }
  59. virtual unsigned short * Detach ()
  60. { unsigned short * t = (unsigned short *) PixelData; PixelData = NULL; return t; }
  61. virtual RealImage * GetImagePart (const DRect * lpRect) const;
  62. // (x, y) is top-left corner
  63. virtual BOOL SetImagePart (int x, int y, const RealImage * realImage, int nOPCode = 0);
  64. virtual BOOL SaveAsWindowsBitmap (const char * filename) const ;
  65. virtual BOOL SaveAsRaw (const char * filename) const ;
  66. virtual void Scale (UINT NewWidth, UINT NewHeight) ;
  67. virtual HANDLE CreateDIB (void) const ;
  68. virtual HBITMAP CreateBitmap (void) const ;
  69. private:
  70. friend class ImageProcess;
  71. friend class DICOMImage;
  72. private:
  73. unsigned short * PixelData;
  74. };
  75. #endif // _DICOM_REALIMAGE_16_