GDCM 3.0.24
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;
31{
32friend class ImageRegionReader;
33public:
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:
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
Class to represent a Data Element either Implicit or Explicit.
Definition gdcmDataElement.h:59
ImageCodec.
Definition gdcmImageCodec.h:31
ImageRegionReader.
Definition gdcmImageRegionReader.h:35
JPEG-LS.
Definition gdcmJPEGLSCodec.h:31
~JPEGLSCodec() override
unsigned long GetBufferLength() const
Definition gdcmJPEGLSCodec.h:39
bool AppendFrameEncode(std::ostream &out, const char *data, size_t datalen) override
bool StopEncode(std::ostream &) override
bool CanCode(TransferSyntax const &ts) const override
Return whether this coder support this transfer syntax (can code it)
bool IsFrameEncoder() override
bool Code(DataElement const &in, DataElement &out) override
Code.
bool IsRowEncoder() override
void SetLossless(bool l)
bool AppendRowEncode(std::ostream &out, const char *data, size_t datalen) override
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 Decode(DataElement const &is, DataElement &os) override
Decode.
bool GetLossless() const
bool CanDecode(TransferSyntax const &ts) const override
Return whether this decoder support this transfer syntax (can decode it)
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)
void SetLossyError(int error)
[0-3] generally
void SetBufferLength(unsigned long l)
Definition gdcmJPEGLSCodec.h:40
ImageCodec * Clone() const override
bool StartEncode(std::ostream &) override
bool GetHeaderInfo(std::istream &is, TransferSyntax &ts) override
Class to manipulate Transfer Syntax.
Definition gdcmTransferSyntax.h:40
#define GDCM_EXPORT
Definition gdcmWin32.h:34
Definition gdcmASN1.h:21