2004.05.21 12:00 "[Tiff] Un-premultiplying the color data", by Mayank
Hi chris,
Here is what I am trying in my code to un-premultiply the color data in the image attached with this message:
source: is the buffer returned by the libtiff functions.
dest: is the destination buffer
the image is: contig, strip, CMYK, 8-bits per channel, with one associated alpha channel
since i have to gather the color values in my dest buffer in the order KCMY, that is why i take dest[0] = source[3] and so on.
alpha = source[4];
if(alpha != 0)
{
dest[0] = ( (source[3]*255) + alpha/2 )/alpha;
dest[1] = ( (source[0]*255) + alpha/2 )/alpha;
dest[2] = ( (source[1]*255) + alpha/2 )/alpha;
dest[3] = ( (source[2]*255) + alpha/2 )/alpha;
}
There are two questions here:
- How do you know come to know about the color information, if alpha had been zero?
- Is the procedure above correct?