2012.02.22 08:22 "[Tiff] Creating a CMYK tiff", by dan claudiu zaharescu
The problem was posted before, about 10 years ago, but there were no satisfying answer for it: 2002.08.01 05:39 "Tiff AND CMYK", by <firstname.lastname@example.org>
I am now trying to do the same thing, but I am facing some difficulties:
Here is some relevant code, and I have bolded the most important calls:
TIFFSetField(image, TIFFTAG_SAMPLESPERPIXEL, 4);
/* When I use separate plans, the tiff cannot be opened, but I don't think contig is good here!! */ //TIFFSetField(image, TIFFTAG_PLANARCONFIG, PLANARCONFIG_SEPARATE); TIFFSetField(image, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
// We need to set some values for basic tags before we can add any data TIFFSetField(image, TIFFTAG_IMAGEWIDTH, width);
TIFFSetField(image, TIFFTAG_IMAGELENGTH, height);
TIFFSetField(image, TIFFTAG_BITSPERSAMPLE, 8);
TIFFSetField(image, TIFFTAG_ROWSPERSTRIP, height);
TIFFSetField(image, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB);
/*I use lzw data, but I think this is not very relevant */ TIFFSetField(image, TIFFTAG_COMPRESSION, COMPRESSION_LZW);
TIFFSetField(image, TIFFTAG_XRESOLUTION, 600.0);
TIFFSetField(image, TIFFTAG_YRESOLUTION, 600.0);
TIFFSetField(image, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH);
Now, I have 4 buffers of LZW data:
For each buffer, I try to call:
TIFFWriteRawStrip(image, 0, buff, buffLen);
Is it ok to call the method this way?
Should I pass to the second paramter the number of the buffer (0,1,2 and 3)?
However the results are disappointing, I am obtaining a tiff with many duplicated images and these images are not colored as they should be.
Some further remarks:
"Tag may not have its values changed once data is written.
If SamplesPerPixel is one, then a single array is passed; otherwise three arrays should be passed." - this is written in TIFFSetField manual: http://www.libtiff.org/man/TIFFSetField.3t.html What fields should I se 4 times and how?
I have tried more combination as described above, but could not make it work in any way.
Does anybody now how these issue should be handled?
I will further investigate myself this issue and come back again with a new mail if I will find a solution.
All the bests, Dan.