File indexing completed on 2025-01-19 03:51:03

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2019-09-22
0007  * Description : RAW DImg plugin.
0008  *
0009  * SPDX-FileCopyrightText: 2020-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 "dimgrawplugin.h"
0016 
0017 // C++ includes
0018 
0019 #include <cstdio>
0020 
0021 // KDE includes
0022 
0023 #include <klocalizedstring.h>
0024 
0025 // Local includes
0026 
0027 #include "digikam_debug.h"
0028 #include "digikam_globals.h"
0029 #include "dimgrawloader.h"
0030 #include "drawdecoder.h"
0031 #include "drawfiles.h"
0032 
0033 namespace DigikamRAWDImgPlugin
0034 {
0035 
0036 DImgRAWPlugin::DImgRAWPlugin(QObject* const parent)
0037     : DPluginDImg(parent)
0038 {
0039 }
0040 
0041 DImgRAWPlugin::~DImgRAWPlugin()
0042 {
0043 }
0044 
0045 QString DImgRAWPlugin::name() const
0046 {
0047     return i18nc("@title", "RAW loader");
0048 }
0049 
0050 QString DImgRAWPlugin::iid() const
0051 {
0052     return QLatin1String(DPLUGIN_IID);
0053 }
0054 
0055 QIcon DImgRAWPlugin::icon() const
0056 {
0057     return QIcon::fromTheme(QLatin1String("image-x-adobe-dng"));
0058 }
0059 
0060 QString DImgRAWPlugin::description() const
0061 {
0062     return i18nc("@info", "An image loader based on Libraw codec");
0063 }
0064 
0065 QString DImgRAWPlugin::details() const
0066 {
0067     return xi18nc("@info", "<para>This plugin allows users to load and save image using Libraw codec.</para>"
0068                   "<para>A camera raw image file contains minimally processed data from the image sensor "
0069                   "of either a digital camera, a motion picture film scanner, or other image scanner. "
0070                   "Raw files are not yet processed and therefore are not ready to be printed or edited "
0071                   "with a bitmap graphics editor. RAW are processed by a raw converter in a wide-gamut "
0072                   "internal color space where precise adjustments can be made before conversion to a TIFF "
0073                   "or JPEG for storage, printing, or further manipulation. This often encodes the image in "
0074                   "a device-dependent color space.</para>"
0075                   "<para>See <a href='https://en.wikipedia.org/wiki/Raw_image_format'>"
0076                   "Raw Image File documentation</a> for details.</para>"
0077     );
0078 }
0079 
0080 QString DImgRAWPlugin::handbookSection() const
0081 {
0082     return QLatin1String("supported_materials");
0083 }
0084 
0085 QString DImgRAWPlugin::handbookChapter() const
0086 {
0087     return QLatin1String("image_formats");
0088 }
0089 
0090 QString DImgRAWPlugin::handbookReference() const
0091 {
0092     return QLatin1String("image-raw");
0093 }
0094 
0095 QList<DPluginAuthor> DImgRAWPlugin::authors() const
0096 {
0097     return QList<DPluginAuthor>()
0098             << DPluginAuthor(QString::fromUtf8("Marcel Wiesweg"),
0099                              QString::fromUtf8("marcel dot wiesweg at gmx dot de"),
0100                              QString::fromUtf8("(C) 2005-2012"))
0101             << DPluginAuthor(QString::fromUtf8("Gilles Caulier"),
0102                              QString::fromUtf8("caulier dot gilles at gmail dot com"),
0103                              QString::fromUtf8("(C) 2009-2022"))
0104             ;
0105 }
0106 
0107 void DImgRAWPlugin::setup(QObject* const /*parent*/)
0108 {
0109     // Nothing to do
0110 }
0111 
0112 QMap<QString, QStringList> DImgRAWPlugin::extraAboutData() const
0113 {
0114     QMap<QString, QString> rawMap = s_rawFileExtensionsdWithDesc();
0115     QMap<QString, QStringList> ret;
0116 
0117     for (QMap<QString, QString>::const_iterator it = rawMap.constBegin() ; it != rawMap.constEnd() ; ++it)
0118     {
0119         ret.insert(it.key(), QStringList() << it.value()
0120                                            << i18nc("@info: can read file format",  "yes")
0121                                            << i18nc("@info: can write file format", "no")
0122         );
0123     }
0124 
0125     return ret;
0126 }
0127 
0128 QString DImgRAWPlugin::loaderName() const
0129 {
0130     return QLatin1String("RAW");
0131 }
0132 
0133 QString DImgRAWPlugin::typeMimes() const
0134 {
0135     return QString(DRawDecoder::rawFiles()).toUpper().remove(QLatin1String("*."));
0136 }
0137 
0138 int DImgRAWPlugin::canRead(const QFileInfo& fileInfo, bool magic) const
0139 {
0140     if (!magic)
0141     {
0142         QString rawFilesExt = DRawDecoder::rawFiles();
0143         QString format      = fileInfo.suffix().toUpper();
0144 
0145         return (!format.isEmpty() && rawFilesExt.toUpper().contains(format)) ? 10 : 0;
0146     }
0147 
0148     return 0;
0149 }
0150 
0151 int DImgRAWPlugin::canWrite(const QString& /*format*/) const
0152 {
0153     // NOTE: Raw are read only files.
0154     return 0;
0155 }
0156 
0157 DImgLoader* DImgRAWPlugin::loader(DImg* const image, const DRawDecoding& rawSettings) const
0158 {
0159     return new DImgRAWLoader(image, rawSettings);
0160 }
0161 
0162 DImgLoaderSettings* DImgRAWPlugin::exportWidget(const QString& format) const
0163 {
0164     Q_UNUSED(format);
0165 
0166     // NOTE: RAW are read only.
0167 
0168     return nullptr;
0169 }
0170 
0171 } // namespace DigikamRAWDImgPlugin
0172 
0173 #include "moc_dimgrawplugin.cpp"