gdcmImageCodec.h
Go to the documentation of this file.
/*=========================================================================
Program: GDCM (Grassroots DICOM). A DICOM library
Copyright (c) 2006-2011 Mathieu Malaterre
All rights reserved.
See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#ifndef GDCMIMAGECODEC_H
#define GDCMIMAGECODEC_H
#include "gdcmCodec.h"
#include "gdcmPhotometricInterpretation.h"
#include "gdcmLookupTable.h"
#include "gdcmSmartPointer.h"
#include "gdcmPixelFormat.h"
namespace gdcm
{
class GDCM_EXPORT ImageCodec : public Codec
{
friend class ImageChangePhotometricInterpretation;
public:
ImageCodec();
~ImageCodec() override;
bool CanCode(TransferSyntax const &) const override { return false; }
bool CanDecode(TransferSyntax const &) const override { return false; }
bool Decode(DataElement const &is_, DataElement &os) override;
bool IsLossy() const;
void SetLossyFlag(bool l);
bool GetLossyFlag() const;
virtual bool GetHeaderInfo(std::istream &is_, TransferSyntax &ts);
virtual ImageCodec * Clone() const = 0;
protected:
bool DecodeByStreams(std::istream &is_, std::ostream &os) override;
virtual bool IsValid(PhotometricInterpretation const &pi);
public:
unsigned int GetPlanarConfiguration() const
{
return PlanarConfiguration;
}
void SetPlanarConfiguration(unsigned int pc)
{
assert( pc == 0 || pc == 1 );
PlanarConfiguration = pc;
}
PixelFormat &GetPixelFormat()
{
return PF;
}
const PixelFormat &GetPixelFormat() const
{
return PF;
}
virtual void SetPixelFormat(PixelFormat const &pf)
{
PF = pf;
}
const PhotometricInterpretation &GetPhotometricInterpretation() const;
void SetPhotometricInterpretation(PhotometricInterpretation const &pi);
bool GetNeedByteSwap() const
{
return NeedByteSwap;
}
void SetNeedByteSwap(bool b)
{
NeedByteSwap = b;
}
void SetNeedOverlayCleanup(bool b)
{
NeedOverlayCleanup = b;
}
void SetLUT(LookupTable const &lut)
{
LUT = SmartPointer<LookupTable>( const_cast<LookupTable*>(&lut) );
}
const LookupTable &GetLUT() const
{
return *LUT;
}
void SetDimensions(const unsigned int d[3]);
void SetDimensions(const std::vector<unsigned int> & d);
const unsigned int *GetDimensions() const { return Dimensions; }
void SetNumberOfDimensions(unsigned int dim);
unsigned int GetNumberOfDimensions() const;
bool CleanupUnusedBits(char * data, size_t datalen);
protected:
// Streaming (write) API:
friend class FileChangeTransferSyntax;
virtual bool StartEncode( std::ostream & os );
virtual bool IsRowEncoder();
virtual bool IsFrameEncoder();
virtual bool AppendRowEncode( std::ostream & out, const char * data, size_t datalen );
virtual bool AppendFrameEncode( std::ostream & out, const char * data, size_t datalen );
virtual bool StopEncode( std::ostream & os);
protected:
bool RequestPlanarConfiguration;
bool RequestPaddedCompositePixelCode;
//private:
unsigned int PlanarConfiguration;
PhotometricInterpretation PI;
PixelFormat PF;
bool NeedByteSwap;
bool NeedOverlayCleanup;
typedef SmartPointer<LookupTable> LUTPtr;
LUTPtr LUT;
unsigned int Dimensions[3]; // FIXME
unsigned int NumberOfDimensions;
bool LossyFlag;
bool DoOverlayCleanup(std::istream &is_, std::ostream &os);
bool DoByteSwap(std::istream &is_, std::ostream &os);
bool DoYBR(std::istream &is_, std::ostream &os);
bool DoYBRFull422(std::istream &is_, std::ostream &os);
bool DoPlanarConfiguration(std::istream &is_, std::ostream &os);
bool DoSimpleCopy(std::istream &is_, std::ostream &os);
bool DoPaddedCompositePixelCode(std::istream &is_, std::ostream &os);
bool DoInvertMonochrome(std::istream &is_, std::ostream &os);
//template <typename T>
//bool DoInvertPlanarConfiguration(T *output, const T *input, uint32_t length);
};
} // end namespace gdcm
#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
gdcmLookupTable.h
gdcmPhotometricInterpretation.h
gdcmPixelFormat.h
gdcmSmartPointer.h
GDCM_EXPORT
#define GDCM_EXPORT
Definition gdcmWin32.h:34
gdcm
Definition gdcmASN1.h:21