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        : 2005-06-17
0007  * Description : A TIFF IO file for DImg framework
0008  *
0009  * SPDX-FileCopyrightText: 2005      by Renchi Raju <renchi dot raju at gmail dot com>
0010  * SPDX-FileCopyrightText: 2006-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  *
0012  * Specifications & references:
0013  * - TIFF 6.0  : partners.adobe.com/public/developer/en/tiff/TIFF6.pdf
0014  * - TIFF/EP   : www.map.tu.chiba-u.ac.jp/IEC/100/TA2/recdoc/N4378.pdf
0015  * - TIFF/Tags : www.awaresystems.be/imaging/tiff/tifftags.html
0016  * - DNG       : www.adobe.com/products/dng/pdfs/dng_spec.pdf
0017  *
0018  * Others Linux Tiff Loader implementation using libtiff:
0019  * - websvn.kde.org/trunk/koffice/filters/krita/tiff/kis_tiff_converter.cc
0020  * - artis.inrialpes.fr/Software/TiffIO/
0021  * - cvs.graphicsmagick.org/cgi-bin/cvsweb.cgi/GraphicsMagick/coders/tiff.c
0022  * - freeimage.cvs.sourceforge.net/freeimage/FreeImage/Source/FreeImage/PluginTIFF.cpp
0023  * - freeimage.cvs.sourceforge.net/freeimage/FreeImage/Source/Metadata/XTIFF.cpp
0024  * - subversion.imagemagick.org/subversion/ImageMagick/trunk/coders/tiff.c
0025  *
0026  * Test images repository:
0027  * - www.remotesensing.org/libtiff/images.html
0028  *
0029  * SPDX-License-Identifier: GPL-2.0-or-later
0030  *
0031  * ============================================================ */
0032 
0033 #ifndef DIGIKAM_DIMG_TIFF_LOADER_H
0034 #define DIGIKAM_DIMG_TIFF_LOADER_H
0035 
0036 // C ANSI includes
0037 
0038 extern "C"
0039 {
0040 #include <tiffio.h>
0041 #include <tiff.h>
0042 }
0043 
0044 // Local includes
0045 
0046 #include "dimg.h"
0047 #include "dimgloader.h"
0048 #include "dmetadata.h"
0049 
0050 using namespace Digikam;
0051 
0052 namespace DigikamTIFFDImgPlugin
0053 {
0054 
0055 class DImgTIFFLoader : public DImgLoader
0056 {
0057 public:
0058 
0059     explicit DImgTIFFLoader(DImg* const image);
0060     ~DImgTIFFLoader()                                                      override;
0061 
0062     bool load(const QString& filePath, DImgLoaderObserver* const observer) override;
0063     bool save(const QString& filePath, DImgLoaderObserver* const observer) override;
0064 
0065     bool hasAlpha()                                                  const override;
0066     bool sixteenBit()                                                const override;
0067     bool isReadOnly()                                                const override;
0068 
0069 private:
0070 
0071     void tiffSetExifAsciiTag(TIFF* const tif, ttag_t tiffTag, const DMetadata& metaData, const char* const exifTagName);
0072 
0073     // cppcheck-suppress unusedPrivateFunction
0074     void tiffSetExifDataTag(TIFF* const tif, ttag_t tiffTag, const DMetadata& metaData, const char* const exifTagName);
0075 
0076     static void dimg_tiff_warning(const char* module, const char* format, va_list warnings);
0077     static void dimg_tiff_error(const char* module, const char* format, va_list errors);
0078 
0079 private:
0080 
0081     bool m_sixteenBit;
0082     bool m_hasAlpha;
0083 };
0084 
0085 } // namespace DigikamTIFFDImgPlugin
0086 
0087 #endif // DIGIKAM_DIMG_TIFF_LOADER_H