File indexing completed on 2025-01-19 03:51:00
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2005-06-14 0007 * Description : A JPEG IO file for DImg framework 0008 * 0009 * SPDX-FileCopyrightText: 2005 by Renchi Raju <renchi dot raju at gmail dot com>, Gilles Caulier 0010 * SPDX-FileCopyrightText: 2005-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 * 0012 * SPDX-License-Identifier: GPL-2.0-or-later 0013 * 0014 * ============================================================ */ 0015 0016 #ifndef DIGIKAM_DIMG_JPEG_LOADER_H 0017 #define DIGIKAM_DIMG_JPEG_LOADER_H 0018 0019 // C++ includes 0020 0021 #include <cstdio> 0022 #include <cstdlib> 0023 0024 // C ANSI includes 0025 0026 extern "C" 0027 { 0028 #include <setjmp.h> 0029 0030 // to avoid warnings under win32 0031 #undef HAVE_STDLIB_H 0032 #undef HAVE_STDDEF_H 0033 0034 #include <jpeglib.h> 0035 } 0036 0037 // Local includes 0038 0039 #include "dimg.h" 0040 #include "dimgloader.h" 0041 0042 using namespace Digikam; 0043 0044 namespace DigikamJPEGDImgPlugin 0045 { 0046 0047 class DImgJPEGLoader : public DImgLoader 0048 { 0049 0050 public: 0051 0052 explicit DImgJPEGLoader(DImg* const image); 0053 ~DImgJPEGLoader() override; 0054 0055 bool load(const QString& filePath, DImgLoaderObserver* const observer) override; 0056 bool save(const QString& filePath, DImgLoaderObserver* const observer) override; 0057 0058 bool hasAlpha() const override; 0059 bool sixteenBit() const override; 0060 bool isReadOnly() const override; 0061 0062 private: 0063 0064 // To manage Errors/Warnings handling provide by libjpeg 0065 0066 struct dimg_jpeg_error_mgr : public jpeg_error_mgr 0067 { 0068 jmp_buf setjmp_buffer; 0069 }; 0070 0071 static void dimg_jpeg_error_exit(j_common_ptr cinfo); 0072 static void dimg_jpeg_emit_message(j_common_ptr cinfo, int msg_level); 0073 static void dimg_jpeg_output_message(j_common_ptr cinfo); 0074 }; 0075 0076 } // namespace DigikamJPEGDImgPlugin 0077 0078 #endif // DIGIKAM_DIMG_JPEG_LOADER_H