| 1 | //cxx . . $ `<file>/Modules/ThirdParty/GDCM/src/gdcm/Utilities/gdcmcharls/jpegstreamwriter.h`/ |
| 2 | // (C) CharLS Team 2014, all rights reserved. See the accompanying "License.txt" for licensed use. |
| 3 | // |
| 4 | |
| 5 | #ifndef CHARLS_JPEGSTREAMWRITER |
| 6 | #define CHARLS_JPEGSTREAMWRITERcxx . . $ `Modules/ThirdParty/GDCM/src/gdcm/Utilities/gdcmcharls/jpegstreamwriter.h:6:9`! |
| 7 | |
| 8 | #include "util.h"cxx . . $ `<file>/Modules/ThirdParty/GDCM/src/gdcm/Utilities/gdcmcharls/util.h`/ |
| 9 | #include "jpegsegment.h"cxx . . $ `<file>/Modules/ThirdParty/GDCM/src/gdcm/Utilities/gdcmcharls/jpegsegment.h`/ |
| 10 | #include <vector> |
| 11 | #include <memory> |
| 12 | |
| 13 | enum class JpegMarkerCodecxx . . $ JpegMarkerCode# : uint8_tcxx . . $ uint8_t#; |
| 14 | |
| 15 | |
| 16 | // |
| 17 | // Purpose: 'Writer'class that can generate JPEG-LS file streams. |
| 18 | // |
| 19 | class JpegStreamWritercxx . . $ JpegStreamWriter# |
| 20 | { |
| 21 | friend class JpegMarkerSegmentcxx . . $ JpegMarkerSegment#; |
| 22 | friend class JpegImageDataSegmentcxx . . $ JpegImageDataSegment#; |
| 23 | |
| 24 | public: |
| 25 | JpegStreamWritercxx . . $ JpegStreamWriter#JpegStreamWriter(49f6e7a06ebc5aa8).(); |
| 26 | |
| 27 | void AddSegmentcxx . . $ JpegStreamWriter#AddSegment(11132885ac29ddb4).(stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<JpegSegmentcxx . . $ JpegSegment#> segment) |
| 28 | { |
| 29 | _segmentscxx . . $ JpegStreamWriter#_segments..push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(segment)); |
| 30 | } |
| 31 | |
| 32 | void AddScancxx . . $ JpegStreamWriter#AddScan(db4e4f0bd86b4cb).(const ByteStreamInfocxx . . $ ByteStreamInfo#& info, const JlsParameterscxx . . $ JlsParameters#& params); |
| 33 | |
| 34 | void AddColorTransformcxx . . $ JpegStreamWriter#AddColorTransform(ae8d4bc8721a6b8a).(charlscxx . . $ charls/::ColorTransformationcxx . . $ charls/ColorTransformation# transformation); |
| 35 | |
| 36 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# GetBytesWrittencxx . . $ JpegStreamWriter#GetBytesWritten(fe4d2d262d4164a8).() const |
| 37 | { |
| 38 | return _byteOffsetcxx . . $ JpegStreamWriter#_byteOffset.; |
| 39 | } |
| 40 | |
| 41 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# GetLengthcxx . . $ JpegStreamWriter#GetLength(fe4d2d262d4164a8).() const |
| 42 | { |
| 43 | return _datacxx . . $ JpegStreamWriter#_data..countcxx . . $ ByteStreamInfo#count. - _byteOffsetcxx . . $ JpegStreamWriter#_byteOffset.; |
| 44 | } |
| 45 | |
| 46 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# Writecxx . . $ JpegStreamWriter#Write(9a829512121a1051).(const ByteStreamInfocxx . . $ ByteStreamInfo#& info); |
| 47 | |
| 48 | void EnableComparecxx . . $ JpegStreamWriter#EnableCompare(b45ddcbc8423892c).(bool bCompare) |
| 49 | { |
| 50 | _bComparecxx . . $ JpegStreamWriter#_bCompare. = bCompare; |
| 51 | } |
| 52 | |
| 53 | private: |
| 54 | uint8_tcxx . . $ uint8_t#* GetPoscxx . . $ JpegStreamWriter#GetPos(707a43c27767d44a).() const |
| 55 | { |
| 56 | return _datacxx . . $ JpegStreamWriter#_data..rawDatacxx . . $ ByteStreamInfo#rawData. + _byteOffsetcxx . . $ JpegStreamWriter#_byteOffset.; |
| 57 | } |
| 58 | |
| 59 | ByteStreamInfocxx . . $ ByteStreamInfo# OutputStreamcxx . . $ JpegStreamWriter#OutputStream(63679468d7c0d29c).() const |
| 60 | { |
| 61 | ByteStreamInfocxx . . $ ByteStreamInfo# data = _datacxx . . $ JpegStreamWriter#_data.; |
| 62 | data.countcxx . . $ ByteStreamInfo#count. -= _byteOffsetcxx . . $ JpegStreamWriter#_byteOffset.; |
| 63 | data.rawDatacxx . . $ ByteStreamInfo#rawData. += _byteOffsetcxx . . $ JpegStreamWriter#_byteOffset.; |
| 64 | return data; |
| 65 | } |
| 66 | |
| 67 | void WriteBytecxx . . $ JpegStreamWriter#WriteByte(ac50b47256ae7414).(uint8_tcxx . . $ uint8_t# val) |
| 68 | { |
| 69 | ASSERTcxx . . $ `Modules/ThirdParty/GDCM/src/gdcm/Utilities/gdcmcharls/util.h:16:13`!(!_bCompare || _data.rawData[_byteOffset] == val); |
| 70 | |
| 71 | if (_datacxx . . $ JpegStreamWriter#_data..rawStreamcxx . . $ ByteStreamInfo#rawStream.) |
| 72 | { |
| 73 | _datacxx . . $ JpegStreamWriter#_data..rawStreamcxx . . $ ByteStreamInfo#rawStream.->sputccxx . . $ std/basic_streambuf#sputc(ca3ffd335fa96936).(val); |
| 74 | } |
| 75 | else |
| 76 | { |
| 77 | if (_byteOffsetcxx . . $ JpegStreamWriter#_byteOffset. >= _datacxx . . $ JpegStreamWriter#_data..countcxx . . $ ByteStreamInfo#count.) |
| 78 | throw stdcxx . . $ std/system_error#system_error(bd3fb6dddb5bfcf6).::system_errorcxx . . $ std/system_error#(static_cast<int>(charlscxx . . $ charls/::ApiResultcxx . . $ charls/ApiResult#::CompressedBufferTooSmallcxx . . $ charls/ApiResult#CompressedBufferTooSmall.), CharLSCategoryInstancecxx . . $ CharLSCategoryInstance(d722c6fa07888cca).()); |
| 79 | |
| 80 | _datacxx . . $ JpegStreamWriter#_data..rawDatacxx . . $ ByteStreamInfo#rawData.[_byteOffsetcxx . . $ JpegStreamWriter#_byteOffset.++] = val; |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | void WriteBytescxx . . $ JpegStreamWriter#WriteBytes(981a1a29c6e5fab4).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<uint8_tcxx . . $ uint8_t#>& bytes) |
| 85 | { |
| 86 | for (stdcxx . . $ std/::size_tcxx . . $ std/size_t# i = 0; i < bytes.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); ++i) |
| 87 | { |
| 88 | WriteBytecxx . . $ JpegStreamWriter#WriteByte(ac50b47256ae7414).(bytes[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).i]); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | void WriteWordcxx . . $ JpegStreamWriter#WriteWord(ed53e3bbd3fa2f69).(uint16_tcxx . . $ uint16_t# value) |
| 93 | { |
| 94 | WriteBytecxx . . $ JpegStreamWriter#WriteByte(ac50b47256ae7414).(static_cast<uint8_tcxx . . $ uint8_t#>(value / 0x100)); |
| 95 | WriteBytecxx . . $ JpegStreamWriter#WriteByte(ac50b47256ae7414).(static_cast<uint8_tcxx . . $ uint8_t#>(value % 0x100)); |
| 96 | } |
| 97 | |
| 98 | void WriteMarkercxx . . $ JpegStreamWriter#WriteMarker(5297cad61e5fe5a0).(JpegMarkerCodecxx . . $ JpegMarkerCode# marker) |
| 99 | { |
| 100 | WriteBytecxx . . $ JpegStreamWriter#WriteByte(ac50b47256ae7414).(0xFF); |
| 101 | WriteBytecxx . . $ JpegStreamWriter#WriteByte(ac50b47256ae7414).(static_cast<uint8_tcxx . . $ uint8_t#>(marker)); |
| 102 | } |
| 103 | |
| 104 | void Seekcxx . . $ JpegStreamWriter#Seek(2c44cd906ae4e829).(stdcxx . . $ std/::size_tcxx . . $ std/size_t# byteCount) |
| 105 | { |
| 106 | if (_datacxx . . $ JpegStreamWriter#_data..rawStreamcxx . . $ ByteStreamInfo#rawStream.) |
| 107 | return; |
| 108 | |
| 109 | _byteOffsetcxx . . $ JpegStreamWriter#_byteOffset. += byteCount; |
| 110 | } |
| 111 | |
| 112 | bool _bComparecxx . . $ JpegStreamWriter#_bCompare.; |
| 113 | ByteStreamInfocxx . . $ ByteStreamInfo# _datacxx . . $ JpegStreamWriter#_data.; |
| 114 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# _byteOffsetcxx . . $ JpegStreamWriter#_byteOffset.; |
| 115 | int32_tcxx . . $ int32_t# _lastCompenentIndexcxx . . $ JpegStreamWriter#_lastCompenentIndex.; |
| 116 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<JpegSegmentcxx . . $ JpegSegment#>> _segmentscxx . . $ JpegStreamWriter#_segments.; |
| 117 | }; |
| 118 | |
| 119 | #endif |