File indexing completed on 2025-01-19 03:51:01
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2009-06-03 0007 * Description : A PGF IO file for DImg framework 0008 * 0009 * SPDX-FileCopyrightText: 2009-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #include "digikam_config.h" 0016 #include "dimgpgfloader.h" // krazy:exclude=includes 0017 0018 // C Ansi includes 0019 0020 extern "C" 0021 { 0022 #ifndef Q_CC_MSVC 0023 # include <unistd.h> 0024 #endif 0025 #include <sys/types.h> 0026 #include <sys/stat.h> 0027 #include <fcntl.h> 0028 } 0029 0030 // C++ includes 0031 0032 #include <iostream> 0033 #include <cmath> 0034 #include <cstdio> 0035 0036 // Qt includes 0037 0038 #include <QFile> 0039 #include <QVariant> 0040 #include <QByteArray> 0041 #include <QTextStream> 0042 #include <QDataStream> 0043 #include <qplatformdefs.h> 0044 0045 // Windows includes 0046 0047 #ifdef Q_OS_WIN32 0048 # include <windows.h> 0049 #endif 0050 0051 // Libpgf includes 0052 0053 // Pragma directives to reduce warnings from Libpgf header files. 0054 #if defined(Q_CC_GNU) 0055 # pragma GCC diagnostic push 0056 # pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" 0057 #endif 0058 0059 #if defined(Q_CC_CLANG) 0060 # pragma clang diagnostic push 0061 # pragma clang diagnostic ignored "-Wkeyword-macro" 0062 #endif 0063 0064 #include "PGFimage.h" 0065 0066 // Restore warnings 0067 #if defined(Q_CC_CLANG) 0068 # pragma clang diagnostic pop 0069 #endif 0070 0071 #if defined(Q_CC_GNU) 0072 # pragma GCC diagnostic pop 0073 #endif 0074 0075 // Local includes 0076 0077 #include "digikam_debug.h" 0078 #include "dimgloaderobserver.h" 0079 #include "pgfutils.h" 0080 #include "metaengine.h" 0081 0082 namespace Digikam 0083 { 0084 0085 DImgPGFLoader::DImgPGFLoader(DImg* const image) 0086 : DImgLoader (image), 0087 m_sixteenBit(false), 0088 m_hasAlpha (false), 0089 m_observer (nullptr) 0090 { 0091 } 0092 0093 DImgPGFLoader::~DImgPGFLoader() 0094 { 0095 } 0096 0097 bool DImgPGFLoader::hasAlpha() const 0098 { 0099 return m_hasAlpha; 0100 } 0101 0102 bool DImgPGFLoader::sixteenBit() const 0103 { 0104 return m_sixteenBit; 0105 } 0106 0107 bool DImgPGFLoader::progressCallback(double percent, bool escapeAllowed) 0108 { 0109 if (m_observer) 0110 { 0111 m_observer->progressInfo((float)percent); 0112 0113 if (escapeAllowed) 0114 { 0115 return (!m_observer->continueQuery()); 0116 } 0117 } 0118 0119 return false; 0120 } 0121 0122 bool DImgPGFLoader::isReadOnly() const 0123 { 0124 return false; 0125 } 0126 0127 bool DImgPGFLoader::CallbackForLibPGF(double percent, bool escapeAllowed, void* data) 0128 { 0129 if (data) 0130 { 0131 DImgPGFLoader* const d = static_cast<DImgPGFLoader*>(data); 0132 0133 return (d->progressCallback(percent, escapeAllowed)); 0134 } 0135 0136 return false; 0137 } 0138 0139 } // namespace Digikam