annotate Core/Images/JpegWriter.h @ 1896:b1a6b90a1667

back to mainline
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 16 Dec 2015 09:23:40 +0100
parents 3727a09e7b53
children b1291df2f780
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1602
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 *
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * This program is free software: you can redistribute it and/or
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * published by the Free Software Foundation, either version 3 of the
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 *
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * In addition, as a special exception, the copyright holders of this
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * program give permission to link the code of its release with the
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * that use the same license as the "OpenSSL" library), and distribute
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * the linked executables. You must obey the GNU General Public License
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * in all respects for all of the code used other than "OpenSSL". If you
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * modify file(s) with this exception, you may extend this exception to
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * your version of the file(s), but you are not obligated to do so. If
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * you do not wish to do so, delete this exception statement from your
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * version. If you delete this exception statement from all source files
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * in the program, then also delete it here.
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 *
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 * This program is distributed in the hope that it will be useful, but
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * General Public License for more details.
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 *
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 * You should have received a copy of the GNU General Public License
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 **/
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 #pragma once
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "ImageAccessor.h"
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include <string>
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 #include <stdint.h>
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 namespace Orthanc
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 {
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 class JpegWriter
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 {
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 private:
1654
3727a09e7b53 fix some icc warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
45 uint8_t quality_;
1602
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 public:
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 JpegWriter() : quality_(90)
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 {
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 }
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 void SetQuality(uint8_t quality);
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 uint8_t GetQuality() const
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 {
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 return quality_;
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 }
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 void WriteToFile(const char* filename,
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 unsigned int width,
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 unsigned int height,
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 unsigned int pitch,
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 PixelFormat format,
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 const void* buffer);
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 void WriteToMemory(std::string& jpeg,
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 unsigned int width,
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 unsigned int height,
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 unsigned int pitch,
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 PixelFormat format,
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 const void* buffer);
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 void WriteToFile(const char* filename,
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 const ImageAccessor& accessor)
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 {
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 WriteToFile(filename, accessor.GetWidth(), accessor.GetHeight(),
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 accessor.GetPitch(), accessor.GetFormat(), accessor.GetConstBuffer());
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 }
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 void WriteToMemory(std::string& jpeg,
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 const ImageAccessor& accessor)
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 {
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 WriteToMemory(jpeg, accessor.GetWidth(), accessor.GetHeight(),
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 accessor.GetPitch(), accessor.GetFormat(), accessor.GetConstBuffer());
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 }
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 };
292bce3f54ed JpegWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 }