comparison Framework/Outputs/MultiframeDicomWriter.h @ 0:4a7a53257c7d

initial commit
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 22 Oct 2016 21:48:33 +0200
parents
children 7a3853d51c45
comparison
equal deleted inserted replaced
-1:000000000000 0:4a7a53257c7d
1 /**
2 * Orthanc - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 *
6 * This program is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU Affero General Public License
8 * as published by the Free Software Foundation, either version 3 of
9 * the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 **/
19
20
21 #pragma once
22
23 #include "../Enumerations.h"
24 #include "../Orthanc/Core/ChunkedBuffer.h"
25
26 #include <boost/noncopyable.hpp>
27 #include <memory>
28 #include <stdint.h>
29
30 #include <dcmtk/dcmdata/dcpixseq.h>
31 #include <dcmtk/dcmdata/dcdatset.h>
32 #include <dcmtk/dcmdata/dcfilefo.h>
33
34 namespace OrthancWSI
35 {
36 class MultiframeDicomWriter : public boost::noncopyable
37 {
38 private:
39 ImageCompression compression_;
40 E_TransferSyntax transferSyntax_;
41 DcmDataset sharedTags_;
42 size_t writtenSize_;
43 size_t framesCount_;
44 size_t uncompressedFrameSize_;
45 unsigned int width_;
46 unsigned int height_;
47
48 Orthanc::ChunkedBuffer uncompressedPixelData_;
49 std::auto_ptr<DcmSequenceOfItems> perFrameFunctionalGroups_;
50 std::auto_ptr<DcmPixelSequence> compressedPixelSequence_;
51 DcmPixelItem* offsetTable_;
52 std::auto_ptr<DcmOffsetList> offsetList_;
53
54 void ResetImage();
55
56 void InjectUncompressedPixelData(DcmFileFormat& dicom);
57
58 public:
59 MultiframeDicomWriter(const DcmDataset& dataset,
60 ImageCompression compression,
61 Orthanc::PixelFormat pixelFormat,
62 unsigned int width,
63 unsigned int height,
64 unsigned int tileWidth,
65 unsigned int tileHeight);
66
67 void AddFrame(const std::string& frame,
68 DcmItem* functionalGroup); // This takes the ownership
69
70 void Flush(std::string& target,
71 unsigned int instanceNumber);
72
73 unsigned int GetFramesCount() const
74 {
75 return framesCount_;
76 }
77
78 size_t GetSize() const
79 {
80 return writtenSize_;
81 }
82
83 unsigned int GetTotalWidth() const
84 {
85 return width_;
86 }
87
88 unsigned int GetTotalHeight() const
89 {
90 return height_;
91 }
92 };
93 }