GDCM: gdcmImageCodec.h Source File

GDCM 3.2.8

gdcmImageCodec.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#ifndef GDCMIMAGECODEC_H
15#define GDCMIMAGECODEC_H
16
17#include "gdcmCodec.h"
18#include "gdcmPhotometricInterpretation.h"
19#include "gdcmLookupTable.h"
20#include "gdcmSmartPointer.h"
21#include "gdcmPixelFormat.h"
22
23namespace gdcm
24{
25
30 class GDCM_EXPORT ImageCodec : public Codec
31{
32 friend class ImageChangePhotometricInterpretation;
33public:
34 ImageCodec();
35 ~ImageCodec() override;
36 bool CanCode(TransferSyntax const &) const override { return false; }
37 bool CanDecode(TransferSyntax const &) const override { return false; }
38 bool Decode(DataElement const &is_, DataElement &os) override;
39 bool IsLossy() const;
40 void SetLossyFlag(bool l);
41 bool GetLossyFlag() const;
42
43 virtual bool GetHeaderInfo(std::istream &is_, TransferSyntax &ts);
44
45 virtual ImageCodec * Clone() const = 0;
46
47protected:
48 bool DecodeByStreams(std::istream &is_, std::ostream &os) override;
49 virtual bool IsValid(PhotometricInterpretation const &pi);
50public:
51
52 unsigned int GetPlanarConfiguration() const
53 {
54 return PlanarConfiguration;
55 }
56 void SetPlanarConfiguration(unsigned int pc)
57 {
58 gdcm_assert( pc == 0 || pc == 1 );
59 PlanarConfiguration = pc;
60 }
61
62 PixelFormat &GetPixelFormat()
63 {
64 return PF;
65 }
66 const PixelFormat &GetPixelFormat() const
67 {
68 return PF;
69 }
70 virtual void SetPixelFormat(PixelFormat const &pf)
71 {
72 PF = pf;
73 }
74 const PhotometricInterpretation &GetPhotometricInterpretation() const;
75 void SetPhotometricInterpretation(PhotometricInterpretation const &pi);
76
77 bool GetNeedByteSwap() const
78 {
79 return NeedByteSwap;
80 }
81 void SetNeedByteSwap(bool b)
82 {
83 NeedByteSwap = b;
84 }
85 void SetNeedOverlayCleanup(bool b)
86 {
87 NeedOverlayCleanup = b;
88 }
89 void SetLUT(LookupTable const &lut)
90 {
91 LUT = SmartPointer<LookupTable>( const_cast<LookupTable*>(&lut) );
92 }
93 const LookupTable &GetLUT() const
94 {
95 return *LUT;
96 }
97
98 void SetDimensions(const unsigned int d[3]);
99 void SetDimensions(const std::vector<unsigned int> & d);
100 const unsigned int *GetDimensions() const { return Dimensions; }
101 void SetNumberOfDimensions(unsigned int dim);
102 unsigned int GetNumberOfDimensions() const;
103
104 bool CleanupUnusedBits(char * data, size_t datalen);
105
106protected:
107 // Streaming (write) API:
114 friend class FileChangeTransferSyntax;
115 virtual bool StartEncode( std::ostream & os );
116 virtual bool IsRowEncoder();
117 virtual bool IsFrameEncoder();
118 virtual bool AppendRowEncode( std::ostream & out, const char * data, size_t datalen );
119 virtual bool AppendFrameEncode( std::ostream & out, const char * data, size_t datalen );
120 virtual bool StopEncode( std::ostream & os);
121
122protected:
123 bool RequestPlanarConfiguration;
124 bool RequestPaddedCompositePixelCode;
125//private:
126 unsigned int PlanarConfiguration;
127 PhotometricInterpretation PI;
128 PixelFormat PF;
129 bool NeedByteSwap;
130 bool NeedOverlayCleanup;
131
132 typedef SmartPointer<LookupTable> LUTPtr;
133 LUTPtr LUT;
134 unsigned int Dimensions[3]; // FIXME
135 unsigned int NumberOfDimensions;
136 bool LossyFlag;
137
138 bool DoOverlayCleanup(std::istream &is_, std::ostream &os);
139 bool DoByteSwap(std::istream &is_, std::ostream &os);
140 bool DoYBR(std::istream &is_, std::ostream &os);
141 bool DoYBRFull422(std::istream &is_, std::ostream &os);
142 bool DoPlanarConfiguration(std::istream &is_, std::ostream &os);
143 bool DoSimpleCopy(std::istream &is_, std::ostream &os);
144 bool DoPaddedCompositePixelCode(std::istream &is_, std::ostream &os);
145 bool DoInvertMonochrome(std::istream &is_, std::ostream &os);
146
147 //template <typename T>
148 //bool DoInvertPlanarConfiguration(T *output, const T *input, uint32_t length);
149};
150
151} // end namespace gdcm
152
153#endif //GDCMIMAGECODEC_H
gdcm::Codec
Codec class.
Definition gdcmCodec.h:27
gdcm::DataElement
Class to represent a Data Element either Implicit or Explicit.
Definition gdcmDataElement.h:59
gdcm::ImageCodec::StartEncode
virtual bool StartEncode(std::ostream &os)
gdcm::ImageCodec::SetNeedOverlayCleanup
void SetNeedOverlayCleanup(bool b)
Definition gdcmImageCodec.h:85
gdcm::ImageCodec::DoPlanarConfiguration
bool DoPlanarConfiguration(std::istream &is_, std::ostream &os)
gdcm::ImageCodec::GetHeaderInfo
virtual bool GetHeaderInfo(std::istream &is_, TransferSyntax &ts)
gdcm::ImageCodec::SetLossyFlag
void SetLossyFlag(bool l)
gdcm::ImageCodec::DoOverlayCleanup
bool DoOverlayCleanup(std::istream &is_, std::ostream &os)
gdcm::ImageCodec::DecodeByStreams
bool DecodeByStreams(std::istream &is_, std::ostream &os) override
gdcm::ImageCodec::PI
PhotometricInterpretation PI
Definition gdcmImageCodec.h:127
gdcm::ImageCodec::IsValid
virtual bool IsValid(PhotometricInterpretation const &pi)
gdcm::ImageCodec::LUTPtr
SmartPointer< LookupTable > LUTPtr
Definition gdcmImageCodec.h:132
gdcm::ImageCodec::SetDimensions
void SetDimensions(const std::vector< unsigned int > &d)
gdcm::ImageCodec::SetDimensions
void SetDimensions(const unsigned int d[3])
gdcm::ImageCodec::SetNumberOfDimensions
void SetNumberOfDimensions(unsigned int dim)
gdcm::ImageCodec::PF
PixelFormat PF
Definition gdcmImageCodec.h:128
gdcm::ImageCodec::NumberOfDimensions
unsigned int NumberOfDimensions
Definition gdcmImageCodec.h:135
gdcm::ImageCodec::RequestPaddedCompositePixelCode
bool RequestPaddedCompositePixelCode
Definition gdcmImageCodec.h:124
gdcm::ImageCodec::GetPhotometricInterpretation
const PhotometricInterpretation & GetPhotometricInterpretation() const
gdcm::ImageCodec::DoYBR
bool DoYBR(std::istream &is_, std::ostream &os)
gdcm::ImageCodec::GetLossyFlag
bool GetLossyFlag() const
gdcm::ImageCodec::GetDimensions
const unsigned int * GetDimensions() const
Definition gdcmImageCodec.h:100
gdcm::ImageCodec::DoInvertMonochrome
bool DoInvertMonochrome(std::istream &is_, std::ostream &os)
gdcm::ImageCodec::DoYBRFull422
bool DoYBRFull422(std::istream &is_, std::ostream &os)
gdcm::ImageCodec::GetPixelFormat
const PixelFormat & GetPixelFormat() const
Definition gdcmImageCodec.h:66
gdcm::ImageCodec::AppendRowEncode
virtual bool AppendRowEncode(std::ostream &out, const char *data, size_t datalen)
gdcm::ImageCodec::CanCode
bool CanCode(TransferSyntax const &) const override
Return whether this coder support this transfer syntax (can code it).
Definition gdcmImageCodec.h:36
gdcm::ImageCodec::GetNumberOfDimensions
unsigned int GetNumberOfDimensions() const
gdcm::ImageCodec::FileChangeTransferSyntax
friend class FileChangeTransferSyntax
Definition gdcmImageCodec.h:114
gdcm::ImageCodec::PlanarConfiguration
unsigned int PlanarConfiguration
Definition gdcmImageCodec.h:126
gdcm::ImageCodec::SetPlanarConfiguration
void SetPlanarConfiguration(unsigned int pc)
Definition gdcmImageCodec.h:56
gdcm::ImageCodec::SetPixelFormat
virtual void SetPixelFormat(PixelFormat const &pf)
Definition gdcmImageCodec.h:70
gdcm::ImageCodec::AppendFrameEncode
virtual bool AppendFrameEncode(std::ostream &out, const char *data, size_t datalen)
gdcm::ImageCodec::DoByteSwap
bool DoByteSwap(std::istream &is_, std::ostream &os)
gdcm::ImageCodec::IsLossy
bool IsLossy() const
gdcm::ImageCodec::RequestPlanarConfiguration
bool RequestPlanarConfiguration
Definition gdcmImageCodec.h:123
gdcm::ImageCodec::CleanupUnusedBits
bool CleanupUnusedBits(char *data, size_t datalen)
gdcm::ImageCodec::DoSimpleCopy
bool DoSimpleCopy(std::istream &is_, std::ostream &os)
gdcm::ImageCodec::IsRowEncoder
virtual bool IsRowEncoder()
gdcm::ImageCodec::GetPlanarConfiguration
unsigned int GetPlanarConfiguration() const
Definition gdcmImageCodec.h:52
gdcm::ImageCodec::NeedOverlayCleanup
bool NeedOverlayCleanup
Definition gdcmImageCodec.h:130
gdcm::ImageCodec::ImageCodec
ImageCodec()
gdcm::ImageCodec::GetPixelFormat
PixelFormat & GetPixelFormat()
Definition gdcmImageCodec.h:62
gdcm::ImageCodec::StopEncode
virtual bool StopEncode(std::ostream &os)
gdcm::ImageCodec::~ImageCodec
~ImageCodec() override
gdcm::ImageCodec::GetLUT
const LookupTable & GetLUT() const
Definition gdcmImageCodec.h:93
gdcm::ImageCodec::NeedByteSwap
bool NeedByteSwap
Definition gdcmImageCodec.h:129
gdcm::ImageCodec::SetNeedByteSwap
void SetNeedByteSwap(bool b)
Definition gdcmImageCodec.h:81
gdcm::ImageCodec::Clone
virtual ImageCodec * Clone() const =0
gdcm::ImageCodec::Decode
bool Decode(DataElement const &is_, DataElement &os) override
Decode.
gdcm::ImageCodec::IsFrameEncoder
virtual bool IsFrameEncoder()
gdcm::ImageCodec::SetLUT
void SetLUT(LookupTable const &lut)
Definition gdcmImageCodec.h:89
gdcm::ImageCodec::GetNeedByteSwap
bool GetNeedByteSwap() const
Definition gdcmImageCodec.h:77
gdcm::ImageCodec::LossyFlag
bool LossyFlag
Definition gdcmImageCodec.h:136
gdcm::ImageCodec::DoPaddedCompositePixelCode
bool DoPaddedCompositePixelCode(std::istream &is_, std::ostream &os)
gdcm::ImageCodec::CanDecode
bool CanDecode(TransferSyntax const &) const override
Return whether this decoder support this transfer syntax (can decode it).
Definition gdcmImageCodec.h:37
gdcm::ImageCodec::SetPhotometricInterpretation
void SetPhotometricInterpretation(PhotometricInterpretation const &pi)
gdcm::ImageCodec::ImageChangePhotometricInterpretation
friend class ImageChangePhotometricInterpretation
Definition gdcmImageCodec.h:32
gdcm::ImageCodec::Dimensions
unsigned int Dimensions[3]
Definition gdcmImageCodec.h:134
gdcm::ImageCodec::LUT
LUTPtr LUT
Definition gdcmImageCodec.h:133
gdcm::LookupTable
LookupTable class.
Definition gdcmLookupTable.h:30
gdcm::PhotometricInterpretation
Class to represent an PhotometricInterpretation.
Definition gdcmPhotometricInterpretation.h:29
gdcm::PixelFormat
PixelFormat.
Definition gdcmPixelFormat.h:46
gdcm::SmartPointer
Class for Smart Pointer.
Definition gdcmSmartPointer.h:40
gdcm::TransferSyntax
Class to manipulate Transfer Syntax.
Definition gdcmTransferSyntax.h:40
gdcmCodec.h
gdcm_assert
#define gdcm_assert(cond)
Definition gdcmException.h:104
gdcmLookupTable.h
gdcmPhotometricInterpretation.h
gdcmPixelFormat.h
gdcmSmartPointer.h
GDCM_EXPORT
#define GDCM_EXPORT
Definition gdcmWin32.h:34
gdcm
Definition gdcmASN1.h:21