39 dbgFile <<
"visiting on layer" << layer->
name() <<
"";
42 uint16_t color_type = 0;
43 uint16_t sample_format = SAMPLEFORMAT_UINT;
47 if (!destColorSpace) {
61 warnFile <<
"TIFF does not support exporting alpha channels with "
69 TIFFSetField(
image(), TIFFTAG_BITSPERSAMPLE, depth);
75 warnFile <<
"Attempt to export JPEG with multi-byte depth, "
76 "disabling compression";
84 const std::array<uint16_t, 1> sampleinfo = {EXTRASAMPLE_UNASSALPHA};
85 TIFFSetField(
image(), TIFFTAG_EXTRASAMPLES, 1, sampleinfo.data());
88 TIFFSetField(
image(), TIFFTAG_EXTRASAMPLES, 0);
92 TIFFSetField(
image(), TIFFTAG_PHOTOMETRIC, color_type);
93 TIFFSetField(
image(), TIFFTAG_SAMPLEFORMAT, sample_format);
104 TIFFSetField(
image(),
105 TIFFTAG_PIXARLOGQUALITY,
115 TIFFSetField(
image(), TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
120 if (color_type == PHOTOMETRIC_YCBCR) {
121 TIFFSetField(
image(), TIFFTAG_YCBCRSUBSAMPLING, 1, 1);
122 TIFFSetField(
image(), TIFFTAG_YCBCRPOSITIONING, YCBCRPOSITION_CENTERED);
124 TIFFSetField(
image(), TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RAW);
131 if (profile && profile->
type() ==
"icc" && !profile->
rawData().isEmpty()) {
132 QByteArray ba = profile->
rawData();
133 TIFFSetField(
image(), TIFFTAG_ICCPROFILE, ba.size(), ba.constData());
145 && !TIFFSetField(
image(),
146 TIFFTAG_RICHTIFFIPTC,
147 static_cast<uint32_t
>(buf.size()),
148 buf.data().data())) {
149 dbgFile <<
"Failed to write the IPTC metadata to the TIFF field";
161 && !TIFFSetField(
image(),
163 static_cast<uint32_t
>(buf.size()),
164 buf.data().data())) {
165 dbgFile <<
"Failed to write the XMP metadata to the TIFF field";
169 tsize_t stripsize = TIFFStripSize(
image());
170 std::unique_ptr<std::remove_pointer_t<tdata_t>,
decltype(&_TIFFfree)> buff(
171 _TIFFmalloc(stripsize),
174 buff &&
"Unable to allocate buffer for TIFF!",
179 for (
int y = 0; y < height; y++) {
181 switch (color_type) {
182 case PHOTOMETRIC_MINISBLACK: {
183 const std::array<quint8, 5> poses = {0, 1};
192 case PHOTOMETRIC_RGB: {
193 const auto poses = [&]() -> std::array<quint8, 5> {
194 if (sample_format == SAMPLEFORMAT_IEEEFP) {
208 case PHOTOMETRIC_SEPARATED: {
209 const std::array<quint8, 5> poses = {0, 1, 2, 3, 4};
218 case PHOTOMETRIC_ICCLAB:
219 case PHOTOMETRIC_YCBCR: {
220 const std::array<quint8, 5> poses = {0, 1, 2, 3};
229 if (!r)
return false;
230 TIFFWriteScanline(
image(),
232 static_cast<uint32_t
>(y),
237 return TIFFWriteDirectory(
image());
void convertTo(const KoColorSpace *dstColorSpace, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags(), KUndo2Command *parentCommand=nullptr, KoUpdater *progressUpdater=nullptr)