RealImageRGB.hpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. //**************************************************************************
  2. // FILENAME : RealImageRGB.h
  3. //
  4. // CLASSES : RealImageRGB
  5. //
  6. //* ECOMPACS DICOM Network Transport Libraries * Version 0.1 Beta
  7. //**************************************************************************
  8. #ifndef _DICOM_REALIMAGE_RGB_
  9. #define _DICOM_REALIMAGE_RGB_
  10. #include "RealImage.hpp"
  11. //**************************************************************************
  12. // class RealImageRGB
  13. //**************************************************************************
  14. class DICOM_API RealImageRGB : public RealImage
  15. {
  16. public:
  17. RealImageRGB (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. RealImageRGB (const RealImageRGB & OrgImageRGB);
  21. virtual ~RealImageRGB();
  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. virtual RealImage8 * Remap (void) const;
  38. //************************************************************************
  39. // Purpose: returns the value of pixel (x,y).
  40. // Purpose: set the value of pixel (x,y).
  41. //************************************************************************
  42. int GetPixelValue (int x, int y) const
  43. { return (int)((float)(*(PixelData + ((long)y) * Width + x) * Slope) + Intercept); };
  44. void SetPixelValue (int x, int y, short val)
  45. { *(PixelData + ((long)y) * Width + x) = (char)((float)(val - Intercept) / Slope); };
  46. //************************************************************************
  47. // Purpose: returns the value of pixel (x,y) without calibration factor
  48. // Purpose: set the value of pixel (x,y) without calibration factor
  49. //************************************************************************
  50. short GetInternalPixel (int x, int y) const
  51. { return (short) *(PixelData + ((long)y) * Width + x); };
  52. void SetInternalPixel (int x, int y, short val);
  53. //************************************************************************
  54. // Purpose: an abstract method for returning a image.
  55. //************************************************************************
  56. unsigned short* GetImage () const { return (unsigned short *) PixelData;};
  57. virtual UINT32 GetImageLength () const { return Width * Height * 3; }
  58. virtual unsigned short * Attach (void * pixelData)
  59. { unsigned short * t = (unsigned short *) PixelData; PixelData = (unsigned char *) pixelData; return t; }
  60. virtual unsigned short * Detach ()
  61. { unsigned short * t = (unsigned short *) PixelData; PixelData = NULL; return t; }
  62. virtual RealImage * GetImagePart (const DRect * lpRect) const;
  63. // (x, y) is top-left corner
  64. virtual BOOL SetImagePart (int x, int y, const RealImage * realImage, int nOPCode = 0);
  65. virtual BOOL SaveAsWindowsBitmap (const char * filename) const ;
  66. virtual BOOL SaveAsRaw (const char * filename) const ;
  67. virtual void Scale (UINT NewWidth, UINT NewHeight);
  68. virtual HANDLE CreateDIB (void) const ;
  69. virtual HBITMAP CreateBitmap (void) const;
  70. private:
  71. friend class ImageProcess;
  72. friend class DICOMImage;
  73. private:
  74. unsigned char * PixelData;
  75. void ConvertTo240 (RGBQUAD * origCol, RGBQUAD * convertedCol);
  76. };
  77. #endif // _DICOM_REALIMAGE_RGB_