[java] Alpha blending?,
Banned - Reputation: 100
Posted 21 April 2000 - 04:01 AM
Members - Reputation: 122
Posted 21 April 2000 - 05:29 AM
How you would accomplish an alpha blended blt of a graphic with variable levels of transparency to the screen would depend on what API you were programming against (DirectX, some version of OPENGL, Java 2D or 3D).
Assuming you are programming in pure Java with no 3D extensions you would use the AlphaComposite class.
Here is a reference on the topic that I found...
A little quote from that reference:
"The AlphaComposite class provides a default implementation of the Composite interface. AlphaComposite supports the blending of new pixel data with existing pixel data using alpha color values in the new and existing pixel data. The alpha color values identify the transparency of a color using a scale of 0.0 to 1.0. If a value of 1.0 is used, the new pixel data completely replaces existing pixel data. If a value of 0.0 is used, any existing pixel data is used instead of new pixel data. If a number between 0.0 and 1.0 is used, the new and existing pixel data are used in proportion to this value. For example, a value of 0.6 causes the color of the new pixel data to contribute 60% of the value of the composite color and the existing pixel data to contribute 40% of the value. In addition to the alpha values of the new and existing pixel data, a separate alpha scale factor may also be specified. This scale factor ranges from 0.0 to 1.0 and is multiplied by the alpha values of the new and existing colors. In addition to this scale factor, the AlphaComposite class provides additional compositing rules. These rules are implemented as class constants and may be used to specify a particular compositing approach."