programming layer blend modes

Started by
-1 comments, last by heron3d 16 years, 3 months ago
Hi I am programming the pin light blend mode found in photoshop. What the transfer mode does is pretty much compare 2 pixels and keep the darker one. Im not sure how to convert and compare vectors with scalars This is the algorithm: A - foreground RGB B - background RGB C - composite RGB vectors tonal values are normalized as such 1 = 255/255 ...scalar There are three conditional statements in the algorithm if(B < 2 * A - 1) { C = 2 * A - 1;// the 1 in the equation is throwing me off } else if ( ( B > 2 * A - 1 ) && ( B < 2 * A ) ) { C = B; } else if ( B > 2 * A ) { C = 2 * A; } How do I convert RGB values, which are vectors, to tonal values which are scalars? 2 * vector gives you a result vector. How do I subtract 1 from a result vector? Do I subtract 1 from each element or from the magnitude of the result vector?... I'm not sure. or is 1 the magnitude of the vector which has to be subtracted from the result vector. The second statement compares which vector is greater ( B < 2*A ). Is it comparing the magnitudes of the vectors? Please help Nikos

This topic is closed to new replies.

Advertisement