| AWARE [SYSTEMS] | Imaging expertise for the Delphi developer | |||||||
![]() |
TIFF and LibTiff Mailing List Archive | |||||||
LibTiff Mailing List
TIFF and LibTiff Mailing List Archive Contact
The TIFF Mailing List Homepage |
Thread2012.02.23 07:12 "Re: Creating a CMYK tiff", by Dan Claudiu ZaharescuHello all,
Andreas,Igor, you are right,the problem was indeed at the viewers.
As it says in the TIFF documentation,
"Since separated images are quite device-specific and are restricted to
color prepress use, they should not be used for general image data
interchange. Separated images are to be used only for prepress applications
in which the imagesetter, paper, ink, and printing press characteristics are
known by the creator of the separated image.",
a TIFF viewer is not forced by the specification to support this kind of
files.
But for my purpose (to create a pdf file that contained this kind of tiff
using pdflib), it worked.
I will put here my whole code that does the job (maybe it does not have the
optimal structure yet, as I am in the prototyping phase, but it works)
I have colored in red the relevant calls.
static TIFF* initSeparatedImagesTiffParams(int pageNo,char *dataenc)
{
std::string fullTiffFileName=data_path;
char tiffFileName[256];
sprintf(tiffFileName,"Page_%d_layer_%s_allLayers.tif",pageNo,dataenc);
fullTiffFileName.append(tiffFileName);
TIFF *image;
// Open the TIFF file
if((image = TIFFOpen(fullTiffFileName.c_str(), "w")) == NULL){
printf("Could not open output.tif for writing\n");
exit(42);
}
TIFFSetField(image, TIFFTAG_SAMPLESPERPIXEL, 4);
TIFFSetField(image, TIFFTAG_PLANARCONFIG, PLANARCONFIG_SEPARATE);
TIFFSetField(image, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_SEPARATED);
// Actually, I think these fields are corret, by default
TIFFSetField(image, TIFFTAG_INKSET, INKSET_CMYK);
TIFFSetField(image, TIFFTAG_NUMBEROFINKS, 4);
// 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);
//4 parameters here are OK
TIFFSetField(image, TIFFTAG_BITSPERSAMPLE, 8,8,8,8);
TIFFSetField(image, TIFFTAG_ROWSPERSTRIP, height);
//This simply just puts LZW compression
setCompression4(image,dataenc);
TIFFSetField(image, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB);
TIFFSetField(image, TIFFTAG_XRESOLUTION, 600.0);
TIFFSetField(image, TIFFTAG_YRESOLUTION, 600.0);
TIFFSetField(image, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH);
return image;
}
static void writeStripsForAllLayers(TIFF *image,char *dataenc)
{
if (strncmp(dataenc,"lzw",32)==0){
// Write the information to the file
TIFFWriteRawStrip(image, 0, buff, buffLen);
}
else {
// Write the information to the file
TIFFWriteEncodedStrip(image, 0, buff, buffLen);
}
}
static void writeStripWithNumber(TIFF *image,char *dataenc,int strip_n)
{
if (strncmp(dataenc,"lzw",32)==0){
// Write the information to the file
TIFFWriteRawStrip(image, strip_n , bufsSeparate[strip_n],
bufsLens[strip_n]);
}
else {
// Write the information to the file
TIFFWriteEncodedStrip(image, 0, buff, buffLen);
}
}
static void createTiffSeparatedImageSeparatedImages(int pageNo,char
*dataenc)
{
int nLayers=4;
TIFF *image = initSeparatedImagesTiffParams(pageNo,dataenc);
for (int i=0 ; i<4 ; i++) {
getBuffFromFileForSeparateImages(pageNo,i,dataenc);
}
/* This is how images are loaded, one by one ; a call to
TIFFWriteRawStrip for each image*/
// strip_no, a C/M/Y/K
buffer, lenght of a buffer
TIFFWriteRawStrip(image, 0 , bufsSeparate[1], bufsLens[1]);
TIFFWriteRawStrip(image, 1 , bufsSeparate[2], bufsLens[2]);
//my buffers here come in a different order, so for strip 1 I have buffer 2
TIFFWriteRawStrip(image, 2 , bufsSeparate[3], bufsLens[3]);
TIFFWriteRawStrip(image, 3 , bufsSeparate[0], bufsLens[0]);
// Close the file
TIFFClose(image);
}
int main() {
getWidthAndHeight(0,0);
for (int i=0 ; i<5 ; i++) {
// I will create 5 tiffs
createTiffSeparatedImageSeparatedImages(i,"lzw");
}
}
Bob and Jürgen decompressing and re-arraning the data can be a good option,
but it may degrade performance, and I needed the best performance I could
get.
But equally true is that I may have portability problems later, so I have to
analyze this carefully.
Thank you all very much for the quick feedback, Dan.
________________________________
From: Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
To: Jürgen Buchmüller <pullmoll@t-online.de>
Cc: tiff@lists.maptools.org
Sent: Thursday, February 23, 2012 4:02 AM
Subject: Re: [Tiff] Creating a CMYK tiff
On Thu, 23 Feb 2012, Jürgen Buchmüller wrote:
>
> If no viewer is capable of displaying the data in this form (I don't
> know), you would have to rearrage the data by decompressing the 4
GraphicsMagick should be cable of reading CMYK TIFFs of this type.
Bob
--
Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/
_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
|
|||||||