2006.07.05 14:38 "[Tiff] CMYK Tiff", by Ivan Kopcanski

2006.07.06 09:38 "Re: [Tiff] CMYK Tiff", by Gerben Vos

    I work on a c# project and I am asked to make CMYK tif file.

What I need to do is to make CMYK tif file with square painted with specified color and properly placed on white painted image.

How it is possible to do using libtiff.dll? GDI+ gives possibility to save RGB tif files.

You cannot paint squares or other things with libtiff. It only works with raw bitmap data.

However, what you could do for example, is construct the image using GDI+ (or something else), then retrieve the bitmap data (from the documentation it looks like you need to use Bitmap.LockBits for that), convert that from RGB to CMYK and then pass it on to libtiff. You can probably find out how to do that conversion on many places on the internet; one place is in the PDF specification (section 6.2: Conversions among device color spaces).

Although the Windows bitmap format aligns scanlines on multiples of 4 bytes, while TIFF uses 1-byte alignment, this doesn't matter in this case because CMYK uses 4 bytes per pixel.

Write the TIFF with TIFFTAG_PHOTOMETRIC = PHOTOMETRIC_SEPARATED. You can also set TIFFTAG_INKSET = INKSET_CMYK and TIFFTAG_NUMBEROFINKS = 4, but those two are optional and default to these values anyway.

Gerben Vos.