Nah, I'd say either accept the ambiguous cases, or reject them. I wouldn't go
down the path of "converting" the images.
Incidentally, you could turn the loops inside out. Instead of
for all pixels:
if (A has alpha and B has alpha)
R = A + A.alpha * B;
else if (A has alpha)
R = A + A.alpha + (B,0);
...
you could have
if (A has alpha and B has alpha)
for all pixels:
R = A + A.alpha * B;
else if (A has alpha)
for all pixels:
R = A + A.alpha + (B,0);
...
There's still extra complexity this way, but no performance issues at all.
On Jun 13, 2012, at 12:02 PM, Stefan Stavrev wrote:
> Related to the previous message, how about we do include all these checks and
> put all that code in a separate function as Larry suggested, but instead of
> returning true or false, this function will modify the images. If an alpha
> channel is missing and we assume it should have it, we will add one.
> Basically do any modification needed and prepare the images for our original
> function and then call it with valid input.
>
> Things got messy because I was putting the checks in the loops over the
> image. Each time you get a pixel value from the iterator, you need to check
> for all images which one has alpha and which one does not, and based on that
> get the alpha from the appropriate place, etc.
>
> Summary: I suggest we put alll input validation code in one function that
> will modify the images as needed, and then call the image processing function
> which will assume correct input.
> _______________________________________________
> Oiio-dev mailing list
> [email protected]
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
--
Larry Gritz
[email protected]
_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org