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>
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 #define XMD_H
0017 
0018 #include "dimgjpegloader.h"
0019 
0020 // C ANSI includes
0021 
0022 extern "C"
0023 {
0024 #include "iccjpeg.h"
0025 }
0026 
0027 // Qt includes
0028 
0029 #include <QFile>
0030 #include <QByteArray>
0031 
0032 // Local includes
0033 
0034 #include "digikam_config.h"
0035 #include "digikam_debug.h"
0036 #include "dimgloaderobserver.h"
0037 
0038 #ifdef Q_OS_WIN
0039 #   include "jpegwin.h"
0040 #endif
0041 
0042 namespace DigikamJPEGDImgPlugin
0043 {
0044 
0045 // To manage Errors/Warnings handling provide by libjpeg
0046 
0047 void DImgJPEGLoader::dimg_jpeg_error_exit(j_common_ptr cinfo)
0048 {
0049     dimg_jpeg_error_mgr* const myerr = static_cast<dimg_jpeg_error_mgr*>(cinfo->err);
0050 
0051     char buffer[JMSG_LENGTH_MAX];
0052     (*cinfo->err->format_message)(cinfo, buffer);
0053 
0054     qCWarning(DIGIKAM_DIMG_LOG_JPEG) << buffer;
0055 
0056 #ifdef __MINGW32__  // krazy:exclude=cpp
0057 
0058     __builtin_longjmp(myerr->setjmp_buffer, 1);
0059 
0060 #else
0061 
0062     longjmp(myerr->setjmp_buffer, 1);
0063 
0064 #endif
0065 
0066 }
0067 
0068 void DImgJPEGLoader::dimg_jpeg_emit_message(j_common_ptr cinfo, int msg_level)
0069 {
0070     char buffer[JMSG_LENGTH_MAX];
0071     (*cinfo->err->format_message)(cinfo, buffer);
0072 
0073     qCDebug(DIGIKAM_DIMG_LOG_JPEG) << buffer << " (" << msg_level << ")";
0074 }
0075 
0076 void DImgJPEGLoader::dimg_jpeg_output_message(j_common_ptr cinfo)
0077 {
0078     char buffer[JMSG_LENGTH_MAX];
0079     (*cinfo->err->format_message)(cinfo, buffer);
0080 
0081     qCDebug(DIGIKAM_DIMG_LOG_JPEG) << buffer;
0082 }
0083 
0084 DImgJPEGLoader::DImgJPEGLoader(DImg* const image)
0085     : DImgLoader(image)
0086 {
0087 }
0088 
0089 DImgJPEGLoader::~DImgJPEGLoader()
0090 {
0091 }
0092 
0093 bool DImgJPEGLoader::hasAlpha() const
0094 {
0095     return false;
0096 }
0097 
0098 bool DImgJPEGLoader::sixteenBit() const
0099 {
0100     return false;
0101 }
0102 
0103 bool DImgJPEGLoader::isReadOnly() const
0104 {
0105     return false;
0106 }
0107 
0108 } // namespace DigikamJPEGDImgPlugin