gdcmPixelFormat.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __gdcmPixelFormat_h
00017 #define __gdcmPixelFormat_h
00018
00019 #include "gdcmTypes.h"
00020 #include <iostream>
00021 #include <assert.h>
00022
00023 namespace gdcm
00024 {
00025
00037 class GDCM_EXPORT PixelFormat
00038 {
00039 friend class Bitmap;
00040 friend std::ostream& operator<<(std::ostream &_os, const PixelFormat &pf);
00041 public:
00042
00043 typedef enum {
00044 UINT8,
00045 INT8,
00046 UINT12,
00047 INT12,
00048 UINT16,
00049 INT16,
00050 UINT32,
00051 INT32,
00052 FLOAT16,
00053 FLOAT32,
00054 FLOAT64,
00055 UNKNOWN
00056 } ScalarType;
00057
00058
00059 explicit PixelFormat (
00060 unsigned short samplesperpixel = 1,
00061 unsigned short bitsallocated = 8,
00062 unsigned short bitsstored = 8,
00063 unsigned short highbit = 7,
00064 unsigned short pixelrepresentation = 0 ) :
00065 SamplesPerPixel(samplesperpixel),
00066 BitsAllocated(bitsallocated),
00067 BitsStored(bitsstored),
00068 HighBit(highbit),
00069 PixelRepresentation(pixelrepresentation) {}
00070
00071 PixelFormat(ScalarType st);
00072 ~PixelFormat() {}
00073
00074
00075 operator ScalarType() const { return GetScalarType(); }
00076
00078 unsigned short GetSamplesPerPixel() const;
00079 void SetSamplesPerPixel(unsigned short spp)
00080 {
00081 SamplesPerPixel = spp;
00082 }
00083
00085 unsigned short GetBitsAllocated() const
00086 {
00087 return BitsAllocated;
00088 }
00089 void SetBitsAllocated(unsigned short ba)
00090 {
00091 BitsAllocated = ba;
00092 }
00093
00095 unsigned short GetBitsStored() const
00096 {
00097 return BitsStored;
00098 }
00099 void SetBitsStored(unsigned short bs)
00100 {
00101 BitsStored = bs;
00102 }
00103
00105 unsigned short GetHighBit() const
00106 {
00107 return HighBit;
00108 }
00109 void SetHighBit(unsigned short hb)
00110 {
00111 HighBit = hb;
00112 }
00113
00115 unsigned short GetPixelRepresentation() const
00116 {
00117 assert( PixelRepresentation == 0
00118 || PixelRepresentation == 1 );
00119 return PixelRepresentation;
00120 }
00121 void SetPixelRepresentation(unsigned short pr)
00122 {
00123 assert( PixelRepresentation == 0
00124 || PixelRepresentation == 1 );
00125 PixelRepresentation = pr;
00126 }
00127
00129 ScalarType GetScalarType() const;
00130
00131 void SetScalarType(ScalarType st);
00132 const char *GetScalarTypeAsString() const;
00133
00139 uint8_t GetPixelSize() const;
00140
00142 void Print(std::ostream &os) const;
00143
00145 int64_t GetMin() const;
00146
00148 int64_t GetMax() const;
00149
00150 protected:
00152 bool Validate();
00153
00154 private:
00155
00156 unsigned short SamplesPerPixel;
00157
00158 unsigned short BitsAllocated;
00159
00160 unsigned short BitsStored;
00161
00162 unsigned short HighBit;
00163
00164 unsigned short PixelRepresentation;
00165 };
00166
00167 inline std::ostream& operator<<(std::ostream &os, const PixelFormat &pf)
00168 {
00169 pf.Print( os );
00170 return os;
00171 }
00172
00173 }
00174
00175 #endif //__gdcmPixelFormat_h
00176