Generally, the file format's open() function will set spec.alpha_channel to the right one (numbering starts at 0) or -1 if it could not identify which channel was supposed to be alpha.
I'd recommend the following heuristic: * If spec.alpha_channel >= 0, use that as the alpha channel. Composite all channels, no matter how many or few there are. * If spec.alpha_channel < 0, but it's a 4-channel image, assume that channel 3 is alpha. * If spec.alpha_channel < 0, but it's a 3-channel image, assume it's RGB and treat it as if alpha==1 everywhere (opaque image). * Reject if the two images do not have the same number of non-alpha channels (i.e., allow for RGB with implied alpha=1). Assume that if the number of channels match, their meaning matches between the two images. On Jun 10, 2012, at 1:10 AM, Stefan Stavrev wrote: > 1. Can I assume that if the image has at least 3 channels, they are RGB, or > if it has at least 4 channels they are RGBA? Yes, unless spec.alpha_channel explicitly designates an alpha channel. > 2. What should I do for images with channels RGBAZXYZ..., that is, images > with more than 5 channels? Composite them all. > 3. What if one image has channels RGBA and the other RGBAZ? I should preserve > the Z channel in the result image, or fail the operation? Fail if the number of non-alpha channels doesn't match. > > Channels being able to take arbitrary names makes things harder. I guess > assumptions like the above will need to be made in many cases. Don't worry about the names. -- Larry Gritz [email protected] _______________________________________________ Oiio-dev mailing list [email protected] http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
