Mercurial > hg > orthanc
annotate OrthancFramework/Sources/Images/IImageWriter.cpp @ 4529:5774fe497ff2
fix decoding of images on big-endian architectures
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 24 Feb 2021 21:06:34 +0100 |
parents | d9473bd5ed43 |
children | 7053502fbf97 |
rev | line source |
---|---|
2083 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
4437
d9473bd5ed43
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
2083 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
10 * the License, or (at your option) any later version. |
2083 | 11 * |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
15 * Lesser General Public License for more details. |
2083 | 16 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
18 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
2083 | 20 **/ |
21 | |
22 | |
23 #include "IImageWriter.h" | |
24 | |
2143
fd5875662670
creation of namespace SystemToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
25 #if ORTHANC_SANDBOXED == 0 |
fd5875662670
creation of namespace SystemToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
26 # include "../SystemToolbox.h" |
fd5875662670
creation of namespace SystemToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
27 #endif |
2083 | 28 |
29 namespace Orthanc | |
30 { | |
2170
baf8dd89b4e0
improved support for sandboxed environments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
31 #if ORTHANC_SANDBOXED == 0 |
2083 | 32 void IImageWriter::WriteToFileInternal(const std::string& path, |
33 unsigned int width, | |
34 unsigned int height, | |
35 unsigned int pitch, | |
36 PixelFormat format, | |
37 const void* buffer) | |
38 { | |
39 std::string compressed; | |
40 WriteToMemoryInternal(compressed, width, height, pitch, format, buffer); | |
2140 | 41 SystemToolbox::WriteFile(compressed, path); |
2170
baf8dd89b4e0
improved support for sandboxed environments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
42 } |
2083 | 43 #endif |
4297 | 44 |
4311
cb9aef006229
turning IImageWriter into a pure interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4310
diff
changeset
|
45 void IImageWriter::WriteToMemory(IImageWriter& writer, |
cb9aef006229
turning IImageWriter into a pure interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4310
diff
changeset
|
46 std::string &compressed, |
4297 | 47 const ImageAccessor &accessor) |
48 { | |
4311
cb9aef006229
turning IImageWriter into a pure interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4310
diff
changeset
|
49 writer.WriteToMemoryInternal(compressed, accessor.GetWidth(), accessor.GetHeight(), |
cb9aef006229
turning IImageWriter into a pure interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4310
diff
changeset
|
50 accessor.GetPitch(), accessor.GetFormat(), accessor.GetConstBuffer()); |
4297 | 51 } |
52 | |
53 #if ORTHANC_SANDBOXED == 0 | |
4311
cb9aef006229
turning IImageWriter into a pure interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4310
diff
changeset
|
54 void IImageWriter::WriteToFile(IImageWriter& writer, |
cb9aef006229
turning IImageWriter into a pure interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4310
diff
changeset
|
55 const std::string &path, |
4297 | 56 const ImageAccessor &accessor) |
57 { | |
4311
cb9aef006229
turning IImageWriter into a pure interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4310
diff
changeset
|
58 writer.WriteToFileInternal(path, accessor.GetWidth(), accessor.GetHeight(), |
cb9aef006229
turning IImageWriter into a pure interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4310
diff
changeset
|
59 accessor.GetPitch(), accessor.GetFormat(), accessor.GetConstBuffer()); |
4297 | 60 } |
61 #endif | |
2083 | 62 } |