RealImage8.hpp 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. //**************************************************************************
  2. // FILENAME : RealImg8.h
  3. //
  4. // CLASSES : RealImage8
  5. //
  6. // ECOMPACS DICOM Network Transport Libraries * Version 0.1 Beta
  7. //**************************************************************************
  8. #ifndef _DICOM_REALIMAGE_8_
  9. #define _DICOM_REALIMAGE_8_
  10. #include "RealImage.hpp"
  11. //**************************************************************************
  12. // class RealImage8
  13. //**************************************************************************
  14. class DICOM_API RealImage8 : public RealImage
  15. {
  16. public:
  17. RealImage8 (unsigned char *theImage,
  18. int width, int height, int depth, int min, int max,
  19. int minSet, int maxSet, float offset = 0, float slope = 1);
  20. RealImage8 (const RealImage8 & OrgImage8);
  21. virtual ~RealImage8();
  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) = (char)((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; }
  57. virtual unsigned short * Attach (void * pixelData)
  58. { unsigned short * t = (unsigned short *) PixelData; PixelData = (unsigned char *) 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 char * PixelData;
  74. };
  75. #endif // _DICOM_REALIMAGE_8_