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