Mercurial > hg > orthanc
comparison OrthancFramework/Sources/Images/NumpyWriter.h @ 4834:bec432ee1094
download of numpy arrays from the REST API
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 26 Nov 2021 19:03:32 +0100 |
parents | |
children | 6f780611fc03 |
comparison
equal
deleted
inserted
replaced
4833:970092a67897 | 4834:bec432ee1094 |
---|---|
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 * Copyright (C) 2017-2021 Osimis S.A., Belgium | |
6 * Copyright (C) 2021-2021 Sebastien Jodogne, ICTEAM UCLouvain, Belgium | |
7 * | |
8 * This program is free software: you can redistribute it and/or | |
9 * modify it under the terms of the GNU Lesser General Public License | |
10 * as published by the Free Software Foundation, either version 3 of | |
11 * the License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * Lesser General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU Lesser General Public | |
19 * License along with this program. If not, see | |
20 * <http://www.gnu.org/licenses/>. | |
21 **/ | |
22 | |
23 | |
24 #pragma once | |
25 | |
26 #if !defined(ORTHANC_ENABLE_ZLIB) | |
27 # error The macro ORTHANC_ENABLE_ZLIB must be defined | |
28 #endif | |
29 | |
30 #include "IImageWriter.h" | |
31 #include "../ChunkedBuffer.h" | |
32 #include "../Compatibility.h" // For ORTHANC_OVERRIDE | |
33 | |
34 namespace Orthanc | |
35 { | |
36 class ORTHANC_PUBLIC NumpyWriter : public IImageWriter | |
37 { | |
38 protected: | |
39 #if ORTHANC_SANDBOXED == 0 | |
40 virtual void WriteToFileInternal(const std::string& filename, | |
41 unsigned int width, | |
42 unsigned int height, | |
43 unsigned int pitch, | |
44 PixelFormat format, | |
45 const void* buffer) ORTHANC_OVERRIDE; | |
46 #endif | |
47 | |
48 virtual void WriteToMemoryInternal(std::string& content, | |
49 unsigned int width, | |
50 unsigned int height, | |
51 unsigned int pitch, | |
52 PixelFormat format, | |
53 const void* buffer) ORTHANC_OVERRIDE; | |
54 | |
55 private: | |
56 bool compressed_; | |
57 | |
58 public: | |
59 NumpyWriter(); | |
60 | |
61 void SetCompressed(bool compressed); | |
62 | |
63 bool IsCompressed() const | |
64 { | |
65 return compressed_; | |
66 } | |
67 | |
68 static void WriteHeader(ChunkedBuffer& target, | |
69 unsigned int depth, // Must be "0" for 2D images | |
70 unsigned int width, | |
71 unsigned int height, | |
72 PixelFormat format); | |
73 | |
74 static void WritePixels(ChunkedBuffer& target, | |
75 const ImageAccessor& image); | |
76 | |
77 static void Finalize(std::string& target, | |
78 ChunkedBuffer& source, | |
79 bool compress); | |
80 }; | |
81 } |