GDCM
2.2.0
|
00001 /*========================================================================= 00002 00003 Program: GDCM (Grassroots DICOM). A DICOM library 00004 00005 Copyright (c) 2006-2011 Mathieu Malaterre 00006 All rights reserved. 00007 See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details. 00008 00009 This software is distributed WITHOUT ANY WARRANTY; without even 00010 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00011 PURPOSE. See the above copyright notice for more information. 00012 00013 =========================================================================*/ 00014 00015 #ifndef GDCMLOOKUPTABLE_H 00016 #define GDCMLOOKUPTABLE_H 00017 00018 #include "gdcmTypes.h" 00019 #include "gdcmObject.h" 00020 #include <stdlib.h> 00021 00022 namespace gdcm 00023 { 00024 00025 class LookupTableInternal; 00029 class GDCM_EXPORT LookupTable : public Object 00030 { 00031 public: 00032 typedef enum { 00033 RED = 0, // Keep RED == 0 00034 GREEN, 00035 BLUE, 00036 GRAY, 00037 UNKNOWN 00038 } LookupTableType; 00039 00040 LookupTable(); 00041 ~LookupTable(); 00042 void Print(std::ostream &) const {} 00043 00045 void Allocate( unsigned short bitsample = 8 ); 00047 //TODO: check to see if length should be unsigned short, unsigned int, or whatever 00048 void InitializeLUT(LookupTableType type, unsigned short length, 00049 unsigned short subscript, unsigned short bitsize); 00050 unsigned int GetLUTLength(LookupTableType type) const; 00051 virtual void SetLUT(LookupTableType type, const unsigned char *array, 00052 unsigned int length); 00053 void GetLUT(LookupTableType type, unsigned char *array, unsigned int &length) const; 00054 void GetLUTDescriptor(LookupTableType type, unsigned short &length, 00055 unsigned short &subscript, unsigned short &bitsize) const; 00056 00058 void InitializeRedLUT(unsigned short length, unsigned short subscript, 00059 unsigned short bitsize); 00060 void SetRedLUT(const unsigned char *red, unsigned int length); 00061 void InitializeGreenLUT(unsigned short length, unsigned short subscript, 00062 unsigned short bitsize); 00063 void SetGreenLUT(const unsigned char *green, unsigned int length); 00064 void InitializeBlueLUT(unsigned short length, unsigned short subscript, 00065 unsigned short bitsize); 00066 void SetBlueLUT(const unsigned char *blue, unsigned int length); 00067 00069 void Clear(); 00070 00072 void Decode(std::istream &is, std::ostream &os) const; 00073 00074 LookupTable(LookupTable const &lut):Object(lut) 00075 { 00076 assert(0); 00077 } 00078 00080 bool GetBufferAsRGBA(unsigned char *rgba) const; 00081 00083 const unsigned char *GetPointer() const; 00084 00086 bool WriteBufferAsRGBA(const unsigned char *rgba); 00087 00089 unsigned short GetBitSample() const { return BitSample; } 00090 00092 bool Initialized() const; 00093 00094 private: 00096 void Encode(std::istream &is, std::ostream &os); 00097 00098 protected: 00099 LookupTableInternal *Internal; 00100 unsigned short BitSample; // refer to the pixel type (not the bit size of LUT) 00101 bool IncompleteLUT:1; 00102 }; 00103 00104 } // end namespace gdcm 00105 00106 #endif //GDCMLOOKUPTABLE_H