de.lmu.ifi.dbs.elki.data.images
Class BlendComposite.BlendingContext

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.data.images.BlendComposite.BlendingContext
All Implemented Interfaces:
CompositeContext
Direct Known Subclasses:
BlendComposite.AverageBlendingContext, BlendComposite.DarkenBlendingContext, BlendComposite.LightenBlendingContext, BlendComposite.MultiplyBlendingContext, BlendComposite.OverlayBlendingContext, BlendComposite.ScreenBlendingContext
Enclosing class:
BlendComposite

protected class BlendComposite.BlendingContext
extends Object
implements CompositeContext

Abstract blending context that takes care of color space conversion and pixel iteration. The base class does simple replacing.


Field Summary
protected  double alpha
          Opacity factor
private  ColorModel dstColorModel
          Destination color model
protected  double ialpha
          Additive inverse of alpha value.
private  ColorModel srcColorModel
          Source color model
 
Constructor Summary
protected BlendComposite.BlendingContext(ColorModel srcColorModel, ColorModel dstColorModel, double alpha)
          Constructor.
 
Method Summary
protected  int blend(int sA, int sR, int sG, int sB, int dA, int dR, int dG, int dB)
          The actual blending function for two colors.
 void compose(Raster src, Raster dstIn, WritableRaster dstOut)
          Compose a raster image (source) and a background (destination) to a result raster.
 void dispose()
           
protected  int mixAlpha(int nA, int nR, int nG, int nB, int dA, int dR, int dG, int dB)
          Mix the new values with the original values taking the alpha value into account.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

srcColorModel

private ColorModel srcColorModel
Source color model


dstColorModel

private ColorModel dstColorModel
Destination color model


alpha

protected double alpha
Opacity factor


ialpha

protected double ialpha
Additive inverse of alpha value.

Constructor Detail

BlendComposite.BlendingContext

protected BlendComposite.BlendingContext(ColorModel srcColorModel,
                                         ColorModel dstColorModel,
                                         double alpha)
Constructor.

Parameters:
srcColorModel - source color model
dstColorModel - destination color model
alpha - Alpha (opacity) factor
Method Detail

dispose

public void dispose()
Specified by:
dispose in interface CompositeContext

compose

public void compose(Raster src,
                    Raster dstIn,
                    WritableRaster dstOut)
Compose a raster image (source) and a background (destination) to a result raster.

Specified by:
compose in interface CompositeContext

blend

protected int blend(int sA,
                    int sR,
                    int sG,
                    int sB,
                    int dA,
                    int dR,
                    int dG,
                    int dB)
The actual blending function for two colors.

Parameters:
sA - source alpha component (0-255)
sR - source red component (0-255)
sG - source green component (0-255)
sB - source blue component (0-255)
dA - destination alpha component (0-255)
dR - destination red component (0-255)
dG - destination green component (0-255)
dB - destination blues component (0-255)
Returns:
Combined color in single-integer ARGB format (see BlendComposite.combineComponents(int, int, int, int) and mixAlpha(int, int, int, int, int, int, int, int) helper functions)

mixAlpha

protected int mixAlpha(int nA,
                       int nR,
                       int nG,
                       int nB,
                       int dA,
                       int dR,
                       int dG,
                       int dB)
Mix the new values with the original values taking the alpha value into account.

Parameters:
nA - new alpha component (0-255)
nR - new red component (0-255)
nG - new green component (0-255)
nB - new blue component (0-255)
dA - old alpha component (0-255)
dR - old red component (0-255)
dG - old green component (0-255)
dB - old blue component (0-255)
Returns:
Combined color in single-integer ARGB format.

Release 0.4.0 (2011-09-20_1324)