GDCM 3.2.1

gdcmLookupTable.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: GDCM (Grassroots DICOM). A DICOM library
4
5 Copyright (c) 2006-2011 Mathieu Malaterre
6 All rights reserved.
7 See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
8
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the above copyright notice for more information.
12
13=========================================================================*/
14
15#ifndef GDCMLOOKUPTABLE_H
16#define GDCMLOOKUPTABLE_H
17
18#include "gdcmTypes.h"
19#include "gdcmObject.h"
20#include <stdlib.h>
21
22 namespace gdcm
23{
24
25 class LookupTableInternal;
29 class GDCM_EXPORT LookupTable : public Object
30{
31 public:
32 typedef enum {
33 RED = 0, // Keep RED == 0
34 GREEN,
35 BLUE,
36 GRAY,
37 UNKNOWN
38 } LookupTableType;
39
40 LookupTable();
41 ~LookupTable() override;
42 void Print(std::ostream &) const override;
43
45 void Allocate( unsigned short bitsample = 8 );
47 //TODO: check to see if length should be unsigned short, unsigned int, or whatever
48 void InitializeLUT(LookupTableType type, unsigned short length,
49 unsigned short subscript, unsigned short bitsize);
50 unsigned int GetLUTLength(LookupTableType type) const;
51 virtual void SetLUT(LookupTableType type, const unsigned char *array,
52 unsigned int length);
53 void GetLUT(LookupTableType type, unsigned char *array, unsigned int &length) const;
54 void GetLUTDescriptor(LookupTableType type, unsigned short &length,
55 unsigned short &subscript, unsigned short &bitsize) const;
56
58 void InitializeRedLUT(unsigned short length, unsigned short subscript,
59 unsigned short bitsize);
60 void SetRedLUT(const unsigned char *red, unsigned int length);
61 void InitializeGreenLUT(unsigned short length, unsigned short subscript,
62 unsigned short bitsize);
63 void SetGreenLUT(const unsigned char *green, unsigned int length);
64 void InitializeBlueLUT(unsigned short length, unsigned short subscript,
65 unsigned short bitsize);
66 void SetBlueLUT(const unsigned char *blue, unsigned int length);
67
69 void Clear();
70
72 void Decode(std::istream &is, std::ostream &os) const;
73
77 bool Decode(char *outputbuffer, size_t outlen, const char *inputbuffer, size_t inlen) const;
78
80 bool IsRGB8() const;
81
83 bool Decode8(char *outputbuffer, size_t outlen, const char *inputbuffer, size_t inlen) const;
84
85 LookupTable(LookupTable const &lut):Object(lut), Internal(nullptr), BitSample(0), IncompleteLUT(false)
86 {
87 gdcm_assert(0);
88 }
89
91 bool GetBufferAsRGBA(unsigned char *rgba) const;
92
94 const unsigned char *GetPointer() const;
95
97 bool WriteBufferAsRGBA(const unsigned char *rgba);
98
100 unsigned short GetBitSample() const { return BitSample; }
101
103 bool Initialized() const;
104
105 private:
107 void Encode(std::istream &is, std::ostream &os);
108
109 protected:
110 LookupTableInternal *Internal;
111 unsigned short BitSample; // refer to the pixel type (not the bit size of LUT)
112 bool IncompleteLUT:1;
113};
114
115} // end namespace gdcm
116
117#endif //GDCMLOOKUPTABLE_H
gdcm::LookupTable::GetLUTDescriptor
void GetLUTDescriptor(LookupTableType type, unsigned short &length, unsigned short &subscript, unsigned short &bitsize) const
gdcm::LookupTable::LookupTableType
LookupTableType
Definition gdcmLookupTable.h:32
gdcm::LookupTable::GRAY
@ GRAY
Definition gdcmLookupTable.h:36
gdcm::LookupTable::BLUE
@ BLUE
Definition gdcmLookupTable.h:35
gdcm::LookupTable::UNKNOWN
@ UNKNOWN
Definition gdcmLookupTable.h:37
gdcm::LookupTable::GREEN
@ GREEN
Definition gdcmLookupTable.h:34
gdcm::LookupTable::RED
@ RED
Definition gdcmLookupTable.h:33
gdcm::LookupTable::BitSample
unsigned short BitSample
Definition gdcmLookupTable.h:111
gdcm::LookupTable::SetBlueLUT
void SetBlueLUT(const unsigned char *blue, unsigned int length)
gdcm::LookupTable::SetLUT
virtual void SetLUT(LookupTableType type, const unsigned char *array, unsigned int length)
gdcm::LookupTable::InitializeGreenLUT
void InitializeGreenLUT(unsigned short length, unsigned short subscript, unsigned short bitsize)
gdcm::LookupTable::LookupTable
LookupTable()
gdcm::LookupTable::Decode
void Decode(std::istream &is, std::ostream &os) const
Decode the LUT.
gdcm::LookupTable::SetGreenLUT
void SetGreenLUT(const unsigned char *green, unsigned int length)
gdcm::LookupTable::WriteBufferAsRGBA
bool WriteBufferAsRGBA(const unsigned char *rgba)
Write the LUT as RGBA.
gdcm::LookupTable::SetRedLUT
void SetRedLUT(const unsigned char *red, unsigned int length)
gdcm::LookupTable::GetBufferAsRGBA
bool GetBufferAsRGBA(unsigned char *rgba) const
return the LUT as RGBA buffer
gdcm::LookupTable::Decode8
bool Decode8(char *outputbuffer, size_t outlen, const char *inputbuffer, size_t inlen) const
Decode into RGB 8 bits space.
gdcm::LookupTable::Initialized
bool Initialized() const
return whether the LUT has been initialized
gdcm::LookupTable::InitializeRedLUT
void InitializeRedLUT(unsigned short length, unsigned short subscript, unsigned short bitsize)
RED / GREEN / BLUE specific:
gdcm::LookupTable::IsRGB8
bool IsRGB8() const
Return whether 16 bits LUT is in RGB 8 bits space.
gdcm::LookupTable::GetLUT
void GetLUT(LookupTableType type, unsigned char *array, unsigned int &length) const
gdcm::LookupTable::Decode
bool Decode(char *outputbuffer, size_t outlen, const char *inputbuffer, size_t inlen) const
gdcm::LookupTable::InitializeBlueLUT
void InitializeBlueLUT(unsigned short length, unsigned short subscript, unsigned short bitsize)
gdcm::LookupTable::Clear
void Clear()
Clear the LUT.
gdcm::LookupTable::LookupTable
LookupTable(LookupTable const &lut)
Definition gdcmLookupTable.h:85
gdcm::LookupTable::Internal
LookupTableInternal * Internal
Definition gdcmLookupTable.h:110
gdcm::LookupTable::~LookupTable
~LookupTable() override
gdcm::LookupTable::Allocate
void Allocate(unsigned short bitsample=8)
Allocate the LUT.
gdcm::LookupTable::InitializeLUT
void InitializeLUT(LookupTableType type, unsigned short length, unsigned short subscript, unsigned short bitsize)
Generic interface:
gdcm::LookupTable::IncompleteLUT
bool IncompleteLUT
Definition gdcmLookupTable.h:112
gdcm::LookupTable::GetPointer
const unsigned char * GetPointer() const
return a raw pointer to the LUT
gdcm::LookupTable::Print
void Print(std::ostream &) const override
gdcm::LookupTable::GetLUTLength
unsigned int GetLUTLength(LookupTableType type) const
gdcm::LookupTable::GetBitSample
unsigned short GetBitSample() const
return the bit sample
Definition gdcmLookupTable.h:100
gdcm::Object::Object
Object()
Definition gdcmObject.h:42
gdcm_assert
#define gdcm_assert(cond)
Definition gdcmException.h:104
gdcmObject.h
gdcmTypes.h
GDCM_EXPORT
#define GDCM_EXPORT
Definition gdcmWin32.h:34
gdcm
Definition gdcmASN1.h:21