//************************************************************************** // FILENAME : RealImg8.h // // CLASSES : RealImage8 // // ECOMPACS DICOM Network Transport Libraries * Version 0.1 Beta //************************************************************************** #ifndef _DICOM_REALIMAGE_8_ #define _DICOM_REALIMAGE_8_ #include "RealImage.hpp" //************************************************************************** // class RealImage8 //************************************************************************** class DICOM_API RealImage8 : public RealImage { public: RealImage8 (unsigned char *theImage, int width, int height, int depth, int min, int max, int minSet, int maxSet, float offset = 0, float slope = 1); RealImage8 (const RealImage8 & OrgImage8); virtual ~RealImage8(); virtual void Invert (); virtual void FlipVertical (void) ; virtual void FlipHorizontal (void) ; virtual void Rotate (RotateAngle angle) ; //************************************************************************ // Purpose: to get the 8 bits image (240 gray levels) from the image data. //************************************************************************ virtual unsigned char *GetPixmap (BOOL relativMode) const; //************************************************************************ // Purpose: to get the 8 bits image (240 gray levels) from the image data, // corresponding to the given colortable. //************************************************************************ virtual unsigned char * GetPixmap (unsigned char *colortable) const; virtual unsigned char * GetPixmapEx (unsigned char *colortable) const; virtual unsigned char * GetPixmap (void) const; //************************************************************************ // Purpose: returns the value of pixel (x,y). // Purpose: set the value of pixel (x,y). //************************************************************************ int GetPixelValue (int x, int y) const { return (int)((float)(*(PixelData + ((long)y) * Width + x) * Slope) + Intercept); }; void SetPixelValue (int x, int y, short val) { *(PixelData + ((long)y) * Width + x) = (char)((float)(val - Intercept) / Slope); }; //************************************************************************ // Purpose: returns the value of pixel (x,y) without calibration factor // Purpose: set the value of pixel (x,y) without calibration factor //************************************************************************ short GetInternalPixel (int x, int y) const { return (short) *(PixelData + ((long)y) * Width + x); }; void SetInternalPixel (int x, int y, short val); //************************************************************************ // Purpose: an abstract method for returning a image. //************************************************************************ unsigned short* GetImage () const { return (unsigned short *) PixelData; } virtual UINT32 GetImageLength () const { return Width * Height; } virtual unsigned short * Attach (void * pixelData) { unsigned short * t = (unsigned short *) PixelData; PixelData = (unsigned char *) pixelData; return t; } virtual unsigned short * Detach () { unsigned short * t = (unsigned short *) PixelData; PixelData = NULL; return t; } virtual RealImage * GetImagePart (const DRect * lpRect) const; // (x, y) is top-left corner virtual BOOL SetImagePart (int x, int y, const RealImage * realImage, int nOPCode = 0); virtual BOOL SaveAsWindowsBitmap (const char * filename) const ; virtual BOOL SaveAsRaw (const char * filename) const ; virtual void Scale (UINT NewWidth, UINT NewHeight); virtual HANDLE CreateDIB (void) const; virtual HBITMAP CreateBitmap (void) const; private: friend class ImageProcess; friend class DICOMImage; private: unsigned char * PixelData; }; #endif // _DICOM_REALIMAGE_8_