digiKam
dimgjpegloader.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2005-06-14
7  * Description : A JPEG IO file for DImg framework
8  *
9  * Copyright (C) 2005 by Renchi Raju <renchi dot raju at gmail dot com>, Gilles Caulier
10  * Copyright (C) 2005-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_DIMG_JPEG_LOADER_H
26 #define DIGIKAM_DIMG_JPEG_LOADER_H
27 
28 // C++ includes
29 
30 #include <cstdio>
31 #include <cstdlib>
32 
33 // C ANSI includes
34 
35 extern "C"
36 {
37 #include <setjmp.h>
38 
39 // to avoid warnings under win32
40 #undef HAVE_STDLIB_H
41 #undef HAVE_STDDEF_H
42 
43 #include <jpeglib.h>
44 }
45 
46 // Local includes
47 
48 #include "dimg.h"
49 #include "dimgloader.h"
50 
51 using namespace Digikam;
52 
53 namespace DigikamJPEGDImgPlugin
54 {
55 
56 class DImgJPEGLoader : public DImgLoader
57 {
58 
59 public:
60 
61  explicit DImgJPEGLoader(DImg* const image);
62  ~DImgJPEGLoader() override;
63 
64  bool load(const QString& filePath, DImgLoaderObserver* const observer) override;
65  bool save(const QString& filePath, DImgLoaderObserver* const observer) override;
66 
67  bool hasAlpha() const override;
68  bool sixteenBit() const override;
69  bool isReadOnly() const override;
70 
71 private:
72 
73  // To manage Errors/Warnings handling provide by libjpeg
74 
75  struct dimg_jpeg_error_mgr : public jpeg_error_mgr
76  {
77  jmp_buf setjmp_buffer;
78  };
79 
80  static void dimg_jpeg_error_exit(j_common_ptr cinfo);
81  static void dimg_jpeg_emit_message(j_common_ptr cinfo, int msg_level);
82  static void dimg_jpeg_output_message(j_common_ptr cinfo);
83 };
84 
85 } // namespace DigikamJPEGDImgPlugin
86 
87 #endif // DIGIKAM_DIMG_JPEG_LOADER_H
Definition: dimgjpegloader.h:57
Definition: dimgloaderobserver.h:41
Definition: dimgloader.h:51
Definition: dimg.h:62
Definition: dimgjpegloader.cpp:52
Definition: datefolderview.cpp:43