File indexing completed on 2024-12-22 04:15:57

0001 /*
0002  *  SPDX-FileCopyrightText: 2005 Cyrille Berger <cberger@cberger.net>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 #ifndef _KIS_TIFF_IMPORT_H_
0007 #define _KIS_TIFF_IMPORT_H_
0008 
0009 #include <QVariant>
0010 
0011 #include <tiffio.h>
0012 
0013 #include <KisImportExportFilter.h>
0014 #include <config-tiff.h>
0015 #include <config-jpeg.h>
0016 #include <kis_types.h>
0017 
0018 class QBuffer;
0019 class KisTiffPsdLayerRecord;
0020 class KisTiffPsdResourceRecord;
0021 struct KisTiffBasicInfo;
0022 
0023 class KisTIFFImport : public KisImportExportFilter
0024 {
0025     Q_OBJECT
0026 public:
0027     KisTIFFImport(QObject *parent, const QVariantList &);
0028     ~KisTIFFImport() override;
0029     bool supportsIO() const override { return false; }
0030     KisImportExportErrorCode
0031     convert(KisDocument *document,
0032             QIODevice *io,
0033             KisPropertiesConfigurationSP configuration = nullptr) override;
0034 
0035 private:
0036     KisImportExportErrorCode readTIFFDirectory(KisDocument *m_doc, TIFF *image);
0037 
0038     /**
0039      * Imports the image from the TIFF descriptor.
0040      */
0041     KisImportExportErrorCode readImageFromTiff(KisDocument *m_doc,
0042                                                TIFF *image,
0043                                                KisTiffBasicInfo &basicInfo);
0044 
0045     /**
0046      * Imports the image from the PSD descriptor.
0047      */
0048     KisImportExportErrorCode readImageFromPsd(KisDocument *m_doc,
0049                                               TIFF *image,
0050                                               KisTiffBasicInfo &basicInfo);
0051 
0052 #ifdef TIFF_HAS_PSD_TAGS
0053     /**
0054      * Imports the image from the PSD descriptor attached.
0055      * If this function is invoked, readTIFFDirectory will only
0056      * parse the first image descriptor.
0057      */
0058     KisImportExportErrorCode
0059     readImageFromPsdRecords(KisDocument *m_doc,
0060                      const KisTiffPsdLayerRecord &photoshopLayerRecord,
0061                      KisTiffPsdResourceRecord &photoshopImageResourceRecord,
0062                      QBuffer &photoshopLayerData,
0063                      const KisTiffBasicInfo &basicInfo);
0064 #endif // TIFF_HAS_PSD_TAGS
0065 
0066     KisImageSP m_image;
0067     bool m_photoshopBlockParsed = false;
0068 
0069     TIFFErrorHandler oldErrHandler = nullptr;
0070     TIFFErrorHandler oldWarnHandler = nullptr;
0071 };
0072 
0073 #endif