#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)
{
gdcm_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:
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;
unsigned int PlanarConfiguration;
PhotometricInterpretation PI;
PixelFormat PF;
bool NeedByteSwap;
bool NeedOverlayCleanup;
typedef SmartPointer<LookupTable> LUTPtr;
LUTPtr LUT;
unsigned int Dimensions[3]; 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);
};
}
#endif