55 * Since the {@code ColorModel} and {@code Raster} classes 56 * allow the storage of pixel data in either premultiplied or 57 * non-premultiplied form, all input data must be normalized into 58 * premultiplied form before applying the equations and all results 59 * might need to be adjusted back to the form required by the destination 60 * before the pixel values are stored. 61 * 62 * <p> 63 * Also note that this class defines only the equations 64 * for combining color and alpha values in a purely mathematical 65 * sense. The accurate application of its equations depends 66 * on the way the data is retrieved from its sources and stored 67 * in its destinations. 68 * See <a href="#caveats">Implementation Caveats</a> 69 * for further information. 70 * 71 * <p> 72 * The following factors are used in the description of the blending 73 * equation in the Porter and Duff paper: 74 * 75 * <blockquote> 76 * <table class="borderless"> 77 * <caption style="display:none">Factors</caption> 78 * <tr><th style="text-align:left">Factor <th style="text-align:left">Definition 79 * <tr><td><em>A<sub>s</sub></em><td>the alpha component of the source pixel 80 * <tr><td><em>C<sub>s</sub></em><td>a color component of the source pixel in premultiplied form 81 * <tr><td><em>A<sub>d</sub></em><td>the alpha component of the destination pixel 82 * <tr><td><em>C<sub>d</sub></em><td>a color component of the destination pixel in premultiplied form 83 * <tr><td><em>F<sub>s</sub></em><td>the fraction of the source pixel that contributes to the output 84 * <tr><td><em>F<sub>d</sub></em><td>the fraction of the destination pixel that contributes 85 * to the output 86 * <tr><td><em>A<sub>r</sub></em><td>the alpha component of the result 87 * <tr><td><em>C<sub>r</sub></em><td>a color component of the result in premultiplied form 88 * </table> 89 * </blockquote> 90 * 91 * <p> 92 * Using these factors, Porter and Duff define 12 ways of choosing 93 * the blending factors <em>F<sub>s</sub></em> and <em>F<sub>d</sub></em> to 94 * produce each of 12 desirable visual effects. 95 * The equations for determining <em>F<sub>s</sub></em> and <em>F<sub>d</sub></em> 96 * are given in the descriptions of the 12 static fields 97 * that specify visual effects. 98 * For example, 99 * the description for 100 * <a href="#SRC_OVER">{@code SRC_OVER}</a> 101 * specifies that <em>F<sub>s</sub></em> = 1 and <em>F<sub>d</sub></em> = (1-<em>A<sub>s</sub></em>). 102 * Once a set of equations for determining the blending factors is 103 * known they can then be applied to each pixel to produce a result 104 * using the following set of equations: 105 * 106 * <pre> 107 * <em>F<sub>s</sub></em> = <em>f</em>(<em>A<sub>d</sub></em>) 108 * <em>F<sub>d</sub></em> = <em>f</em>(<em>A<sub>s</sub></em>) 109 * <em>A<sub>r</sub></em> = <em>A<sub>s</sub></em>*<em>F<sub>s</sub></em> + <em>A<sub>d</sub></em>*<em>F<sub>d</sub></em> 110 * <em>C<sub>r</sub></em> = <em>C<sub>s</sub></em>*<em>F<sub>s</sub></em> + <em>C<sub>d</sub></em>*<em>F<sub>d</sub></em></pre> 111 * 112 * <p> 113 * The following factors will be used to discuss our extensions to 114 * the blending equation in the Porter and Duff paper: 115 * 116 * <blockquote> 117 * <table class="borderless"> 118 * <caption style="display:none">Factors</caption> 119 * <tr><th style="text-align:left">Factor <th style="text-align:left">Definition 120 * <tr><td><em>C<sub>sr</sub></em> <td>one of the raw color components of the source pixel 121 * <tr><td><em>C<sub>dr</sub></em> <td>one of the raw color components of the destination pixel 122 * <tr><td><em>A<sub>ac</sub></em> <td>the "extra" alpha component from the AlphaComposite instance 123 * <tr><td><em>A<sub>sr</sub></em> <td>the raw alpha component of the source pixel 124 * <tr><td><em>A<sub>dr</sub></em><td>the raw alpha component of the destination pixel 125 * <tr><td><em>A<sub>df</sub></em> <td>the final alpha component stored in the destination 126 * <tr><td><em>C<sub>df</sub></em> <td>the final raw color component stored in the destination 127 * </table> 128 *</blockquote> 129 * 130 * <h3>Preparing Inputs</h3> 131 * 132 * <p> 133 * The {@code AlphaComposite} class defines an additional alpha 134 * value that is applied to the source alpha. 135 * This value is applied as if an implicit SRC_IN rule were first 136 * applied to the source pixel against a pixel with the indicated 137 * alpha by multiplying both the raw source alpha and the raw 138 * source colors by the alpha in the {@code AlphaComposite}. 139 * This leads to the following equation for producing the alpha 140 * used in the Porter and Duff blending equation: 141 * 142 * <pre> 143 * <em>A<sub>s</sub></em> = <em>A<sub>sr</sub></em> * <em>A<sub>ac</sub></em> </pre> 144 * 145 * All of the raw source color components need to be multiplied 146 * by the alpha in the {@code AlphaComposite} instance. 147 * Additionally, if the source was not in premultiplied form 148 * then the color components also need to be multiplied by the | 55 * Since the {@code ColorModel} and {@code Raster} classes 56 * allow the storage of pixel data in either premultiplied or 57 * non-premultiplied form, all input data must be normalized into 58 * premultiplied form before applying the equations and all results 59 * might need to be adjusted back to the form required by the destination 60 * before the pixel values are stored. 61 * 62 * <p> 63 * Also note that this class defines only the equations 64 * for combining color and alpha values in a purely mathematical 65 * sense. The accurate application of its equations depends 66 * on the way the data is retrieved from its sources and stored 67 * in its destinations. 68 * See <a href="#caveats">Implementation Caveats</a> 69 * for further information. 70 * 71 * <p> 72 * The following factors are used in the description of the blending 73 * equation in the Porter and Duff paper: 74 * 75 * <table class="striped"> 76 * <caption style="display:none">Factors</caption> 77 * <thead> 78 * <tr> 79 * <th scope="col">Factor 80 * <th scope="col">Definition 81 * </thead> 82 * <tbody> 83 * <tr> 84 * <th scope="row"><em>A<sub>s</sub></em> 85 * <td>the alpha component of the source pixel 86 * <tr> 87 * <th scope="row"><em>C<sub>s</sub></em> 88 * <td>a color component of the source pixel in premultiplied form 89 * <tr> 90 * <th scope="row"><em>A<sub>d</sub></em> 91 * <td>the alpha component of the destination pixel 92 * <tr> 93 * <th scope="row"><em>C<sub>d</sub></em> 94 * <td>a color component of the destination pixel in premultiplied form 95 * <tr> 96 * <th scope="row"><em>F<sub>s</sub></em> 97 * <td>the fraction of the source pixel that contributes to the output 98 * <tr> 99 * <th scope="row"><em>F<sub>d</sub></em> 100 * <td>the fraction of the destination pixel that contributes to the output 101 * <tr> 102 * <th scope="row"><em>A<sub>r</sub></em> 103 * <td>the alpha component of the result 104 * <tr> 105 * <th scope="row"><em>C<sub>r</sub></em> 106 * <td>a color component of the result in premultiplied form 107 * </tbody> 108 * </table> 109 * <p> 110 * Using these factors, Porter and Duff define 12 ways of choosing 111 * the blending factors <em>F<sub>s</sub></em> and <em>F<sub>d</sub></em> to 112 * produce each of 12 desirable visual effects. 113 * The equations for determining <em>F<sub>s</sub></em> and <em>F<sub>d</sub></em> 114 * are given in the descriptions of the 12 static fields 115 * that specify visual effects. 116 * For example, 117 * the description for 118 * <a href="#SRC_OVER">{@code SRC_OVER}</a> 119 * specifies that <em>F<sub>s</sub></em> = 1 and <em>F<sub>d</sub></em> = (1-<em>A<sub>s</sub></em>). 120 * Once a set of equations for determining the blending factors is 121 * known they can then be applied to each pixel to produce a result 122 * using the following set of equations: 123 * 124 * <pre> 125 * <em>F<sub>s</sub></em> = <em>f</em>(<em>A<sub>d</sub></em>) 126 * <em>F<sub>d</sub></em> = <em>f</em>(<em>A<sub>s</sub></em>) 127 * <em>A<sub>r</sub></em> = <em>A<sub>s</sub></em>*<em>F<sub>s</sub></em> + <em>A<sub>d</sub></em>*<em>F<sub>d</sub></em> 128 * <em>C<sub>r</sub></em> = <em>C<sub>s</sub></em>*<em>F<sub>s</sub></em> + <em>C<sub>d</sub></em>*<em>F<sub>d</sub></em></pre> 129 * 130 * <p> 131 * The following factors will be used to discuss our extensions to 132 * the blending equation in the Porter and Duff paper: 133 * 134 * <table class="striped"> 135 * <caption style="display:none">Factors</caption> 136 * <thead> 137 * <tr> 138 * <th scope="col">Factor 139 * <th scope="col">Definition 140 * </thead> 141 * <tbody> 142 * <tr> 143 * <th scope="row"><em>C<sub>sr</sub></em> 144 * <td>one of the raw color components of the source pixel 145 * <tr> 146 * <th scope="row"><em>C<sub>dr</sub></em> 147 * <td>one of the raw color components of the destination pixel 148 * <tr> 149 * <th scope="row"><em>A<sub>ac</sub></em> 150 * <td>the "extra" alpha component from the AlphaComposite instance 151 * <tr> 152 * <th scope="row"><em>A<sub>sr</sub></em> 153 * <td>the raw alpha component of the source pixel 154 * <tr> 155 * <th scope="row"><em>A<sub>dr</sub></em> 156 * <td>the raw alpha component of the destination pixel 157 * <tr> 158 * <th scope="row"><em>A<sub>df</sub></em> 159 * <td>the final alpha component stored in the destination 160 * <tr> 161 * <th scope="row"><em>C<sub>df</sub></em> 162 * <td>the final raw color component stored in the destination 163 * </tbody> 164 * </table> 165 * 166 * <h3>Preparing Inputs</h3> 167 * 168 * <p> 169 * The {@code AlphaComposite} class defines an additional alpha 170 * value that is applied to the source alpha. 171 * This value is applied as if an implicit SRC_IN rule were first 172 * applied to the source pixel against a pixel with the indicated 173 * alpha by multiplying both the raw source alpha and the raw 174 * source colors by the alpha in the {@code AlphaComposite}. 175 * This leads to the following equation for producing the alpha 176 * used in the Porter and Duff blending equation: 177 * 178 * <pre> 179 * <em>A<sub>s</sub></em> = <em>A<sub>sr</sub></em> * <em>A<sub>ac</sub></em> </pre> 180 * 181 * All of the raw source color components need to be multiplied 182 * by the alpha in the {@code AlphaComposite} instance. 183 * Additionally, if the source was not in premultiplied form 184 * then the color components also need to be multiplied by the |