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