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

0001 /*
0002  *  SPDX-FileCopyrightText: 2022 L. E. Segovia <amy@amyspark.me>
0003  *  SPDX-FileCopyrightText: 2024 Lucas Chollet <lucas.chollet@serenityos.org>
0004  *
0005  *  SPDX-License-Identifier: GPL-2.0-or-later
0006  */
0007 
0008 #ifndef KIS_TIFF_BASE_WRITER_H
0009 #define KIS_TIFF_BASE_WRITER_H
0010 
0011 #include "tiffio.h"
0012 
0013 #include <array>
0014 
0015 #include <kis_types.h>
0016 
0017 class KisTIFFOptions;
0018 class KoColorSpace;
0019 
0020 class KisTIFFBaseWriter
0021 {
0022 protected:
0023     KisTIFFBaseWriter(TIFF*image, KisTIFFOptions* options);
0024     ~KisTIFFBaseWriter() = default;
0025 
0026     static bool isBitDepthFloat(const KoID depth);
0027     static bool writeColorSpaceInformation(TIFF *image,
0028                                            const KoColorSpace *cs,
0029                                            uint16_t &color_type,
0030                                            uint16_t &sample_format,
0031                                            const KoColorSpace *&destColorSpace);
0032 
0033     inline TIFF *image()
0034     {
0035         return m_image;
0036     }
0037 
0038     bool copyDataToStrips(KisHLineConstIteratorSP it,
0039                           tdata_t buff,
0040                           uint32_t depth,
0041                           uint16_t sample_format,
0042                           uint8_t nbcolorssamples,
0043                           const std::array<quint8, 5> &poses);
0044 
0045     TIFF *m_image;
0046     KisTIFFOptions *m_options;
0047 };
0048 
0049 #endif