Mercurial > hg > orthanc
annotate OrthancFramework/Sources/Images/JpegErrorManager.cpp @ 4335:82652c5fc04f
cppcheck
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 01 Dec 2020 20:31:04 +0100 |
parents | bf7b9edf6b81 |
children | d9473bd5ed43 |
rev | line source |
---|---|
1604 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1604 | 4 * Department, University Hospital of Liege, Belgium |
3640
94f4a18a79cc
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
1604 | 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. |
1604 | 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. |
1604 | 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/>. |
1604 | 20 **/ |
21 | |
22 | |
23 #include "../PrecompiledHeaders.h" | |
24 #include "JpegErrorManager.h" | |
25 | |
26 namespace Orthanc | |
27 { | |
28 namespace Internals | |
29 { | |
30 void JpegErrorManager::OutputMessage(j_common_ptr cinfo) | |
31 { | |
32 char message[JMSG_LENGTH_MAX]; | |
33 (*cinfo->err->format_message) (cinfo, message); | |
34 | |
35 JpegErrorManager* that = reinterpret_cast<JpegErrorManager*>(cinfo->err); | |
36 that->message = std::string(message); | |
37 } | |
38 | |
39 | |
40 void JpegErrorManager::ErrorExit(j_common_ptr cinfo) | |
41 { | |
42 (*cinfo->err->output_message) (cinfo); | |
43 | |
44 JpegErrorManager* that = reinterpret_cast<JpegErrorManager*>(cinfo->err); | |
45 longjmp(that->setjmp_buffer, 1); | |
46 } | |
47 | |
48 | |
49 JpegErrorManager::JpegErrorManager() | |
50 { | |
51 memset(&pub, 0, sizeof(struct jpeg_error_mgr)); | |
52 memset(&setjmp_buffer, 0, sizeof(jmp_buf)); | |
53 | |
54 jpeg_std_error(&pub); | |
55 pub.error_exit = ErrorExit; | |
56 pub.output_message = OutputMessage; | |
57 } | |
58 } | |
59 } |