GDCM: gdcmJPEGLSCodec.h Source File

GDCM 3.0.25

gdcmJPEGLSCodec.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 GDCMJPEGLSCODEC_H
15#define GDCMJPEGLSCODEC_H
16
17#include "gdcmImageCodec.h"
18
19namespace gdcm
20{
21
22class JPEGLSInternals;
30 class GDCM_EXPORT JPEGLSCodec : public ImageCodec
31{
32 friend class ImageRegionReader;
33public:
34 JPEGLSCodec();
35 ~JPEGLSCodec() override;
36 bool CanDecode(TransferSyntax const &ts) const override;
37 bool CanCode(TransferSyntax const &ts) const override;
38
39 unsigned long GetBufferLength() const { return BufferLength; }
40 void SetBufferLength(unsigned long l) { BufferLength = l; }
41
42 bool Decode(DataElement const &is, DataElement &os) override;
43 bool Decode(DataElement const &in, char* outBuffer, size_t inBufferLength,
44 uint32_t inXMin, uint32_t inXMax, uint32_t inYMin,
45 uint32_t inYMax, uint32_t inZMin, uint32_t inZMax);
46 bool Code(DataElement const &in, DataElement &out) override;
47
48 bool GetHeaderInfo(std::istream &is, TransferSyntax &ts) override;
49 ImageCodec * Clone() const override;
50
51 void SetLossless(bool l);
52 bool GetLossless() const;
53
54/*
55 * test.acr can look pretty bad, even with a lossy error of 2. Explanation follows:
56 * I agree that the test image looks ugly. In this particular case I can
57 * explain though.
58 *
59 * The image is 8 bit, but it does not use the full 8 bit dynamic range. The
60 * black pixels have value 234 and the white 255. If you set allowed lossy
61 * error to 2, you allow an error of about 10% of the actual dynamic range.
62 * That is of course very visible.
63 */
65 void SetLossyError(int error);
66
67protected:
68 bool DecodeExtent(
69 char *buffer,
70 unsigned int xmin, unsigned int xmax,
71 unsigned int ymin, unsigned int ymax,
72 unsigned int zmin, unsigned int zmax,
73 std::istream & is
74 );
75
76 bool StartEncode( std::ostream & ) override;
77 bool IsRowEncoder() override;
78 bool IsFrameEncoder() override;
79 bool AppendRowEncode( std::ostream & out, const char * data, size_t datalen ) override;
80 bool AppendFrameEncode( std::ostream & out, const char * data, size_t datalen ) override;
81 bool StopEncode( std::ostream & ) override;
82
83private:
84 bool DecodeByStreamsCommon(const char *buffer, size_t totalLen, std::vector<unsigned char> &rgbyteOut);
85 bool CodeFrameIntoBuffer(char * outdata, size_t outlen, size_t & complen, const char * indata, size_t inlen );
86
87 unsigned long BufferLength;
88 int LossyError;
89};
90
91} // end namespace gdcm
92
93#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