1 /* Copyright (C) 2001-2006 Artifex Software, Inc. 2 All Rights Reserved. 3 4 This software is provided AS-IS with no warranty, either express or 5 implied. 6 7 This software is distributed under license and may not be copied, modified 8 or distributed except as expressly authorized under the terms of that 9 license. Refer to licensing information at http://www.artifex.com/ 10 or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, 11 San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information. 12 */ 13 14 /* $Id: gxalpha.h 8022 2007-06-05 22:23:38Z giles $ */ 15 /* Internal machinery for alpha channel support */ 16 17 #ifndef gxalpha_INCLUDED 18 # define gxalpha_INCLUDED 19 20 /* 21 * As discussed in the classic Porter & Duff paper on compositing, 22 * supporting alpha channel properly involves premultiplying color values 23 * that are associated with non-unity alpha values. After considerable 24 * thrashing around trying to read between the lines of the spotty NeXT 25 * documentation, we've concluded that the correct approach is to 26 * premultiply towards whatever the color value 0 represents in the device's 27 * native color space: black for DeviceGray and DeviceRGB (displays and some 28 * file formats), white for DeviceCMYK (color printers), with a special hack 29 * for monochrome printers TBD. This makes things very easy internally, at 30 * the expense of some inconsistency at the boundaries. 31 * 32 * For the record, the only places apparently affected by this decision 33 * are the following: 34 * - alphaimage, if it doesn't assume premultiplication (see below) 35 * - readimage 36 * - The cmap_rgb_alpha_ procedures in gxcmap.c 37 * - [color]image, if they are supposed to use currentalpha (see below) 38 * - The compositing code in gsalphac.c 39 * 40 * The NeXT documentation also is very unclear as to how readimage, 41 * alphaimage, and [color]image are supposed to work. Our current 42 * interpretation is the following: 43 * 44 * - readimage reads pixels exactly as the device stores them 45 * (converted into DeviceGray or DeviceRGB space if the device 46 * uses a palette). Pixels with non-unity alpha come out 47 * premultiplied, however the device stores them. 48 * 49 * - alphaimage assumes the pixels are premultiplied as appropriate 50 * for the relevant color space. This makes alphaimage and 51 * readimage complementary, i.e., the output of readimage is 52 * suitable as the input of alphaimage. 53 * 54 * - [color]image disregard currentalpha, and treat all input as 55 * opaque (alpha = 1). */ 56 /* 57 * Just in case we ever change our minds about the direction of 58 * premultiplication, uncommenting the following preprocessor definition is 59 * supposed to produce premultiplication towards white. 60 */ 61 /*#define PREMULTIPLY_TOWARDS_WHITE */ 62 63 #endif /* gxalpha_INCLUDED */ 64