DVBAlphaComposite

Overview | Package | Class | Use | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.dvb.ui
Class DVBAlphaComposite

    java.lang.Object
      org.dvb.ui.DVBAlphaComposite

    public final class DVBAlphaComposite

extends Object

This `DVBAlphaComposite` class implements the basic alpha compositing rules for combining source and destination pixels to achieve blending and transparency effects with graphics, images and video. The rules implemented by this class are a subset of the Porter-Duff rules described in T. Porter and T. Duff, "Compositing Digital Images", SIGGRAPH 84, 253-259.

If any input does not have an alpha channel, an alpha value of 1,0, which is completely opaque, is assumed for all pixels. A constant alpha value can also be specified to be multiplied with the alpha value of the source pixels.

The following abbreviations are used in the description of the rules:

- Cs = one of the color components of the source pixel without alpha.
- cs = color component of a source pixel premultimlied with alpha (cs = As*Ar*Cs)
- Cd = one of the color components of the destination pixel without alpha.
- cd = color component of a destination pixel premultimlied with alpha
- Cn = the new constructed color without alpha.
- cn = the new constructed color pre-multiplied with alpha
- As = alpha component of the source pixel.
- Ad = alpha component of the destination pixel.
- An = the new alpha after compositing
- Ar = alpha, specified by getInstance(int Rule, float Ar). Unless otherwise specified Ar = 1,0f
- Fs = fraction of the source pixel that contributes to the output.
- Fd = fraction of the input destination pixel that contributes to the output.

The color and alpha components produced by the compositing operation are calculated as follows:

            cn = (As*Ar)*Cs*Fs + Ad*Cd*Fd
            An = (As*Ar)*Fs + Ad*Fd
      Cn = cn/An

where Fs and Fd are specified by each rule.

The alpha resulting from the compositing operation is stored in the destination if the destination has an alpha channel. Otherwise, the resulting color is divided by the resulting alpha before being stored in the destination and the alpha is discarded. If the alpha value is 0,0, the color values are set to 0,0.

Version:
  10 Feb 1997
See Also:
  `AlphaComposite`

Field Summary
`static DVBAlphaComposite` | `Clear` `DVBAlphaComposite` object that implements the opaque CLEAR rule with an alpha (Ar) of 1,0f.
`static int` | `CLEAR` Porter-Duff Clear rule.
`static int` | `DST_IN` Porter-Duff Destination In Source rule.
`static int` | `DST_OUT` Porter-Duff Destination Held Out By Source rule.
`static int` | `DST_OVER` Porter-Duff Destination Over Source rule.
`static DVBAlphaComposite` | `DstIn` `DVBAlphaComposite` object that implements the opaque DST_IN rule with an alpha (Ar) of 1,0f.
`static DVBAlphaComposite` | `DstOut` `DVBAlphaComposite` object that implements the opaque DST_OUT rule with an alpha (Ar) of 1,0f.
`static DVBAlphaComposite` | `DstOver` `DVBAlphaComposite` object that implements the opaque DST_OVER rule with an alpha (Ar) of 1,0f.
`static DVBAlphaComposite` | `Src` `DVBAlphaComposite` object that implements the opaque SRC rule with an alpha (Ar) of 1,0f.
`static int` | `SRC` Porter-Duff Source rule.
`static int` | `SRC_IN` Porter-Duff Source In Destination rule.
`static int` | `SRC_OUT` Porter-Duff Source Held Out By Destination rule.
`static int` | `SRC_OVER` Porter-Duff Source Over Destination rule.
`static DVBAlphaComposite` | `SrcIn` `DVBAlphaComposite` object that implements the opaque SRC_IN rule with an alpha (Ar) of 1,0f.
`static DVBAlphaComposite` | `SrcOut` `DVBAlphaComposite` object that implements the opaque SRC_OUT rule with an alpha (Ar) of 1,0f.
`static DVBAlphaComposite` | `SrcOver` `DVBAlphaComposite` object that implements the opaque SRC_OVER rule with an alpha (Ar) of 1,0f.

Method Summary
`boolean` | `equals(Object obj)` Tests if the specified `Object` is equal to this `DVBAlphaComposite` object.
`float` | `getAlpha()` Returns the alpha value of this `DVBAlphaComposite`.
`static DVBAlphaComposite` | `getInstance(int rule)` Creates an `DVBAlphaComposite` object with the specified rule.
`static DVBAlphaComposite` | `getInstance(int rule, float alpha)` Creates an `DVBAlphaComposite` object with the specified rule and the constant alpha (Ar) to multiply with the alpha of the source (As).
`int` | `getRule()` Returns the compositing rule of this `DVBAlphaComposite`.

Methods inherited from class java.lang.Object
`getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### CLEAR

    public static final int CLEAR

  Porter-Duff Clear rule. Both the color and the alpha of the destination are cleared. Neither the source nor the destination is used as input.

  Fs = 0 and Fd = 0, thus:

              cn = 0
              An = 0
        Cn = 0

  Note that this operation is a fast drawing operation This operation is the same as using a source with alpha= 0 and the SRC rule

  See Also:
    Constant Field Values

### SRC

    public static final int SRC

  Porter-Duff Source rule. The source is copied to the destination. The destination is not used as input.

  Fs = 1 and Fd = 0, thus:

              cn = (As*Ar)*Cs
              An = As*Ar
        Cn = Cs

  Note that this is a fast drawing routine

  See Also:
    Constant Field Values

### SRC_OVER

    public static final int SRC_OVER

  Porter-Duff Source Over Destination rule. The source is composited over the destination.

  Fs = 1 and Fd = (1-(As*Ar)), thus:

              cn = (As*Ar)*Cs + Ad*Cd*(1-(As*Ar))
              An = (As*Ar) + Ad*(1-(As*Ar))

  Note that this can be a very slow drawing operation

  See Also:
    Constant Field Values

### DST_OVER

    public static final int DST_OVER

  Porter-Duff Destination Over Source rule. The destination is composited over the source and the result replaces the destination.

  Fs = (1-Ad) and Fd = 1, thus:

              cn = (As*Ar)*Cs*(1-Ad) + Ad*Cd
              An = (As*Ar)*(1-Ad) + Ad

  Note that this can be a very slow drawing operation

  See Also:
    Constant Field Values

### SRC_IN

    public static final int SRC_IN

  Porter-Duff Source In Destination rule. The part of the source lying inside of the destination replaces the destination.

  Fs = Ad and Fd = 0, thus:

              cn = (As*Ar)*Cs*Ad
              An = (As*Ar)*Ad
        Cn = Cs

  Note that this operation is faster than e.g. SRC_OVER but slower than SRC

  See Also:
    Constant Field Values

### DST_IN

    public static final int DST_IN

  Porter-Duff Destination In Source rule. The part of the destination lying inside of the source replaces the destination.

  Fs = 0 and Fd = (As*Ar), thus:

              cn = Ad*Cd*(As*Ar)
              An = Ad*(As*Ar)
        Cn = Cd

  Note that this operation is faster than e.g. SRC_OVER but slower than SRC

  See Also:
    Constant Field Values

### SRC_OUT

    public static final int SRC_OUT

  Porter-Duff Source Held Out By Destination rule. The part of the source lying outside of the destination replaces the destination.

  Fs = (1-Ad) and Fd = 0, thus:

              cn = (As*Ar)*Cs*(1-Ad)
              An = (As*Ar)*(1-Ad)
        Cn = Cs

  Note that this operation is faster than e.g. SRC_OVER but slower than SRC

  See Also:
    Constant Field Values

### DST_OUT

    public static final int DST_OUT

  Porter-Duff Destination Held Out By Source rule. The part of the destination lying outside of the source replaces the destination.

  Fs = 0 and Fd = (1-(As*Ar)), thus:

              cn = Ad*Cd*(1-(As*Ar))
              An = Ad*(1-(As*Ar))
        Cn = Cd

  Note that this operation is faster than e.g. SRC_OVER but slower than SRC

  See Also:
    Constant Field Values

### Clear

    public static final DVBAlphaComposite Clear

  `DVBAlphaComposite` object that implements the opaque CLEAR rule with an alpha (Ar) of 1,0f.

  See Also:
    `CLEAR`

### Src

    public static final DVBAlphaComposite Src

  `DVBAlphaComposite` object that implements the opaque SRC rule with an alpha (Ar) of 1,0f.

  See Also:
    `SRC`

### SrcOver

    public static final DVBAlphaComposite SrcOver

  `DVBAlphaComposite` object that implements the opaque SRC_OVER rule with an alpha (Ar) of 1,0f.

  See Also:
    `SRC_OVER`

### DstOver

    public static final DVBAlphaComposite DstOver

  `DVBAlphaComposite` object that implements the opaque DST_OVER rule with an alpha (Ar) of 1,0f.

  See Also:
    `DST_OVER`

### SrcIn

    public static final DVBAlphaComposite SrcIn

  `DVBAlphaComposite` object that implements the opaque SRC_IN rule with an alpha (Ar) of 1,0f.

  See Also:
    `SRC_IN`

### DstIn

    public static final DVBAlphaComposite DstIn

  `DVBAlphaComposite` object that implements the opaque DST_IN rule with an alpha (Ar) of 1,0f.

  See Also:
    `DST_IN`

### SrcOut

    public static final DVBAlphaComposite SrcOut

  `DVBAlphaComposite` object that implements the opaque SRC_OUT rule with an alpha (Ar) of 1,0f.

  See Also:
    `SRC_OUT`

### DstOut

    public static final DVBAlphaComposite DstOut

  `DVBAlphaComposite` object that implements the opaque DST_OUT rule with an alpha (Ar) of 1,0f.

  See Also:
    `DST_OUT`

Method Detail

### equals

    public boolean equals(Object obj)

  Tests if the specified `Object` is equal to this `DVBAlphaComposite` object.

  Overrides:
    `equals` in class `Object`
  Parameters:
    `obj` - the `Object` to test for equality
  Returns:
    `true` if `obj` is a DVBAlphaComposite and has the same values for rule and alpha as this object. Otherwise `false` shall be returned.
  See Also:
    `Object.hashCode()`, `Hashtable`

### getAlpha

    public float getAlpha()

  Returns the alpha value of this `DVBAlphaComposite`. If this `DVBAlphaComposite` does not have an alpha value, 1,0 is returned.

  Returns:
    the alpha value of this `DVBAlphaComposite`.

### getInstance

    public static DVBAlphaComposite getInstance(int rule)

  Creates an `DVBAlphaComposite` object with the specified rule. The value for alpha shall be 1,0f.

  Parameters:
    `rule` - the compositing rule
  Returns:
    an `DVBAlphaComposite` object with the specified rule.

### getInstance

    public static DVBAlphaComposite getInstance(int rule,
                                                float alpha)

  Creates an `DVBAlphaComposite` object with the specified rule and the constant alpha (Ar) to multiply with the alpha of the source (As). The source is multiplied with the specified alpha before being composited with the destination.

  Parameters:
    `rule` - the compositing rule
    `alpha` - the constant alpha (Ar) to be multiplied with the alpha of the source (As). `alpha` must be a floating point number in the inclusive range [0,0, 1,0].
  Returns:
    an `DVBAlphaComposite` object with the specified rule and the constant alpha to multiply with the alpha of the source.

### getRule

    public int getRule()

  Returns the compositing rule of this `DVBAlphaComposite`.

  Returns:
    the compositing rule of this `DVBAlphaComposite`.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD