Class Compositor
- java.lang.Object
-
- uk.ac.starlink.ttools.plot2.paper.Compositor
-
- Direct Known Subclasses:
Compositor.BoostCompositor
public abstract class Compositor extends java.lang.Object
Represents an algorithm for combining multiple RGBA values to produce a single RGBA value. ThecreateBuffer(int)
method produces a buffer containing a vector of pixels for which the compositing operation can be performed on each element.In general RGB values are not pre-multiplied by alpha as used by this class.
- Since:
- 12 Feb 2013
- Author:
- Mark Taylor
- See Also:
RgbImage
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Compositor.BoostCompositor
Compositor with boosted saturation.static interface
Compositor.Buffer
Buffer of pixels on which compositing operations can be performed.
-
Field Summary
Fields Modifier and Type Field Description static Compositor
SATURATION
Implementation which adds colours until the alpha is saturated and then makes no further updates to colour.
-
Constructor Summary
Constructors Constructor Description Compositor()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static float
byteToFloat(int i)
Maps an integer in the range 0-255 to a float in the range 0-1.abstract Compositor.Buffer
createBuffer(int count)
Creates a buffer on which compositing operations can be performed.static int
floatToByte(float f)
Maps a float in the range 0-1 to an int in the range 0-255.abstract float
scaleAlpha(float alpha)
Adjusts an alpha value in accordance with this compositor's policy.static int
srcOverOpaque(int sRgba, int dRgb)
Returns the result of compositing a possibly transparent source pixel over an opaque destination pixel.
-
-
-
Field Detail
-
SATURATION
public static final Compositor SATURATION
Implementation which adds colours until the alpha is saturated and then makes no further updates to colour.
-
-
Method Detail
-
scaleAlpha
public abstract float scaleAlpha(float alpha)
Adjusts an alpha value in accordance with this compositor's policy. It takes an alpha value in the range 0-1 and maps it into the range to be used for output from this compositor.- Parameters:
alpha
- input alpha in range 0-1- Returns:
- adjusted alpha, also in range 0-1
-
createBuffer
public abstract Compositor.Buffer createBuffer(int count)
Creates a buffer on which compositing operations can be performed.- Parameters:
count
- number of pixel elements in buffer- Returns:
- new buffer
-
byteToFloat
public static float byteToFloat(int i)
Maps an integer in the range 0-255 to a float in the range 0-1. Bits more significant than the first 8 are ignored.- Parameters:
i
- integer value- Returns:
- float in range 0-1
-
floatToByte
public static int floatToByte(float f)
Maps a float in the range 0-1 to an int in the range 0-255.- Parameters:
f
- float in range 0-1- Returns:
- int in range 0-255
-
srcOverOpaque
public static int srcOverOpaque(int sRgba, int dRgb)
Returns the result of compositing a possibly transparent source pixel over an opaque destination pixel.- Parameters:
sRgba
- RGBA for source pixeldRgb
- RGB for opaque destination pixel- Returns:
- RGBA for composition result
-
-