gdcmJPEGLSCodec.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 GDCMJPEGLSCODEC_H
#define GDCMJPEGLSCODEC_H
#include "gdcmImageCodec.h"
namespace gdcm
{
class JPEGLSInternals;
class GDCM_EXPORT JPEGLSCodec : public ImageCodec
{
friend class ImageRegionReader;
public:
JPEGLSCodec();
~JPEGLSCodec() override;
bool CanDecode(TransferSyntax const &ts) const override;
bool CanCode(TransferSyntax const &ts) const override;
unsigned long GetBufferLength() const { return BufferLength; }
void SetBufferLength(unsigned long l) { BufferLength = l; }
bool Decode(DataElement const &is, DataElement &os) override;
bool Decode(DataElement const &in, char* outBuffer, size_t inBufferLength,
uint32_t inXMin, uint32_t inXMax, uint32_t inYMin,
uint32_t inYMax, uint32_t inZMin, uint32_t inZMax);
bool Code(DataElement const &in, DataElement &out) override;
bool GetHeaderInfo(std::istream &is, TransferSyntax &ts) override;
ImageCodec * Clone() const override;
void SetLossless(bool l);
bool GetLossless() const;
/*
* test.acr can look pretty bad, even with a lossy error of 2. Explanation follows:
* I agree that the test image looks ugly. In this particular case I can
* explain though.
*
* The image is 8 bit, but it does not use the full 8 bit dynamic range. The
* black pixels have value 234 and the white 255. If you set allowed lossy
* error to 2, you allow an error of about 10% of the actual dynamic range.
* That is of course very visible.
*/
void SetLossyError(int error);
protected:
bool DecodeExtent(
char *buffer,
unsigned int xmin, unsigned int xmax,
unsigned int ymin, unsigned int ymax,
unsigned int zmin, unsigned int zmax,
std::istream & is
);
bool StartEncode( std::ostream & ) override;
bool IsRowEncoder() override;
bool IsFrameEncoder() override;
bool AppendRowEncode( std::ostream & out, const char * data, size_t datalen ) override;
bool AppendFrameEncode( std::ostream & out, const char * data, size_t datalen ) override;
bool StopEncode( std::ostream & ) override;
private:
bool DecodeByStreamsCommon(const char *buffer, size_t totalLen, std::vector<unsigned char> &rgbyteOut);
bool CodeFrameIntoBuffer(char * outdata, size_t outlen, size_t & complen, const char * indata, size_t inlen );
unsigned long BufferLength;
int LossyError;
};
} // end namespace gdcm
#endif //GDCMJPEGLSCODEC_H
gdcm::DataElement
Class to represent a Data Element either Implicit or Explicit.
Definition gdcmDataElement.h:59
gdcm::ImageCodec::ImageCodec
ImageCodec()
gdcm::JPEGLSCodec::~JPEGLSCodec
~JPEGLSCodec() override
gdcm::JPEGLSCodec::ImageRegionReader
friend class ImageRegionReader
Definition gdcmJPEGLSCodec.h:32
gdcm::JPEGLSCodec::GetBufferLength
unsigned long GetBufferLength() const
Definition gdcmJPEGLSCodec.h:39
gdcm::JPEGLSCodec::AppendFrameEncode
bool AppendFrameEncode(std::ostream &out, const char *data, size_t datalen) override
gdcm::JPEGLSCodec::StopEncode
bool StopEncode(std::ostream &) override
gdcm::JPEGLSCodec::CanCode
bool CanCode(TransferSyntax const &ts) const override
Return whether this coder support this transfer syntax (can code it).
gdcm::JPEGLSCodec::IsFrameEncoder
bool IsFrameEncoder() override
gdcm::JPEGLSCodec::Code
bool Code(DataElement const &in, DataElement &out) override
Code.
gdcm::JPEGLSCodec::IsRowEncoder
bool IsRowEncoder() override
gdcm::JPEGLSCodec::SetLossless
void SetLossless(bool l)
gdcm::JPEGLSCodec::AppendRowEncode
bool AppendRowEncode(std::ostream &out, const char *data, size_t datalen) override
gdcm::JPEGLSCodec::DecodeExtent
bool DecodeExtent(char *buffer, unsigned int xmin, unsigned int xmax, unsigned int ymin, unsigned int ymax, unsigned int zmin, unsigned int zmax, std::istream &is)
gdcm::JPEGLSCodec::Decode
bool Decode(DataElement const &is, DataElement &os) override
Decode.
gdcm::JPEGLSCodec::GetLossless
bool GetLossless() const
gdcm::JPEGLSCodec::CanDecode
bool CanDecode(TransferSyntax const &ts) const override
Return whether this decoder support this transfer syntax (can decode it).
gdcm::JPEGLSCodec::Decode
bool Decode(DataElement const &in, char *outBuffer, size_t inBufferLength, uint32_t inXMin, uint32_t inXMax, uint32_t inYMin, uint32_t inYMax, uint32_t inZMin, uint32_t inZMax)
gdcm::JPEGLSCodec::SetLossyError
void SetLossyError(int error)
[0-3] generally
gdcm::JPEGLSCodec::SetBufferLength
void SetBufferLength(unsigned long l)
Definition gdcmJPEGLSCodec.h:40
gdcm::JPEGLSCodec::Clone
ImageCodec * Clone() const override
gdcm::JPEGLSCodec::StartEncode
bool StartEncode(std::ostream &) override
gdcm::JPEGLSCodec::GetHeaderInfo
bool GetHeaderInfo(std::istream &is, TransferSyntax &ts) override
gdcm::JPEGLSCodec::JPEGLSCodec
JPEGLSCodec()
gdcm::TransferSyntax
Class to manipulate Transfer Syntax.
Definition gdcmTransferSyntax.h:40
gdcmImageCodec.h
GDCM_EXPORT
#define GDCM_EXPORT
Definition gdcmWin32.h:34
gdcm
Definition gdcmASN1.h:21